about summary refs log tree commit diff
path: root/src/libsyntax/errors
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-05-08 00:31:40 -0700
committerbors <bors@rust-lang.org>2016-05-08 00:31:40 -0700
commit1ec22171e6053c640293067418ea1901cb1c7df1 (patch)
tree8d4b9c30157f0bcaeb42fc3d7fe606fe91b33738 /src/libsyntax/errors
parentd91f8ab0f58fa123857d96b9e151fc5185f5ff08 (diff)
parent3b0e27cc74d61e229aeaf0a710d3a018f7104ffc (diff)
downloadrust-1ec22171e6053c640293067418ea1901cb1c7df1.tar.gz
rust-1ec22171e6053c640293067418ea1901cb1c7df1.zip
Auto merge of #33130 - eddyb:mir-const, r=nikomatsakis
Implement constant support in MIR.

All of the intended features in `trans::consts` are now supported by `mir::constant`.
The implementation is considered a temporary measure until `miri` replaces it.

A `-Z orbit` bootstrap build will only translate LLVM IR from AST for `#[rustc_no_mir]` functions.

Furthermore, almost all checks of constant expressions have been moved to MIR.
In non-`const` functions, trees of temporaries are promoted, as per RFC 1414 (rvalue promotion).
Promotion before MIR borrowck would allow reasoning about promoted values' lifetimes.

The improved checking comes at the cost of four `[breaking-change]`s:
* repeat counts must contain a constant expression, e.g.:
`let arr = [0; { println!("foo"); 5 }];` used to be allowed (it behaved like `let arr = [0; 5];`)
* dereference of a reference to a `static` cannot be used in another `static`, e.g.:
`static X: [u8; 1] = [1]; static Y: u8 = (&X)[0];` was unintentionally allowed before
* the type of a `static` *must* be `Sync`, irrespective of the initializer, e.g.
`static FOO: *const T = &BAR;` worked as `&T` is `Sync`, but it shouldn't because `*const T` isn't
* a `static` cannot wrap `UnsafeCell` around a type that *may* need drop, e.g.
`static X: MakeSync<UnsafeCell<Option<String>>> = MakeSync(UnsafeCell::new(None));`
was previously allowed based on the fact `None` alone doesn't need drop, but in `UnsafeCell`
it can be later changed to `Some(String)` which *does* need dropping

The drop restrictions are relaxed by RFC 1440 (#33156), which is implemented, but feature-gated.
However, creating `UnsafeCell` from constants is unstable, so users can just enable the feature gate.
Diffstat (limited to 'src/libsyntax/errors')
0 files changed, 0 insertions, 0 deletions