@@ -450,25 +450,26 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
450450 match * place {
451451 Place :: Local ( ref local) => self . visit_local ( local, context, location) ,
452452 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+ }
455462 self . add ( Qualif :: NOT_CONST ) ;
463+ return ;
456464 }
457465
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 ;
469469 }
470+ self . add ( Qualif :: NOT_CONST ) ;
470471
471- if self . mode == Mode :: Const || self . mode == Mode :: ConstFn {
472+ if self . mode != Mode :: Fn {
472473 let mut err = struct_span_err ! ( self . tcx. sess, self . span, E0013 ,
473474 "{}s cannot refer to statics, use \
474475 a constant instead", self . mode) ;
@@ -544,13 +545,11 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
544545 }
545546
546547 fn visit_operand ( & mut self , operand : & Operand < ' tcx > , location : Location ) {
548+ self . super_operand ( operand, location) ;
549+
547550 match * operand {
548551 Operand :: Copy ( _) |
549552 Operand :: Move ( _) => {
550- self . nest ( |this| {
551- this. super_operand ( operand, location) ;
552- } ) ;
553-
554553 // Mark the consumed locals to indicate later drops are noops.
555554 if let Operand :: Move ( Place :: Local ( local) ) = * operand {
556555 self . local_qualif [ local] = self . local_qualif [ local] . map ( |q|
@@ -595,12 +594,10 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
595594 }
596595
597596 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) ;
604601 } else {
605602 self . super_rvalue ( rvalue, location) ;
606603 }
0 commit comments