Skip to content

Commit 194f38f

Browse files
committed
rustboot: Don't use ridiculous type names when describing simple types like int and uint
1 parent a7840f0 commit 194f38f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/boot/fe/ast.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,17 @@ let sane_name (n:name) : bool =
516516
| NAME_ext (prefix, _) -> sane_prefix prefix
517517
;;
518518

519+
(* Error messages always refer to simple types structurally, not by their
520+
* user-defined names. *)
521+
let rec ty_is_simple (ty:ty) : bool =
522+
match ty with
523+
TY_any | TY_nil | TY_bool | TY_mach _ | TY_int | TY_uint | TY_char
524+
| TY_str | TY_task | TY_type -> true
525+
| TY_vec ty | TY_chan ty | TY_port ty -> ty_is_simple ty
526+
| TY_tup tys -> List.for_all ty_is_simple (Array.to_list tys)
527+
| _ -> false
528+
;;
529+
519530
(*
520531
* We have multiple subset-categories of expression:
521532
*

src/boot/me/semant.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ let ty_fold_rebuild (id:Ast.ty -> Ast.ty)
971971

972972
let rec pretty_ty_str (cx:ctxt) (fallback:(Ast.ty -> string)) (ty:Ast.ty) =
973973
let cache = cx.ctxt_user_type_names in
974-
if Hashtbl.mem cache ty then
974+
if not (Ast.ty_is_simple ty) && Hashtbl.mem cache ty then
975975
let names = List.map (Ast.sprintf_name ()) (Hashtbl.find_all cache ty) in
976976
String.concat " = " names
977977
else

0 commit comments

Comments
 (0)