diff options
| -rw-r--r-- | src/librustc_mir/transform/check_consts/qualifs.rs | 25 | ||||
| -rw-r--r-- | src/test/run-make-fulldeps/min-global-align/min_global_align.rs | 10 |
2 files changed, 14 insertions, 21 deletions
diff --git a/src/librustc_mir/transform/check_consts/qualifs.rs b/src/librustc_mir/transform/check_consts/qualifs.rs index e509e8267cc..215496e4d03 100644 --- a/src/librustc_mir/transform/check_consts/qualifs.rs +++ b/src/librustc_mir/transform/check_consts/qualifs.rs @@ -94,32 +94,23 @@ pub trait Qualif { } Operand::Constant(ref constant) => { - if constant.check_static_ptr(cx.tcx).is_some() { - // `mir_const_qualif` does return the qualifs in the final value of a `static`, - // so we could use value-based qualification here, but we shouldn't do this - // without a good reason. - // - // Note: this uses `constant.literal.ty` which is a reference or pointer to the - // type of the actual `static` item. - Self::in_any_value_of_ty(cx, constant.literal.ty) - } else if let ty::ConstKind::Unevaluated(def_id, _, promoted) = constant.literal.val - { + // Check the qualifs of the value of `const` items. + if let ty::ConstKind::Unevaluated(def_id, _, promoted) = constant.literal.val { assert!(promoted.is_none()); // Don't peek inside trait associated constants. - if cx.tcx.trait_of_item(def_id).is_some() { - Self::in_any_value_of_ty(cx, constant.literal.ty) - } else { + if cx.tcx.trait_of_item(def_id).is_none() { let qualifs = cx.tcx.at(constant.span).mir_const_qualif(def_id); - let qualif = Self::in_qualifs(&qualifs); + if !Self::in_qualifs(&qualifs) { + return false; + } // Just in case the type is more specific than // the definition, e.g., impl associated const // with type parameters, take it into account. - qualif && Self::in_any_value_of_ty(cx, constant.literal.ty) } - } else { - false } + // Otherwise use the qualifs of the type. + Self::in_any_value_of_ty(cx, constant.literal.ty) } } } diff --git a/src/test/run-make-fulldeps/min-global-align/min_global_align.rs b/src/test/run-make-fulldeps/min-global-align/min_global_align.rs index ce86d202c62..d9851a2f794 100644 --- a/src/test/run-make-fulldeps/min-global-align/min_global_align.rs +++ b/src/test/run-make-fulldeps/min-global-align/min_global_align.rs @@ -1,5 +1,5 @@ #![feature(no_core, lang_items)] -#![crate_type="rlib"] +#![crate_type = "rlib"] #![no_core] pub static STATIC_BOOL: bool = true; @@ -9,7 +9,6 @@ pub static mut STATIC_MUT_BOOL: bool = true; const CONST_BOOL: bool = true; pub static CONST_BOOL_REF: &'static bool = &CONST_BOOL; - #[lang = "sized"] trait Sized {} @@ -19,10 +18,13 @@ trait Copy {} #[lang = "freeze"] trait Freeze {} +// No `UnsafeCell`, so everything is `Freeze`. +impl<T: ?Sized> Freeze for T {} + #[lang = "sync"] trait Sync {} impl Sync for bool {} impl Sync for &'static bool {} -#[lang="drop_in_place"] -pub unsafe fn drop_in_place<T: ?Sized>(_: *mut T) { } +#[lang = "drop_in_place"] +pub unsafe fn drop_in_place<T: ?Sized>(_: *mut T) {} |
