@@ -41,7 +41,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
41
41
expr : & Expr < ' tcx > ,
42
42
temp_scope_override : Option < region:: Scope > ,
43
43
break_scope : region:: Scope ,
44
- variable_scope_span : Span ,
44
+ variable_span : Span ,
45
45
) -> BlockAnd < ( ) > {
46
46
let this = self ;
47
47
let expr_span = expr. span ;
@@ -53,15 +53,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
53
53
& this. thir[ lhs] ,
54
54
temp_scope_override,
55
55
break_scope,
56
- variable_scope_span ,
56
+ variable_span ,
57
57
) ) ;
58
58
59
59
let rhs_then_block = unpack ! ( this. then_else_break(
60
60
lhs_then_block,
61
61
& this. thir[ rhs] ,
62
62
temp_scope_override,
63
63
break_scope,
64
- variable_scope_span ,
64
+ variable_span ,
65
65
) ) ;
66
66
67
67
rhs_then_block. unit ( )
@@ -74,12 +74,22 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
74
74
& this. thir [ value] ,
75
75
temp_scope_override,
76
76
break_scope,
77
- variable_scope_span ,
77
+ variable_span ,
78
78
)
79
79
} )
80
80
}
81
81
ExprKind :: Let { expr, ref pat } => {
82
- this. lower_let_expr ( block, & this. thir [ expr] , pat, break_scope, variable_scope_span)
82
+ let variable_scope =
83
+ this. new_source_scope ( variable_span, LintLevel :: Inherited , None ) ;
84
+ this. source_scope = variable_scope;
85
+ this. lower_let_expr (
86
+ block,
87
+ & this. thir [ expr] ,
88
+ pat,
89
+ break_scope,
90
+ Some ( variable_scope) ,
91
+ variable_span,
92
+ )
83
93
}
84
94
_ => {
85
95
let temp_scope = temp_scope_override. unwrap_or_else ( || this. local_scope ( ) ) ;
@@ -1773,6 +1783,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1773
1783
expr : & Expr < ' tcx > ,
1774
1784
pat : & Pat < ' tcx > ,
1775
1785
else_target : region:: Scope ,
1786
+ source_scope : Option < SourceScope > ,
1776
1787
span : Span ,
1777
1788
) -> BlockAnd < ( ) > {
1778
1789
let expr_span = expr. span ;
@@ -1798,12 +1809,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1798
1809
let otherwise_post_guard_block = otherwise_candidate. pre_binding_block . unwrap ( ) ;
1799
1810
self . break_for_else ( otherwise_post_guard_block, else_target, self . source_info ( expr_span) ) ;
1800
1811
1801
- let scope =
1802
- self . declare_bindings ( None , pat. span . to ( span) , pat, ArmHasGuard ( false ) , opt_expr_place) ;
1803
-
1804
- if let Some ( scope) = scope {
1805
- self . source_scope = scope;
1806
- }
1812
+ self . declare_bindings (
1813
+ source_scope,
1814
+ pat. span . to ( span) ,
1815
+ pat,
1816
+ ArmHasGuard ( false ) ,
1817
+ opt_expr_place,
1818
+ ) ;
1807
1819
1808
1820
let post_guard_block = self . bind_pattern (
1809
1821
self . source_info ( pat. span ) ,
@@ -1981,7 +1993,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1981
1993
Guard :: IfLet ( ref pat, scrutinee) => {
1982
1994
let s = & this. thir [ scrutinee] ;
1983
1995
guard_span = s. span ;
1984
- this. lower_let_expr ( block, s, pat, match_scope, arm_span)
1996
+ this. lower_let_expr ( block, s, pat, match_scope, None , arm_span)
1985
1997
}
1986
1998
} ) ;
1987
1999
0 commit comments