@@ -2,12 +2,12 @@ use std::mem;
22
33use rustc_ast:: visit:: FnKind ;
44use rustc_ast:: * ;
5- use rustc_ast_pretty:: pprust;
65use rustc_attr_parsing:: { AttributeParser , OmitDoc } ;
76use rustc_expand:: expand:: AstFragment ;
87use rustc_hir as hir;
98use rustc_hir:: def:: { CtorKind , CtorOf , DefKind } ;
109use rustc_hir:: def_id:: LocalDefId ;
10+ use rustc_middle:: span_bug;
1111use rustc_span:: hygiene:: LocalExpnId ;
1212use rustc_span:: { Span , Symbol , sym} ;
1313use tracing:: debug;
@@ -380,20 +380,20 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
380380 }
381381
382382 fn visit_ty ( & mut self , ty : & ' a Ty ) {
383- match & ty. kind {
383+ match ty. kind {
384384 TyKind :: MacCall ( ..) => self . visit_macro_invoc ( ty. id ) ,
385- TyKind :: ImplTrait ( id , _) => {
386- // HACK: pprust breaks strings with newlines when the type
387- // gets too long. We don't want these to show up in compiler
388- // output or built artifacts, so replace them here...
389- // Perhaps we should instead format APITs more robustly.
390- let name = Symbol :: intern ( & pprust :: ty_to_string ( ty) . replace ( '\n' , " " ) ) ;
385+ TyKind :: ImplTrait ( opaque_id , _) => {
386+ let name = * self
387+ . resolver
388+ . impl_trait_names
389+ . get ( & ty . id )
390+ . unwrap_or_else ( || span_bug ! ( ty. span , "expected this opaque to be named " ) ) ;
391391 let kind = match self . invocation_parent . impl_trait_context {
392392 ImplTraitContext :: Universal => DefKind :: TyParam ,
393393 ImplTraitContext :: Existential => DefKind :: OpaqueTy ,
394394 ImplTraitContext :: InBinding => return visit:: walk_ty ( self , ty) ,
395395 } ;
396- let id = self . create_def ( * id , Some ( name) , kind, ty. span ) ;
396+ let id = self . create_def ( opaque_id , Some ( name) , kind, ty. span ) ;
397397 match self . invocation_parent . impl_trait_context {
398398 // Do not nest APIT, as we desugar them as `impl_trait: bounds`,
399399 // so the `impl_trait` node is not a parent to `bounds`.
0 commit comments