Skip to content

Commit 23ba3ba

Browse files
committed
---
yaml --- r: 150113 b: refs/heads/try2 c: 68a3ec0 h: refs/heads/master i: 150111: 6333af5 v: v3
1 parent d23a4a9 commit 23ba3ba

File tree

3 files changed

+5
-46
lines changed

3 files changed

+5
-46
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: ff1c49fa543faf9123271c8cfb779796dd00078a
8+
refs/heads/try2: 68a3ec08b3a829d64e6bc452c0b11fbd01e70eaf
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/check_static.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
// - For each *immutable* static item, it checks that its **value**:
1919
// - doesn't own owned, managed pointers
2020
// - doesn't contain a struct literal or a call to an enum variant / struct constructor where
21-
// - the type of the struct/enum is not freeze
2221
// - the type of the struct/enum has a dtor
22+
//
23+
// Rules Enforced Elsewhere:
24+
// - It's not possible to take the address of a static item with unsafe interior. This is enforced
25+
// by borrowck::gather_loans
2326

2427
use middle::ty;
2528

@@ -121,21 +124,6 @@ impl<'a> Visitor<bool> for CheckStaticVisitor<'a> {
121124
self.tcx.sess.span_err(e.span,
122125
"static items are not allowed to have owned pointers");
123126
}
124-
ast::ExprProc(..) => {
125-
self.report_error(e.span,
126-
Some(~"immutable static items must be `Freeze`"));
127-
return;
128-
}
129-
ast::ExprAddrOf(mutability, _) => {
130-
match mutability {
131-
ast::MutMutable => {
132-
self.report_error(e.span,
133-
Some(~"immutable static items must be `Freeze`"));
134-
return;
135-
}
136-
_ => {}
137-
}
138-
}
139127
_ => {
140128
let node_ty = ty::node_id_to_type(self.tcx, e.id);
141129

@@ -147,11 +135,6 @@ impl<'a> Visitor<bool> for CheckStaticVisitor<'a> {
147135
Some(~"static items are not allowed to have destructors"));
148136
return;
149137
}
150-
if Some(did) == self.tcx.lang_items.no_freeze_bound() {
151-
self.report_error(e.span,
152-
Some(~"immutable static items must be `Freeze`"));
153-
return;
154-
}
155138
}
156139
_ => {}
157140
}

branches/try2/src/test/compile-fail/check-static-values-constraints.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,30 +124,6 @@ static STATIC18: @SafeStruct = @SafeStruct{field1: Variant1, field2: Variant2(0)
124124
static STATIC19: ~int = box 3;
125125
//~^ ERROR static items are not allowed to have owned pointers
126126

127-
128-
struct StructNoFreeze<'a> {
129-
nf: &'a int
130-
}
131-
132-
enum EnumNoFreeze<'a> {
133-
FreezableVariant,
134-
NonFreezableVariant(StructNoFreeze<'a>)
135-
}
136-
137-
static STATIC20: StructNoFreeze<'static> = StructNoFreeze{nf: &'static mut 4};
138-
//~^ ERROR immutable static items must be `Freeze`
139-
140-
static STATIC21: EnumNoFreeze<'static> = FreezableVariant;
141-
static STATIC22: EnumNoFreeze<'static> = NonFreezableVariant(StructNoFreeze{nf: &'static mut 4});
142-
//~^ ERROR immutable static items must be `Freeze`
143-
144-
struct NFMarker {
145-
nf: marker::NoFreeze
146-
}
147-
148-
static STATIC23: NFMarker = NFMarker{nf: marker::NoFreeze};
149-
//~^ ERROR immutable static items must be `Freeze`
150-
151127
pub fn main() {
152128
let y = { static x: ~int = ~3; x };
153129
//~^ ERROR static items are not allowed to have owned pointers

0 commit comments

Comments
 (0)