diff --git a/src/librustc/middle/check_static.rs b/src/librustc/middle/check_static.rs index 83f987a0bd0b..ecc3ba59dd5a 100644 --- a/src/librustc/middle/check_static.rs +++ b/src/librustc/middle/check_static.rs @@ -18,8 +18,11 @@ // - For each *immutable* static item, it checks that its **value**: // - doesn't own owned, managed pointers // - doesn't contain a struct literal or a call to an enum variant / struct constructor where -// - the type of the struct/enum is not freeze // - the type of the struct/enum has a dtor +// +// Rules Enforced Elsewhere: +// - It's not possible to take the address of a static item with unsafe interior. This is enforced +// by borrowck::gather_loans use middle::ty; @@ -121,21 +124,6 @@ impl<'a> Visitor for CheckStaticVisitor<'a> { self.tcx.sess.span_err(e.span, "static items are not allowed to have owned pointers"); } - ast::ExprProc(..) => { - self.report_error(e.span, - Some(~"immutable static items must be `Freeze`")); - return; - } - ast::ExprAddrOf(mutability, _) => { - match mutability { - ast::MutMutable => { - self.report_error(e.span, - Some(~"immutable static items must be `Freeze`")); - return; - } - _ => {} - } - } _ => { let node_ty = ty::node_id_to_type(self.tcx, e.id); @@ -147,11 +135,6 @@ impl<'a> Visitor for CheckStaticVisitor<'a> { Some(~"static items are not allowed to have destructors")); return; } - if Some(did) == self.tcx.lang_items.no_freeze_bound() { - self.report_error(e.span, - Some(~"immutable static items must be `Freeze`")); - return; - } } _ => {} } diff --git a/src/test/compile-fail/check-static-values-constraints.rs b/src/test/compile-fail/check-static-values-constraints.rs index 852b06d00a64..8ae40a74af18 100644 --- a/src/test/compile-fail/check-static-values-constraints.rs +++ b/src/test/compile-fail/check-static-values-constraints.rs @@ -124,30 +124,6 @@ static STATIC18: @SafeStruct = @SafeStruct{field1: Variant1, field2: Variant2(0) static STATIC19: ~int = box 3; //~^ ERROR static items are not allowed to have owned pointers - -struct StructNoFreeze<'a> { - nf: &'a int -} - -enum EnumNoFreeze<'a> { - FreezableVariant, - NonFreezableVariant(StructNoFreeze<'a>) -} - -static STATIC20: StructNoFreeze<'static> = StructNoFreeze{nf: &'static mut 4}; -//~^ ERROR immutable static items must be `Freeze` - -static STATIC21: EnumNoFreeze<'static> = FreezableVariant; -static STATIC22: EnumNoFreeze<'static> = NonFreezableVariant(StructNoFreeze{nf: &'static mut 4}); -//~^ ERROR immutable static items must be `Freeze` - -struct NFMarker { - nf: marker::NoFreeze -} - -static STATIC23: NFMarker = NFMarker{nf: marker::NoFreeze}; -//~^ ERROR immutable static items must be `Freeze` - pub fn main() { let y = { static x: ~int = ~3; x }; //~^ ERROR static items are not allowed to have owned pointers