diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-31 06:17:10 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-31 06:17:10 +0200 |
| commit | 0a8a3dd88a1216e7487b8e39179fbac16d07bafe (patch) | |
| tree | 792cd25277fdd212c375cc70e2d0a48db81056fd /src | |
| parent | 9196af0b3647c29cb1c268ba9b01546df55fc004 (diff) | |
qualify_consts: move thread_local condition out.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/transform/qualify_consts.rs | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 73475be24d4..32b49ee9423 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -1648,9 +1648,9 @@ impl<'tcx> MirPass<'tcx> for QualifyAndPromoteConstants<'tcx> { remove_drop_and_storage_dead_on_promoted_locals(body, promoted_temps); } - if let Mode::Static = mode { + if mode == Mode::Static && !tcx.has_attr(def_id, sym::thread_local) { // `static`s (not `static mut`s) which are not `#[thread_local]` must be `Sync`. - check_non_thread_local_static_is_sync(tcx, body, def_id, hir_id); + check_static_is_sync(tcx, body, hir_id); } } } @@ -1739,17 +1739,7 @@ fn remove_drop_and_storage_dead_on_promoted_locals( } } -fn check_non_thread_local_static_is_sync( - tcx: TyCtxt<'tcx>, - body: &mut Body<'tcx>, - def_id: DefId, - hir_id: HirId, -) { - // `#[thread_local]` statics don't have to be `Sync`. - if tcx.has_attr(def_id, sym::thread_local) { - return; - } - +fn check_static_is_sync(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, hir_id: HirId) { let ty = body.return_ty(); tcx.infer_ctxt().enter(|infcx| { let cause = traits::ObligationCause::new(body.span, hir_id, traits::SharedStatic); |
