@@ -23,8 +23,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
23
23
safety_mode
24
24
} =
25
25
self . hir . mirror ( ast_block) ;
26
- self . in_opt_scope ( opt_destruction_scope. map ( |de|( de, source_info) ) , block , move |this| {
27
- this. in_scope ( ( region_scope, source_info) , LintLevel :: Inherited , block , move |this| {
26
+ self . in_opt_scope ( opt_destruction_scope. map ( |de|( de, source_info) ) , move |this| {
27
+ this. in_scope ( ( region_scope, source_info) , LintLevel :: Inherited , move |this| {
28
28
if targeted_by_break {
29
29
// This is a `break`-able block
30
30
let exit_block = this. cfg . start_new_block ( ) ;
@@ -83,9 +83,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
83
83
StmtKind :: Expr { scope, expr } => {
84
84
this. block_context . push ( BlockFrame :: Statement { ignores_expr_result : true } ) ;
85
85
unpack ! ( block = this. in_opt_scope(
86
- opt_destruction_scope. map( |de|( de, source_info) ) , block , |this| {
86
+ opt_destruction_scope. map( |de|( de, source_info) ) , |this| {
87
87
let si = ( scope, source_info) ;
88
- this. in_scope( si, LintLevel :: Inherited , block , |this| {
88
+ this. in_scope( si, LintLevel :: Inherited , |this| {
89
89
let expr = this. hir. mirror( expr) ;
90
90
this. stmt_expr( block, expr, Some ( stmt_span) )
91
91
} )
@@ -113,31 +113,39 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
113
113
let remainder_span = remainder_scope. span ( this. hir . tcx ( ) ,
114
114
& this. hir . region_scope_tree ) ;
115
115
116
- let scope;
116
+ let visibility_scope =
117
+ Some ( this. new_source_scope ( remainder_span, LintLevel :: Inherited , None ) ) ;
117
118
118
119
// Evaluate the initializer, if present.
119
120
if let Some ( init) = initializer {
120
121
let initializer_span = init. span ( ) ;
121
122
122
- scope = this. declare_bindings (
123
- None ,
124
- remainder_span,
125
- lint_level,
126
- & pattern,
127
- ArmHasGuard ( false ) ,
128
- Some ( ( None , initializer_span) ) ,
129
- ) ;
130
123
unpack ! ( block = this. in_opt_scope(
131
- opt_destruction_scope. map( |de|( de, source_info) ) , block , |this| {
124
+ opt_destruction_scope. map( |de|( de, source_info) ) , |this| {
132
125
let scope = ( init_scope, source_info) ;
133
- this. in_scope( scope, lint_level, block, |this| {
126
+ this. in_scope( scope, lint_level, |this| {
127
+ this. declare_bindings(
128
+ visibility_scope,
129
+ remainder_span,
130
+ & pattern,
131
+ ArmHasGuard ( false ) ,
132
+ Some ( ( None , initializer_span) ) ,
133
+ ) ;
134
134
this. expr_into_pattern( block, pattern, init)
135
135
} )
136
136
} ) ) ;
137
137
} else {
138
- scope = this. declare_bindings (
139
- None , remainder_span, lint_level, & pattern,
140
- ArmHasGuard ( false ) , None ) ;
138
+ let scope = ( init_scope, source_info) ;
139
+ unpack ! ( this. in_scope( scope, lint_level, |this| {
140
+ this. declare_bindings(
141
+ visibility_scope,
142
+ remainder_span,
143
+ & pattern,
144
+ ArmHasGuard ( false ) ,
145
+ None ,
146
+ ) ;
147
+ block. unit( )
148
+ } ) ) ;
141
149
142
150
debug ! ( "ast_block_stmts: pattern={:?}" , pattern) ;
143
151
this. visit_bindings (
@@ -149,8 +157,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
149
157
} )
150
158
}
151
159
152
- // Enter the source scope, after evaluating the initializer.
153
- if let Some ( source_scope) = scope {
160
+ // Enter the visibility scope, after evaluating the initializer.
161
+ if let Some ( source_scope) = visibility_scope {
154
162
this. source_scope = source_scope;
155
163
}
156
164
}
0 commit comments