@@ -9,16 +9,16 @@ use rustc_hir::def_id::LocalDefId;
9
9
use rustc_span:: hygiene:: LocalExpnId ;
10
10
use rustc_span:: symbol:: { kw, sym, Symbol } ;
11
11
use rustc_span:: Span ;
12
- use tracing:: { debug, instrument } ;
12
+ use tracing:: debug;
13
13
14
- use crate :: { ImplTraitContext , PendingAnonConstInfo , Resolver } ;
14
+ use crate :: { ImplTraitContext , InvocationParent , PendingAnonConstInfo , Resolver } ;
15
15
16
16
pub ( crate ) fn collect_definitions (
17
17
resolver : & mut Resolver < ' _ , ' _ > ,
18
18
fragment : & AstFragment ,
19
19
expansion : LocalExpnId ,
20
20
) {
21
- let ( parent_def, pending_anon_const_info, impl_trait_context, in_attr) =
21
+ let InvocationParent { parent_def, pending_anon_const_info, impl_trait_context, in_attr } =
22
22
resolver. invocation_parents [ & expansion] ;
23
23
let mut visitor = DefCollector {
24
24
resolver,
@@ -50,17 +50,6 @@ impl<'a, 'b, 'tcx> DefCollector<'a, 'b, 'tcx> {
50
50
span : Span ,
51
51
) -> LocalDefId {
52
52
let parent_def = self . parent_def ;
53
- self . create_def_with_parent ( parent_def, node_id, name, def_kind, span)
54
- }
55
-
56
- fn create_def_with_parent (
57
- & mut self ,
58
- parent_def : LocalDefId ,
59
- node_id : NodeId ,
60
- name : Symbol ,
61
- def_kind : DefKind ,
62
- span : Span ,
63
- ) -> LocalDefId {
64
53
debug ! (
65
54
"create_def(node_id={:?}, def_kind={:?}, parent_def={:?})" ,
66
55
node_id, def_kind, parent_def
@@ -133,7 +122,12 @@ impl<'a, 'b, 'tcx> DefCollector<'a, 'b, 'tcx> {
133
122
let pending_anon_const_info = self . pending_anon_const_info . take ( ) ;
134
123
let old_parent = self . resolver . invocation_parents . insert (
135
124
id,
136
- ( self . parent_def , pending_anon_const_info, self . impl_trait_context , self . in_attr ) ,
125
+ InvocationParent {
126
+ parent_def : self . parent_def ,
127
+ pending_anon_const_info,
128
+ impl_trait_context : self . impl_trait_context ,
129
+ in_attr : self . in_attr ,
130
+ } ,
137
131
) ;
138
132
assert ! ( old_parent. is_none( ) , "parent `LocalDefId` is reset for an invocation" ) ;
139
133
}
@@ -334,7 +328,6 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
334
328
}
335
329
}
336
330
337
- #[ instrument( level = "debug" , skip( self ) ) ]
338
331
fn visit_anon_const ( & mut self , constant : & ' a AnonConst ) {
339
332
// HACK(min_generic_const_args): don't create defs for anon consts if we think they will
340
333
// later be turned into ConstArgKind::Path's. because this is before resolve is done, we
@@ -343,18 +336,12 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
343
336
// items will be messed up, but that's ok because there can't be any if we're just looking
344
337
// for bare idents.
345
338
if matches ! ( constant. value. maybe_unwrap_block( ) . kind, ExprKind :: MacCall ( ..) ) {
346
- debug ! ( "ATTN(strict): unwrapped const is macro" ) ;
347
- self . pending_anon_const_info = Some ( PendingAnonConstInfo {
348
- parent_def : self . parent_def ,
349
- id : constant. id ,
350
- span : constant. value . span ,
351
- } ) ;
339
+ self . pending_anon_const_info =
340
+ Some ( PendingAnonConstInfo { id : constant. id , span : constant. value . span } ) ;
352
341
visit:: walk_anon_const ( self , constant)
353
342
} else if constant. value . is_potential_trivial_const_arg ( ) {
354
- debug ! ( "ATTN(strict): unwrapped const is potentially trivial" ) ;
355
343
visit:: walk_anon_const ( self , constant)
356
344
} else {
357
- debug ! ( "ATTN(strict): unwrapped const is not trivial" ) ;
358
345
let def =
359
346
self . create_def ( constant. id , kw:: Empty , DefKind :: AnonConst , constant. value . span ) ;
360
347
self . with_parent ( def, |this| visit:: walk_anon_const ( this, constant) ) ;
@@ -367,19 +354,10 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
367
354
}
368
355
369
356
let grandparent_def = if let Some ( pending_anon) = self . pending_anon_const_info {
370
- debug ! ( "ATTN(lazy): pending anon={pending_anon:?} expr={expr:?}" ) ;
371
357
self . pending_anon_const_info = None ;
372
358
if !expr. is_potential_trivial_const_arg ( ) {
373
- debug ! ( "ATTN(lazy): pending anon is not trivial" ) ;
374
- self . create_def_with_parent (
375
- pending_anon. parent_def ,
376
- pending_anon. id ,
377
- kw:: Empty ,
378
- DefKind :: AnonConst ,
379
- pending_anon. span ,
380
- )
359
+ self . create_def ( pending_anon. id , kw:: Empty , DefKind :: AnonConst , pending_anon. span )
381
360
} else {
382
- debug ! ( "ATTN(lazy): pending anon is potentially trivial" ) ;
383
361
self . parent_def
384
362
}
385
363
} else {
0 commit comments