@@ -40,7 +40,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
40
40
expr : & Expr < ' tcx > ,
41
41
temp_scope_override : Option < region:: Scope > ,
42
42
break_scope : region:: Scope ,
43
- variable_scope_span : Span ,
43
+ variable_source_info : SourceInfo ,
44
44
) -> BlockAnd < ( ) > {
45
45
let this = self ;
46
46
let expr_span = expr. span ;
@@ -52,15 +52,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
52
52
& this. thir[ lhs] ,
53
53
temp_scope_override,
54
54
break_scope,
55
- variable_scope_span ,
55
+ variable_source_info ,
56
56
) ) ;
57
57
58
58
let rhs_then_block = unpack ! ( this. then_else_break(
59
59
lhs_then_block,
60
60
& this. thir[ rhs] ,
61
61
temp_scope_override,
62
62
break_scope,
63
- variable_scope_span ,
63
+ variable_source_info ,
64
64
) ) ;
65
65
66
66
rhs_then_block. unit ( )
@@ -73,13 +73,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
73
73
& this. thir [ value] ,
74
74
temp_scope_override,
75
75
break_scope,
76
- variable_scope_span ,
76
+ variable_source_info ,
77
77
)
78
78
} )
79
79
}
80
- ExprKind :: Let { expr, ref pat } => {
81
- this. lower_let_expr ( block, & this. thir [ expr] , pat, break_scope, variable_scope_span)
82
- }
80
+ ExprKind :: Let { expr, ref pat } => this. lower_let_expr (
81
+ block,
82
+ & this. thir [ expr] ,
83
+ pat,
84
+ break_scope,
85
+ Some ( variable_source_info. scope ) ,
86
+ variable_source_info. span ,
87
+ ) ,
83
88
_ => {
84
89
let temp_scope = temp_scope_override. unwrap_or_else ( || this. local_scope ( ) ) ;
85
90
let mutability = Mutability :: Mut ;
@@ -1772,6 +1777,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1772
1777
expr : & Expr < ' tcx > ,
1773
1778
pat : & Pat < ' tcx > ,
1774
1779
else_target : region:: Scope ,
1780
+ source_scope : Option < SourceScope > ,
1775
1781
span : Span ,
1776
1782
) -> BlockAnd < ( ) > {
1777
1783
let expr_span = expr. span ;
@@ -1797,7 +1803,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1797
1803
let otherwise_post_guard_block = otherwise_candidate. pre_binding_block . unwrap ( ) ;
1798
1804
self . break_for_else ( otherwise_post_guard_block, else_target, self . source_info ( expr_span) ) ;
1799
1805
1800
- self . declare_bindings ( None , pat. span . to ( span) , pat, ArmHasGuard ( false ) , opt_expr_place) ;
1806
+ self . declare_bindings (
1807
+ source_scope,
1808
+ pat. span . to ( span) ,
1809
+ pat,
1810
+ ArmHasGuard ( false ) ,
1811
+ opt_expr_place,
1812
+ ) ;
1813
+
1801
1814
let post_guard_block = self . bind_pattern (
1802
1815
self . source_info ( pat. span ) ,
1803
1816
guard_candidate,
@@ -1969,12 +1982,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1969
1982
Guard :: If ( e) => {
1970
1983
let e = & this. thir [ e] ;
1971
1984
guard_span = e. span ;
1972
- this. then_else_break ( block, e, None , match_scope, arm_span)
1985
+ this. then_else_break (
1986
+ block,
1987
+ e,
1988
+ None ,
1989
+ match_scope,
1990
+ this. source_info ( arm_span) ,
1991
+ )
1973
1992
}
1974
1993
Guard :: IfLet ( ref pat, scrutinee) => {
1975
1994
let s = & this. thir [ scrutinee] ;
1976
1995
guard_span = s. span ;
1977
- this. lower_let_expr ( block, s, pat, match_scope, arm_span)
1996
+ this. lower_let_expr ( block, s, pat, match_scope, None , arm_span)
1978
1997
}
1979
1998
} ) ;
1980
1999
0 commit comments