@@ -64,7 +64,7 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol};
64
64
use rustc_span:: { Span , DUMMY_SP } ;
65
65
use rustc_target:: spec:: abi:: Abi ;
66
66
67
- use smallvec:: { smallvec , SmallVec } ;
67
+ use smallvec:: SmallVec ;
68
68
use std:: collections:: BTreeMap ;
69
69
use std:: mem;
70
70
use tracing:: { debug, trace} ;
@@ -77,6 +77,7 @@ macro_rules! arena_vec {
77
77
}
78
78
79
79
mod asm;
80
+ mod block;
80
81
mod expr;
81
82
mod item;
82
83
mod pat;
@@ -1793,24 +1794,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1793
1794
)
1794
1795
}
1795
1796
1796
- fn lower_local ( & mut self , l : & Local ) -> hir:: Local < ' hir > {
1797
- let ty = l
1798
- . ty
1799
- . as_ref ( )
1800
- . map ( |t| self . lower_ty ( t, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Binding ) ) ) ;
1801
- let init = l. kind . init ( ) . map ( |init| self . lower_expr ( init) ) ;
1802
- let hir_id = self . lower_node_id ( l. id ) ;
1803
- self . lower_attrs ( hir_id, & l. attrs ) ;
1804
- hir:: Local {
1805
- hir_id,
1806
- ty,
1807
- pat : self . lower_pat ( & l. pat ) ,
1808
- init,
1809
- span : self . lower_span ( l. span ) ,
1810
- source : hir:: LocalSource :: Normal ,
1811
- }
1812
- }
1813
-
1814
1797
fn lower_fn_params_to_names ( & mut self , decl : & FnDecl ) -> & ' hir [ Ident ] {
1815
1798
// Skip the `...` (`CVarArgs`) trailing arguments from the AST,
1816
1799
// as they are not explicit in HIR/Ty function signatures.
@@ -2396,23 +2379,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2396
2379
bounds. iter ( ) . map ( move |bound| self . lower_param_bound ( bound, itctx. reborrow ( ) ) )
2397
2380
}
2398
2381
2399
- fn lower_block ( & mut self , b : & Block , targeted_by_break : bool ) -> & ' hir hir:: Block < ' hir > {
2400
- self . arena . alloc ( self . lower_block_noalloc ( b, targeted_by_break) )
2401
- }
2402
-
2403
- fn lower_block_noalloc ( & mut self , b : & Block , targeted_by_break : bool ) -> hir:: Block < ' hir > {
2404
- let ( stmts, expr) = match & * b. stmts {
2405
- [ stmts @ .., Stmt { kind : StmtKind :: Expr ( e) , .. } ] => ( stmts, Some ( & * e) ) ,
2406
- stmts => ( stmts, None ) ,
2407
- } ;
2408
- let stmts = self . arena . alloc_from_iter ( stmts. iter ( ) . flat_map ( |stmt| self . lower_stmt ( stmt) ) ) ;
2409
- let expr = expr. map ( |e| self . lower_expr ( e) ) ;
2410
- let rules = self . lower_block_check_mode ( & b. rules ) ;
2411
- let hir_id = self . lower_node_id ( b. id ) ;
2412
-
2413
- hir:: Block { hir_id, stmts, expr, rules, span : self . lower_span ( b. span ) , targeted_by_break }
2414
- }
2415
-
2416
2382
/// Lowers a block directly to an expression, presuming that it
2417
2383
/// has no attributes and is not targeted by a `break`.
2418
2384
fn lower_block_expr ( & mut self , b : & Block ) -> hir:: Expr < ' hir > {
@@ -2427,65 +2393,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2427
2393
} )
2428
2394
}
2429
2395
2430
- fn lower_stmt ( & mut self , s : & Stmt ) -> SmallVec < [ hir:: Stmt < ' hir > ; 1 ] > {
2431
- let ( hir_id, kind) = match s. kind {
2432
- StmtKind :: Local ( ref l) => {
2433
- let l = self . lower_local ( l) ;
2434
- let hir_id = self . lower_node_id ( s. id ) ;
2435
- self . alias_attrs ( hir_id, l. hir_id ) ;
2436
- return smallvec ! [ hir:: Stmt {
2437
- hir_id,
2438
- kind: hir:: StmtKind :: Local ( self . arena. alloc( l) ) ,
2439
- span: self . lower_span( s. span) ,
2440
- } ] ;
2441
- }
2442
- StmtKind :: Item ( ref it) => {
2443
- // Can only use the ID once.
2444
- let mut id = Some ( s. id ) ;
2445
- return self
2446
- . lower_item_id ( it)
2447
- . into_iter ( )
2448
- . map ( |item_id| {
2449
- let hir_id = id
2450
- . take ( )
2451
- . map ( |id| self . lower_node_id ( id) )
2452
- . unwrap_or_else ( || self . next_id ( ) ) ;
2453
-
2454
- hir:: Stmt {
2455
- hir_id,
2456
- kind : hir:: StmtKind :: Item ( item_id) ,
2457
- span : self . lower_span ( s. span ) ,
2458
- }
2459
- } )
2460
- . collect ( ) ;
2461
- }
2462
- StmtKind :: Expr ( ref e) => {
2463
- let e = self . lower_expr ( e) ;
2464
- let hir_id = self . lower_node_id ( s. id ) ;
2465
- self . alias_attrs ( hir_id, e. hir_id ) ;
2466
- ( hir_id, hir:: StmtKind :: Expr ( e) )
2467
- }
2468
- StmtKind :: Semi ( ref e) => {
2469
- let e = self . lower_expr ( e) ;
2470
- let hir_id = self . lower_node_id ( s. id ) ;
2471
- self . alias_attrs ( hir_id, e. hir_id ) ;
2472
- ( hir_id, hir:: StmtKind :: Semi ( e) )
2473
- }
2474
- StmtKind :: Empty => return smallvec ! [ ] ,
2475
- StmtKind :: MacCall ( ..) => panic ! ( "shouldn't exist here" ) ,
2476
- } ;
2477
- smallvec ! [ hir:: Stmt { hir_id, kind, span: self . lower_span( s. span) } ]
2478
- }
2479
-
2480
- fn lower_block_check_mode ( & mut self , b : & BlockCheckMode ) -> hir:: BlockCheckMode {
2481
- match * b {
2482
- BlockCheckMode :: Default => hir:: BlockCheckMode :: DefaultBlock ,
2483
- BlockCheckMode :: Unsafe ( u) => {
2484
- hir:: BlockCheckMode :: UnsafeBlock ( self . lower_unsafe_source ( u) )
2485
- }
2486
- }
2487
- }
2488
-
2489
2396
fn lower_unsafe_source ( & mut self , u : UnsafeSource ) -> hir:: UnsafeSource {
2490
2397
match u {
2491
2398
CompilerGenerated => hir:: UnsafeSource :: CompilerGenerated ,
0 commit comments