@@ -23,8 +23,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
2323 safety_mode
2424 } =
2525 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| {
2828 if targeted_by_break {
2929 // This is a `break`-able block
3030 let exit_block = this. cfg . start_new_block ( ) ;
@@ -83,9 +83,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
8383 StmtKind :: Expr { scope, expr } => {
8484 this. block_context . push ( BlockFrame :: Statement { ignores_expr_result : true } ) ;
8585 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| {
8787 let si = ( scope, source_info) ;
88- this. in_scope( si, LintLevel :: Inherited , block , |this| {
88+ this. in_scope( si, LintLevel :: Inherited , |this| {
8989 let expr = this. hir. mirror( expr) ;
9090 this. stmt_expr( block, expr, Some ( stmt_span) )
9191 } )
@@ -113,31 +113,39 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
113113 let remainder_span = remainder_scope. span ( this. hir . tcx ( ) ,
114114 & this. hir . region_scope_tree ) ;
115115
116- let scope;
116+ let visibility_scope =
117+ Some ( this. new_source_scope ( remainder_span, LintLevel :: Inherited , None ) ) ;
117118
118119 // Evaluate the initializer, if present.
119120 if let Some ( init) = initializer {
120121 let initializer_span = init. span ( ) ;
121122
122- scope = this. declare_bindings (
123- None ,
124- remainder_span,
125- lint_level,
126- & pattern,
127- ArmHasGuard ( false ) ,
128- Some ( ( None , initializer_span) ) ,
129- ) ;
130123 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| {
132125 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+ ) ;
134134 this. expr_into_pattern( block, pattern, init)
135135 } )
136136 } ) ) ;
137137 } 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+ } ) ) ;
141149
142150 debug ! ( "ast_block_stmts: pattern={:?}" , pattern) ;
143151 this. visit_bindings (
@@ -149,8 +157,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
149157 } )
150158 }
151159
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 {
154162 this. source_scope = source_scope;
155163 }
156164 }
0 commit comments