1
1
//! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations.
2
2
3
3
use rustc_errors:: { Applicability , Diagnostic , ErrorReported } ;
4
+ use rustc_hir as hir;
4
5
use rustc_hir:: def_id:: DefId ;
5
- use rustc_hir:: { self as hir, HirId , LangItem } ;
6
6
use rustc_index:: bit_set:: BitSet ;
7
7
use rustc_infer:: infer:: TyCtxtInferExt ;
8
8
use rustc_infer:: traits:: { ImplSource , Obligation , ObligationCause } ;
@@ -14,8 +14,7 @@ use rustc_middle::ty::{self, adjustment::PointerCast, Instance, InstanceDef, Ty,
14
14
use rustc_middle:: ty:: { Binder , TraitPredicate , TraitRef } ;
15
15
use rustc_mir_dataflow:: { self , Analysis } ;
16
16
use 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 ;
19
18
20
19
use std:: mem;
21
20
use std:: ops:: Deref ;
@@ -255,16 +254,6 @@ impl Checker<'mir, 'tcx> {
255
254
self . visit_body ( & body) ;
256
255
}
257
256
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
-
268
257
// If we got through const-checking without emitting any "primary" errors, emit any
269
258
// "secondary" errors if they occurred.
270
259
let secondary_errors = mem:: take ( & mut self . secondary_errors ) ;
@@ -1054,20 +1043,6 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
1054
1043
}
1055
1044
}
1056
1045
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
-
1071
1046
fn place_as_reborrow (
1072
1047
tcx : TyCtxt < ' tcx > ,
1073
1048
body : & Body < ' tcx > ,
0 commit comments