@@ -2,12 +2,12 @@ use std::mem;
2
2
3
3
use rustc_ast:: visit:: FnKind ;
4
4
use rustc_ast:: * ;
5
- use rustc_ast_pretty:: pprust;
6
5
use rustc_attr_parsing:: { AttributeParser , Early , OmitDoc } ;
7
6
use rustc_expand:: expand:: AstFragment ;
8
7
use rustc_hir as hir;
9
8
use rustc_hir:: def:: { CtorKind , CtorOf , DefKind } ;
10
9
use rustc_hir:: def_id:: LocalDefId ;
10
+ use rustc_middle:: span_bug;
11
11
use rustc_span:: hygiene:: LocalExpnId ;
12
12
use rustc_span:: { Span , Symbol , sym} ;
13
13
use tracing:: debug;
@@ -380,20 +380,20 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
380
380
}
381
381
382
382
fn visit_ty ( & mut self , ty : & ' a Ty ) {
383
- match & ty. kind {
383
+ match ty. kind {
384
384
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 " ) ) ;
391
391
let kind = match self . invocation_parent . impl_trait_context {
392
392
ImplTraitContext :: Universal => DefKind :: TyParam ,
393
393
ImplTraitContext :: Existential => DefKind :: OpaqueTy ,
394
394
ImplTraitContext :: InBinding => return visit:: walk_ty ( self , ty) ,
395
395
} ;
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 ) ;
397
397
match self . invocation_parent . impl_trait_context {
398
398
// Do not nest APIT, as we desugar them as `impl_trait: bounds`,
399
399
// so the `impl_trait` node is not a parent to `bounds`.
0 commit comments