@@ -450,25 +450,26 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
450
450
match * place {
451
451
Place :: Local ( ref local) => self . visit_local ( local, context, location) ,
452
452
Place :: Static ( ref global) => {
453
- // Only allow statics (not consts) to refer to other statics.
454
- if !( self . mode == Mode :: Static || self . mode == Mode :: StaticMut ) {
453
+ if self . tcx
454
+ . get_attrs ( global. def_id )
455
+ . iter ( )
456
+ . any ( |attr| attr. check_name ( "thread_local" ) ) {
457
+ if self . mode != Mode :: Fn {
458
+ span_err ! ( self . tcx. sess, self . span, E0625 ,
459
+ "thread-local statics cannot be \
460
+ accessed at compile-time") ;
461
+ }
455
462
self . add ( Qualif :: NOT_CONST ) ;
463
+ return ;
456
464
}
457
465
458
- if self . mode != Mode :: Fn {
459
- if self . tcx
460
- . get_attrs ( global. def_id )
461
- . iter ( )
462
- . any ( |attr| attr. check_name ( "thread_local" ) ) {
463
- span_err ! ( self . tcx. sess, self . span, E0625 ,
464
- "thread-local statics cannot be \
465
- accessed at compile-time") ;
466
- self . add ( Qualif :: NOT_CONST ) ;
467
- return ;
468
- }
466
+ // Only allow statics (not consts) to refer to other statics.
467
+ if self . mode == Mode :: Static || self . mode == Mode :: StaticMut {
468
+ return ;
469
469
}
470
+ self . add ( Qualif :: NOT_CONST ) ;
470
471
471
- if self . mode == Mode :: Const || self . mode == Mode :: ConstFn {
472
+ if self . mode != Mode :: Fn {
472
473
let mut err = struct_span_err ! ( self . tcx. sess, self . span, E0013 ,
473
474
"{}s cannot refer to statics, use \
474
475
a constant instead", self . mode) ;
@@ -544,13 +545,11 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
544
545
}
545
546
546
547
fn visit_operand ( & mut self , operand : & Operand < ' tcx > , location : Location ) {
548
+ self . super_operand ( operand, location) ;
549
+
547
550
match * operand {
548
551
Operand :: Copy ( _) |
549
552
Operand :: Move ( _) => {
550
- self . nest ( |this| {
551
- this. super_operand ( operand, location) ;
552
- } ) ;
553
-
554
553
// Mark the consumed locals to indicate later drops are noops.
555
554
if let Operand :: Move ( Place :: Local ( local) ) = * operand {
556
555
self . local_qualif [ local] = self . local_qualif [ local] . map ( |q|
@@ -595,12 +594,10 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
595
594
}
596
595
597
596
if is_reborrow {
598
- self . nest ( |this| {
599
- this. super_place ( place, PlaceContext :: Borrow {
600
- region,
601
- kind
602
- } , location) ;
603
- } ) ;
597
+ self . super_place ( place, PlaceContext :: Borrow {
598
+ region,
599
+ kind
600
+ } , location) ;
604
601
} else {
605
602
self . super_rvalue ( rvalue, location) ;
606
603
}
0 commit comments