Skip to content

Commit dc213a8

Browse files
author
Nick Hamann
committed
---
yaml --- r: 211773 b: refs/heads/auto c: 7e78e70 h: refs/heads/master i: 211771: c74f6b7 v: v3
1 parent 3938e63 commit dc213a8

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: eb15030dc18933c189daa0f9e0dfc780691a217b
13+
refs/heads/auto: 7e78e708fb3f5115b47cc1c0b32c77a381519ecc
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/diagnostics.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,19 @@ From [RFC 246]:
880880
> required that all references be borrowed.
881881
882882
[RFC 246]: https://github.com/rust-lang/rfcs/pull/246
883+
"##,
884+
885+
E0397: r##"
886+
It is not allowed for a mutable static to allocate or have destructors. For
887+
example:
888+
889+
```
890+
// error: mutable statics are not allowed to have boxes
891+
static mut FOO: Option<Box<usize>> = None;
892+
893+
// error: mutable statics are not allowed to have destructors
894+
static mut BAR: Option<Vec<i32>> = None;
895+
```
883896
"##
884897

885898
}

branches/auto/src/librustc/middle/check_const.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
249249
let suffix = if tcontents.has_dtor() {
250250
"destructors"
251251
} else if tcontents.owns_owned() {
252-
"owned pointers"
252+
"boxes"
253253
} else {
254254
return
255255
};
256256

257-
self.tcx.sess.span_err(e.span, &format!("mutable statics are not allowed \
258-
to have {}", suffix));
257+
span_err!(self.tcx.sess, e.span, E0397,
258+
"mutable statics are not allowed to have {}", suffix);
259259
}
260260

261261
fn check_static_type(&self, e: &ast::Expr) {

branches/auto/src/test/compile-fail/static-mut-not-constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212

1313
static mut a: Box<isize> = box 3;
1414
//~^ ERROR allocations are not allowed in statics
15-
//~^^ ERROR mutable statics are not allowed to have owned pointers
15+
//~^^ ERROR mutable statics are not allowed to have boxes
1616

1717
fn main() {}

0 commit comments

Comments
 (0)