@@ -438,31 +438,6 @@ impl<'a> TokenStreamLowering<'a> {
438
438
}
439
439
}
440
440
441
- struct ImplTraitTypeIdVisitor < ' a > {
442
- ids : & ' a mut SmallVec < [ NodeId ; 1 ] > ,
443
- }
444
-
445
- impl Visitor < ' _ > for ImplTraitTypeIdVisitor < ' _ > {
446
- fn visit_ty ( & mut self , ty : & Ty ) {
447
- match ty. kind {
448
- TyKind :: Typeof ( _) | TyKind :: BareFn ( _) => return ,
449
-
450
- TyKind :: ImplTrait ( id, _) => self . ids . push ( id) ,
451
- _ => { }
452
- }
453
- visit:: walk_ty ( self , ty) ;
454
- }
455
-
456
- fn visit_path_segment ( & mut self , path_span : Span , path_segment : & PathSegment ) {
457
- if let Some ( ref p) = path_segment. args {
458
- if let GenericArgs :: Parenthesized ( _) = * * p {
459
- return ;
460
- }
461
- }
462
- visit:: walk_path_segment ( self , path_span, path_segment)
463
- }
464
- }
465
-
466
441
impl < ' a , ' hir > LoweringContext < ' a , ' hir > {
467
442
fn lower_crate ( mut self , c : & Crate ) -> hir:: Crate < ' hir > {
468
443
/// Full-crate AST visitor that inserts into a fresh
@@ -1789,14 +1764,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1789
1764
)
1790
1765
}
1791
1766
1792
- fn lower_local ( & mut self , l : & Local ) -> ( hir:: Local < ' hir > , SmallVec < [ NodeId ; 1 ] > ) {
1793
- let mut ids = SmallVec :: < [ NodeId ; 1 ] > :: new ( ) ;
1794
- if self . sess . features_untracked ( ) . impl_trait_in_bindings {
1795
- if let Some ( ref ty) = l. ty {
1796
- let mut visitor = ImplTraitTypeIdVisitor { ids : & mut ids } ;
1797
- visitor. visit_ty ( ty) ;
1798
- }
1799
- }
1767
+ fn lower_local ( & mut self , l : & Local ) -> hir:: Local < ' hir > {
1800
1768
let ty = l. ty . as_ref ( ) . map ( |t| {
1801
1769
let mut capturable_lifetimes;
1802
1770
self . lower_ty (
@@ -1815,17 +1783,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1815
1783
let init = l. init . as_ref ( ) . map ( |e| self . lower_expr ( e) ) ;
1816
1784
let hir_id = self . lower_node_id ( l. id ) ;
1817
1785
self . lower_attrs ( hir_id, & l. attrs ) ;
1818
- (
1819
- hir:: Local {
1820
- hir_id,
1821
- ty,
1822
- pat : self . lower_pat ( & l. pat ) ,
1823
- init,
1824
- span : l. span ,
1825
- source : hir:: LocalSource :: Normal ,
1826
- } ,
1827
- ids,
1828
- )
1786
+ hir:: Local {
1787
+ hir_id,
1788
+ ty,
1789
+ pat : self . lower_pat ( & l. pat ) ,
1790
+ init,
1791
+ span : l. span ,
1792
+ source : hir:: LocalSource :: Normal ,
1793
+ }
1829
1794
}
1830
1795
1831
1796
fn lower_fn_params_to_names ( & mut self , decl : & FnDecl ) -> & ' hir [ Ident ] {
@@ -2445,27 +2410,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2445
2410
fn lower_stmt ( & mut self , s : & Stmt ) -> SmallVec < [ hir:: Stmt < ' hir > ; 1 ] > {
2446
2411
let ( hir_id, kind) = match s. kind {
2447
2412
StmtKind :: Local ( ref l) => {
2448
- let ( l, item_ids) = self . lower_local ( l) ;
2449
- let mut ids: SmallVec < [ hir:: Stmt < ' hir > ; 1 ] > = item_ids
2450
- . into_iter ( )
2451
- . map ( |item_id| {
2452
- let item_id = hir:: ItemId {
2453
- // All the items that `lower_local` finds are `impl Trait` types.
2454
- def_id : self . lower_node_id ( item_id) . expect_owner ( ) ,
2455
- } ;
2456
- self . stmt ( s. span , hir:: StmtKind :: Item ( item_id) )
2457
- } )
2458
- . collect ( ) ;
2413
+ let l = self . lower_local ( l) ;
2459
2414
let hir_id = self . lower_node_id ( s. id ) ;
2460
2415
self . alias_attrs ( hir_id, l. hir_id ) ;
2461
- ids. push ( {
2462
- hir:: Stmt {
2463
- hir_id,
2464
- kind : hir:: StmtKind :: Local ( self . arena . alloc ( l) ) ,
2465
- span : s. span ,
2466
- }
2467
- } ) ;
2468
- return ids;
2416
+ return smallvec ! [ hir:: Stmt {
2417
+ hir_id,
2418
+ kind: hir:: StmtKind :: Local ( self . arena. alloc( l) ) ,
2419
+ span: s. span,
2420
+ } ] ;
2469
2421
}
2470
2422
StmtKind :: Item ( ref it) => {
2471
2423
// Can only use the ID once.
0 commit comments