@@ -9,16 +9,16 @@ use rustc_hir::def_id::LocalDefId;
99use rustc_span:: hygiene:: LocalExpnId ;
1010use rustc_span:: symbol:: { kw, sym, Symbol } ;
1111use rustc_span:: Span ;
12- use tracing:: { debug, instrument } ;
12+ use tracing:: debug;
1313
14- use crate :: { ImplTraitContext , PendingAnonConstInfo , Resolver } ;
14+ use crate :: { ImplTraitContext , InvocationParent , PendingAnonConstInfo , Resolver } ;
1515
1616pub ( crate ) fn collect_definitions (
1717 resolver : & mut Resolver < ' _ , ' _ > ,
1818 fragment : & AstFragment ,
1919 expansion : LocalExpnId ,
2020) {
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 } =
2222 resolver. invocation_parents [ & expansion] ;
2323 let mut visitor = DefCollector {
2424 resolver,
@@ -50,17 +50,6 @@ impl<'a, 'b, 'tcx> DefCollector<'a, 'b, 'tcx> {
5050 span : Span ,
5151 ) -> LocalDefId {
5252 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 {
6453 debug ! (
6554 "create_def(node_id={:?}, def_kind={:?}, parent_def={:?})" ,
6655 node_id, def_kind, parent_def
@@ -133,7 +122,12 @@ impl<'a, 'b, 'tcx> DefCollector<'a, 'b, 'tcx> {
133122 let pending_anon_const_info = self . pending_anon_const_info . take ( ) ;
134123 let old_parent = self . resolver . invocation_parents . insert (
135124 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+ } ,
137131 ) ;
138132 assert ! ( old_parent. is_none( ) , "parent `LocalDefId` is reset for an invocation" ) ;
139133 }
@@ -334,7 +328,6 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
334328 }
335329 }
336330
337- #[ instrument( level = "debug" , skip( self ) ) ]
338331 fn visit_anon_const ( & mut self , constant : & ' a AnonConst ) {
339332 // HACK(min_generic_const_args): don't create defs for anon consts if we think they will
340333 // 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> {
343336 // items will be messed up, but that's ok because there can't be any if we're just looking
344337 // for bare idents.
345338 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 } ) ;
352341 visit:: walk_anon_const ( self , constant)
353342 } else if constant. value . is_potential_trivial_const_arg ( ) {
354- debug ! ( "ATTN(strict): unwrapped const is potentially trivial" ) ;
355343 visit:: walk_anon_const ( self , constant)
356344 } else {
357- debug ! ( "ATTN(strict): unwrapped const is not trivial" ) ;
358345 let def =
359346 self . create_def ( constant. id , kw:: Empty , DefKind :: AnonConst , constant. value . span ) ;
360347 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> {
367354 }
368355
369356 let grandparent_def = if let Some ( pending_anon) = self . pending_anon_const_info {
370- debug ! ( "ATTN(lazy): pending anon={pending_anon:?} expr={expr:?}" ) ;
371357 self . pending_anon_const_info = None ;
372358 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 )
381360 } else {
382- debug ! ( "ATTN(lazy): pending anon is potentially trivial" ) ;
383361 self . parent_def
384362 }
385363 } else {
0 commit comments