Skip to content

Commit 3baa466

Browse files
committed
Auto merge of #88626 - cjgillot:lfitb, r=petrochenkov
Simplify lifetimes_from_impl_trait_bounds Part of #87234 r? `@petrochenkov`
2 parents 5d2a410 + fed4410 commit 3baa466

File tree

2 files changed

+195
-235
lines changed

2 files changed

+195
-235
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+6-26
Original file line numberDiff line numberDiff line change
@@ -1186,9 +1186,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11861186
}
11871187
}
11881188
None => self
1189-
.loop_scopes
1190-
.last()
1191-
.cloned()
1189+
.loop_scope
11921190
.map(|id| Ok(self.lower_node_id(id)))
11931191
.unwrap_or(Err(hir::LoopIdError::OutsideLoopScope)),
11941192
};
@@ -1208,18 +1206,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
12081206
}
12091207

12101208
fn with_catch_scope<T>(&mut self, catch_id: NodeId, f: impl FnOnce(&mut Self) -> T) -> T {
1211-
let len = self.catch_scopes.len();
1212-
self.catch_scopes.push(catch_id);
1213-
1209+
let old_scope = self.catch_scope.replace(catch_id);
12141210
let result = f(self);
1215-
assert_eq!(
1216-
len + 1,
1217-
self.catch_scopes.len(),
1218-
"catch scopes should be added and removed in stack order"
1219-
);
1220-
1221-
self.catch_scopes.pop().unwrap();
1222-
1211+
self.catch_scope = old_scope;
12231212
result
12241213
}
12251214

@@ -1228,17 +1217,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
12281217
let was_in_loop_condition = self.is_in_loop_condition;
12291218
self.is_in_loop_condition = false;
12301219

1231-
let len = self.loop_scopes.len();
1232-
self.loop_scopes.push(loop_id);
1233-
1220+
let old_scope = self.loop_scope.replace(loop_id);
12341221
let result = f(self);
1235-
assert_eq!(
1236-
len + 1,
1237-
self.loop_scopes.len(),
1238-
"loop scopes should be added and removed in stack order"
1239-
);
1240-
1241-
self.loop_scopes.pop().unwrap();
1222+
self.loop_scope = old_scope;
12421223

12431224
self.is_in_loop_condition = was_in_loop_condition;
12441225

@@ -1565,8 +1546,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15651546
unstable_span,
15661547
);
15671548
let thin_attrs = ThinVec::from(attrs);
1568-
let catch_scope = self.catch_scopes.last().copied();
1569-
let ret_expr = if let Some(catch_node) = catch_scope {
1549+
let ret_expr = if let Some(catch_node) = self.catch_scope {
15701550
let target_id = Ok(self.lower_node_id(catch_node));
15711551
self.arena.alloc(self.expr(
15721552
try_span,

0 commit comments

Comments
 (0)