about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlavio Percoco <flaper87@gmail.com>2014-03-14 22:56:10 +0100
committerFlavio Percoco <flaper87@gmail.com>2014-03-20 10:17:28 +0100
commit68a3ec08b3a829d64e6bc452c0b11fbd01e70eaf (patch)
treeb186c09e0b3b66c2ce445a40516265b94bcf499c
parentff1c49fa543faf9123271c8cfb779796dd00078a (diff)
downloadrust-68a3ec08b3a829d64e6bc452c0b11fbd01e70eaf.tar.gz
rust-68a3ec08b3a829d64e6bc452c0b11fbd01e70eaf.zip
Allow static items that don't fulfill `Freeze`
-rw-r--r--src/librustc/middle/check_static.rs25
-rw-r--r--src/test/compile-fail/check-static-values-constraints.rs24
2 files changed, 4 insertions, 45 deletions
diff --git a/src/librustc/middle/check_static.rs b/src/librustc/middle/check_static.rs
index 83f987a0bd0..ecc3ba59dd5 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<bool> 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<bool> 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 852b06d00a6..8ae40a74af1 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