Skip to content

Commit d88ed04

Browse files
author
Nick Hamann
committed
---
yaml --- r: 212071 b: refs/heads/tmp c: 7e78e70 h: refs/heads/master i: 212069: 15a374a 212067: 1698576 212063: 3144c7b v: v3
1 parent ac84cce commit d88ed04

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
@@ -32,7 +32,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3232
refs/heads/beta: 62e70d35be3fe532c26a400b499c58a18f18dd3a
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35-
refs/heads/tmp: eb15030dc18933c189daa0f9e0dfc780691a217b
35+
refs/heads/tmp: 7e78e708fb3f5115b47cc1c0b32c77a381519ecc
3636
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3737
refs/tags/homu-tmp: b77d60adb019bb5de05e884a99f3290ec4694137
3838
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/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/tmp/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/tmp/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)