From: Eduard-Mihai Burtescu Date: Mon, 14 Jan 2019 22:41:14 +0000 (+0200) Subject: rustc_codegen_utils: print all nominal types as paths, in symbol names. X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=6d67d6846c9d25b1cffdafd8c330e6374532b5d8;p=rust.git rustc_codegen_utils: print all nominal types as paths, in symbol names. --- diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 3c8bd0dd01b..a17a554480e 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -422,7 +422,18 @@ fn print_type( self: PrintCx<'_, '_, 'tcx, Self>, ty: Ty<'tcx>, ) -> Result { - self.pretty_print_type(ty) + match ty.sty { + // Print all nominal types as paths (unlike `pretty_print_type`). + ty::FnDef(def_id, substs) | + ty::Opaque(def_id, substs) | + ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs }) | + ty::UnnormalizedProjection(ty::ProjectionTy { item_def_id: def_id, substs }) | + ty::Closure(def_id, ty::ClosureSubsts { substs }) | + ty::Generator(def_id, ty::GeneratorSubsts { substs }, _) => { + self.print_def_path(def_id, Some(substs), iter::empty()) + } + _ => self.pretty_print_type(ty), + } } fn path_crate( @@ -437,7 +448,22 @@ fn path_qualified( self_ty: Ty<'tcx>, trait_ref: Option>, ) -> Result { - self.pretty_path_qualified(self_ty, trait_ref) + // Similar to `pretty_path_qualified`, but for the other + // types that are printed as paths (see `print_type` above). + match self_ty.sty { + ty::FnDef(..) | + ty::Opaque(..) | + ty::Projection(_) | + ty::UnnormalizedProjection(_) | + ty::Closure(..) | + ty::Generator(..) + if trait_ref.is_none() => + { + self.print_type(self_ty) + } + + _ => self.pretty_path_qualified(self_ty, trait_ref) + } } fn path_append_impl<'gcx, 'tcx>(