11//! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations.
22
33use rustc_errors:: { Applicability , Diagnostic , ErrorReported } ;
4+ use rustc_hir as hir;
45use rustc_hir:: def_id:: DefId ;
5- use rustc_hir:: { self as hir, HirId , LangItem } ;
66use rustc_index:: bit_set:: BitSet ;
77use rustc_infer:: infer:: TyCtxtInferExt ;
88use rustc_infer:: traits:: { ImplSource , Obligation , ObligationCause } ;
@@ -14,8 +14,7 @@ use rustc_middle::ty::{self, adjustment::PointerCast, Instance, InstanceDef, Ty,
1414use rustc_middle:: ty:: { Binder , TraitPredicate , TraitRef } ;
1515use rustc_mir_dataflow:: { self , Analysis } ;
1616use rustc_span:: { sym, Span , Symbol } ;
17- use rustc_trait_selection:: traits:: error_reporting:: InferCtxtExt ;
18- use rustc_trait_selection:: traits:: { self , SelectionContext , TraitEngine } ;
17+ use rustc_trait_selection:: traits:: SelectionContext ;
1918
2019use std:: mem;
2120use std:: ops:: Deref ;
@@ -255,16 +254,6 @@ impl Checker<'mir, 'tcx> {
255254 self . visit_body ( & body) ;
256255 }
257256
258- // Ensure that the end result is `Sync` in a non-thread local `static`.
259- let should_check_for_sync = self . const_kind ( )
260- == hir:: ConstContext :: Static ( hir:: Mutability :: Not )
261- && !tcx. is_thread_local_static ( def_id. to_def_id ( ) ) ;
262-
263- if should_check_for_sync {
264- let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def_id) ;
265- check_return_ty_is_sync ( tcx, & body, hir_id) ;
266- }
267-
268257 // If we got through const-checking without emitting any "primary" errors, emit any
269258 // "secondary" errors if they occurred.
270259 let secondary_errors = mem:: take ( & mut self . secondary_errors ) ;
@@ -1054,20 +1043,6 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
10541043 }
10551044}
10561045
1057- fn check_return_ty_is_sync ( tcx : TyCtxt < ' tcx > , body : & Body < ' tcx > , hir_id : HirId ) {
1058- let ty = body. return_ty ( ) ;
1059- tcx. infer_ctxt ( ) . enter ( |infcx| {
1060- let cause = traits:: ObligationCause :: new ( body. span , hir_id, traits:: SharedStatic ) ;
1061- let mut fulfillment_cx = traits:: FulfillmentContext :: new ( ) ;
1062- let sync_def_id = tcx. require_lang_item ( LangItem :: Sync , Some ( body. span ) ) ;
1063- fulfillment_cx. register_bound ( & infcx, ty:: ParamEnv :: empty ( ) , ty, sync_def_id, cause) ;
1064- let errors = fulfillment_cx. select_all_or_error ( & infcx) ;
1065- if !errors. is_empty ( ) {
1066- infcx. report_fulfillment_errors ( & errors, None , false ) ;
1067- }
1068- } ) ;
1069- }
1070-
10711046fn place_as_reborrow (
10721047 tcx : TyCtxt < ' tcx > ,
10731048 body : & Body < ' tcx > ,
0 commit comments