Skip to content

Commit a813856

Browse files
committed
---
yaml --- r: 109194 b: refs/heads/dist-snap c: 68a3ec0 h: refs/heads/master v: v3
1 parent 18193a5 commit a813856

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
@@ -6,7 +6,7 @@ refs/heads/try: f64fdf524a434f0e5cd0bc91d09c144723f3c90d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: ff1c49fa543faf9123271c8cfb779796dd00078a
9+
refs/heads/dist-snap: 68a3ec08b3a829d64e6bc452c0b11fbd01e70eaf
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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/dist-snap/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)