Auto merge of #117673 - matthewjasper:thir-unsafeck-stabilization, r=… · rust-lang/rust@9ee6473 (original) (raw)
`@@ -20,7 +20,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
`
20
20
`ref stmts,
`
21
21
` expr,
`
22
22
` targeted_by_break,
`
23
``
`-
safety_mode,
`
``
23
`+
safety_mode: _,
`
24
24
`} = self.thir[ast_block];
`
25
25
`let expr = expr.map(|expr| &self.thir[expr]);
`
26
26
`self.in_opt_scope(opt_destruction_scope.map(|de| (de, source_info)), move |this| {
`
`@@ -33,20 +33,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
`
33
33
` span,
`
34
34
`&stmts,
`
35
35
` expr,
`
36
``
`-
safety_mode,
`
37
36
` region_scope,
`
38
37
`))
`
39
38
`})
`
40
39
`} else {
`
41
``
`-
this.ast_block_stmts(
`
42
``
`-
destination,
`
43
``
`-
block,
`
44
``
`-
span,
`
45
``
`-
&stmts,
`
46
``
`-
expr,
`
47
``
`-
safety_mode,
`
48
``
`-
region_scope,
`
49
``
`-
)
`
``
40
`+
this.ast_block_stmts(destination, block, span, &stmts, expr, region_scope)
`
50
41
`}
`
51
42
`})
`
52
43
`})
`
`@@ -59,7 +50,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
`
59
50
`span: Span,
`
60
51
`stmts: &[StmtId],
`
61
52
`expr: Option<&Expr<'tcx>>,
`
62
``
`-
safety_mode: BlockSafety,
`
63
53
`region_scope: Scope,
`
64
54
`) -> BlockAnd<()> {
`
65
55
`let this = self;
`
`@@ -82,13 +72,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
`
82
72
`// First we build all the statements in the block.
`
83
73
`let mut let_scope_stack = Vec::with_capacity(8);
`
84
74
`let outer_source_scope = this.source_scope;
`
85
``
`-
let outer_in_scope_unsafe = this.in_scope_unsafe;
`
86
75
`// This scope information is kept for breaking out of the parent remainder scope in case
`
87
76
`// one let-else pattern matching fails.
`
88
77
`// By doing so, we can be sure that even temporaries that receive extended lifetime
`
89
78
`// assignments are dropped, too.
`
90
79
`let mut last_remainder_scope = region_scope;
`
91
``
`-
this.update_source_scope_for_safety_mode(span, safety_mode);
`
92
80
``
93
81
`let source_info = this.source_info(span);
`
94
82
`for stmt in stmts {
`
`@@ -217,7 +205,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
`
217
205
` let_scope_stack.push(remainder_scope);
`
218
206
``
219
207
`let visibility_scope =
`
220
``
`-
Some(this.new_source_scope(remainder_span, LintLevel::Inherited, None));
`
``
208
`+
Some(this.new_source_scope(remainder_span, LintLevel::Inherited));
`
221
209
``
222
210
`let init = &this.thir[*initializer];
`
223
211
`let initializer_span = init.span;
`
`@@ -292,7 +280,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
`
292
280
`let remainder_span = remainder_scope.span(this.tcx, this.region_scope_tree);
`
293
281
``
294
282
`let visibility_scope =
`
295
``
`-
Some(this.new_source_scope(remainder_span, LintLevel::Inherited, None));
`
``
283
`+
Some(this.new_source_scope(remainder_span, LintLevel::Inherited));
`
296
284
``
297
285
`// Evaluate the initializer, if present.
`
298
286
`if let Some(init) = initializer {
`
`@@ -390,22 +378,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
`
390
378
`}
`
391
379
`// Restore the original source scope.
`
392
380
` this.source_scope = outer_source_scope;
`
393
``
`-
this.in_scope_unsafe = outer_in_scope_unsafe;
`
394
381
` block.unit()
`
395
382
`}
`
396
``
-
397
``
`-
/// If we are entering an unsafe block, create a new source scope
`
398
``
`-
fn update_source_scope_for_safety_mode(&mut self, span: Span, safety_mode: BlockSafety) {
`
399
``
`-
debug!("update_source_scope_for({:?}, {:?})", span, safety_mode);
`
400
``
`-
let new_unsafety = match safety_mode {
`
401
``
`-
BlockSafety::Safe => return,
`
402
``
`-
BlockSafety::BuiltinUnsafe => Safety::BuiltinUnsafe,
`
403
``
`-
BlockSafety::ExplicitUnsafe(hir_id) => {
`
404
``
`-
self.in_scope_unsafe = Safety::ExplicitUnsafe(hir_id);
`
405
``
`-
Safety::ExplicitUnsafe(hir_id)
`
406
``
`-
}
`
407
``
`-
};
`
408
``
-
409
``
`-
self.source_scope = self.new_source_scope(span, LintLevel::Inherited, Some(new_unsafety));
`
410
``
`-
}
`
411
383
`}
`