Skip to content

Commit 2fd5b79

Browse files
author
Nick Hamann
committed
---
yaml --- r: 218815 b: refs/heads/snap-stage3 c: 7e78e70 h: refs/heads/master i: 218813: fc60631 218811: 3ee5e83 218807: e5fbc17 218799: 92e362d 218783: c0caa23 218751: 1485d75 v: v3
1 parent 8b885b1 commit 2fd5b79

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
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: c044791d80ea0dc5c4b57b6030a67b69f8510239
3-
refs/heads/snap-stage3: eb15030dc18933c189daa0f9e0dfc780691a217b
3+
refs/heads/snap-stage3: 7e78e708fb3f5115b47cc1c0b32c77a381519ecc
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

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