Skip to content

Commit 28af533

Browse files
committed
lowering: move scope & capture_clause stuff -> expr.rs
1 parent 5ab7345 commit 28af533

File tree

2 files changed

+66
-66
lines changed

2 files changed

+66
-66
lines changed

src/librustc/hir/lowering.rs

-65
Original file line numberDiff line numberDiff line change
@@ -971,64 +971,6 @@ impl<'a> LoweringContext<'a> {
971971
(lowered_generics, res)
972972
}
973973

974-
fn with_catch_scope<T, F>(&mut self, catch_id: NodeId, f: F) -> T
975-
where
976-
F: FnOnce(&mut LoweringContext<'_>) -> T,
977-
{
978-
let len = self.catch_scopes.len();
979-
self.catch_scopes.push(catch_id);
980-
981-
let result = f(self);
982-
assert_eq!(
983-
len + 1,
984-
self.catch_scopes.len(),
985-
"catch scopes should be added and removed in stack order"
986-
);
987-
988-
self.catch_scopes.pop().unwrap();
989-
990-
result
991-
}
992-
993-
fn with_loop_scope<T, F>(&mut self, loop_id: NodeId, f: F) -> T
994-
where
995-
F: FnOnce(&mut LoweringContext<'_>) -> T,
996-
{
997-
// We're no longer in the base loop's condition; we're in another loop.
998-
let was_in_loop_condition = self.is_in_loop_condition;
999-
self.is_in_loop_condition = false;
1000-
1001-
let len = self.loop_scopes.len();
1002-
self.loop_scopes.push(loop_id);
1003-
1004-
let result = f(self);
1005-
assert_eq!(
1006-
len + 1,
1007-
self.loop_scopes.len(),
1008-
"loop scopes should be added and removed in stack order"
1009-
);
1010-
1011-
self.loop_scopes.pop().unwrap();
1012-
1013-
self.is_in_loop_condition = was_in_loop_condition;
1014-
1015-
result
1016-
}
1017-
1018-
fn with_loop_condition_scope<T, F>(&mut self, f: F) -> T
1019-
where
1020-
F: FnOnce(&mut LoweringContext<'_>) -> T,
1021-
{
1022-
let was_in_loop_condition = self.is_in_loop_condition;
1023-
self.is_in_loop_condition = true;
1024-
1025-
let result = f(self);
1026-
1027-
self.is_in_loop_condition = was_in_loop_condition;
1028-
1029-
result
1030-
}
1031-
1032974
fn with_dyn_type_scope<T, F>(&mut self, in_scope: bool, f: F) -> T
1033975
where
1034976
F: FnOnce(&mut LoweringContext<'_>) -> T,
@@ -3005,13 +2947,6 @@ impl<'a> LoweringContext<'a> {
30052947
}]
30062948
}
30072949

3008-
fn lower_capture_clause(&mut self, c: CaptureBy) -> hir::CaptureClause {
3009-
match c {
3010-
CaptureBy::Value => hir::CaptureByValue,
3011-
CaptureBy::Ref => hir::CaptureByRef,
3012-
}
3013-
}
3014-
30152950
fn lower_block_check_mode(&mut self, b: &BlockCheckMode) -> hir::BlockCheckMode {
30162951
match *b {
30172952
BlockCheckMode::Default => hir::DefaultBlock,

src/librustc/hir/lowering/expr.rs

+66-1
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,16 @@ impl LoweringContext<'_> {
700700
})
701701
}
702702

703+
fn lower_capture_clause(&mut self, c: CaptureBy) -> hir::CaptureClause {
704+
match c {
705+
CaptureBy::Value => hir::CaptureByValue,
706+
CaptureBy::Ref => hir::CaptureByRef,
707+
}
708+
}
709+
703710
fn generator_movability_for_fn(
704711
&mut self,
705-
decl: &ast::FnDecl,
712+
decl: &FnDecl,
706713
fn_decl_span: Span,
707714
generator_kind: Option<hir::GeneratorKind>,
708715
movability: Movability,
@@ -898,6 +905,64 @@ impl LoweringContext<'_> {
898905
}
899906
}
900907

908+
fn with_catch_scope<T, F>(&mut self, catch_id: NodeId, f: F) -> T
909+
where
910+
F: FnOnce(&mut LoweringContext<'_>) -> T,
911+
{
912+
let len = self.catch_scopes.len();
913+
self.catch_scopes.push(catch_id);
914+
915+
let result = f(self);
916+
assert_eq!(
917+
len + 1,
918+
self.catch_scopes.len(),
919+
"catch scopes should be added and removed in stack order"
920+
);
921+
922+
self.catch_scopes.pop().unwrap();
923+
924+
result
925+
}
926+
927+
fn with_loop_scope<T, F>(&mut self, loop_id: NodeId, f: F) -> T
928+
where
929+
F: FnOnce(&mut LoweringContext<'_>) -> T,
930+
{
931+
// We're no longer in the base loop's condition; we're in another loop.
932+
let was_in_loop_condition = self.is_in_loop_condition;
933+
self.is_in_loop_condition = false;
934+
935+
let len = self.loop_scopes.len();
936+
self.loop_scopes.push(loop_id);
937+
938+
let result = f(self);
939+
assert_eq!(
940+
len + 1,
941+
self.loop_scopes.len(),
942+
"loop scopes should be added and removed in stack order"
943+
);
944+
945+
self.loop_scopes.pop().unwrap();
946+
947+
self.is_in_loop_condition = was_in_loop_condition;
948+
949+
result
950+
}
951+
952+
fn with_loop_condition_scope<T, F>(&mut self, f: F) -> T
953+
where
954+
F: FnOnce(&mut LoweringContext<'_>) -> T,
955+
{
956+
let was_in_loop_condition = self.is_in_loop_condition;
957+
self.is_in_loop_condition = true;
958+
959+
let result = f(self);
960+
961+
self.is_in_loop_condition = was_in_loop_condition;
962+
963+
result
964+
}
965+
901966
fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind {
902967
let hir_asm = hir::InlineAsm {
903968
inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),

0 commit comments

Comments
 (0)