about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-01-12 10:54:56 +0100
committerGitHub <noreply@github.com>2019-01-12 10:54:56 +0100
commitbd8f46487761fe7e1d1feb301a7e45231ca2c0fe (patch)
treecba4990b610d2de89a9e87486110a5b7ab37cf60 /src/rustllvm/RustWrapper.cpp
parent017f046c1371758bf4363afd4384bafb583b9710 (diff)
parent6c623224dcf6f7cf06afd46b17ce7f665e6b4fda (diff)
downloadrust-bd8f46487761fe7e1d1feb301a7e45231ca2c0fe.tar.gz
rust-bd8f46487761fe7e1d1feb301a7e45231ca2c0fe.zip
Rollup merge of #57175 - oli-obk:const_let_stabilization, r=nikomatsakis
Stabilize `let` bindings and destructuring in constants and const fn

r? @Centril

This PR stabilizes the following features in constants and `const` functions:

* irrefutable destructuring patterns (e.g. `const fn foo((x, y): (u8, u8)) { ... }`)
* `let` bindings (e.g. `let x = 1;`)
* mutable `let` bindings (e.g. `let mut x = 1;`)
* assignment (e.g. `x = y`) and assignment operator (e.g. `x += y`) expressions, even where the assignment target is a projection (e.g. a struct field or index operation like `x[3] = 42`)
* expression statements (e.g. `3;`)

This PR does explicitly *not* stabilize:

* mutable references (i.e. `&mut T`)
* dereferencing mutable references
* refutable patterns (e.g. `Some(x)`)
* operations on `UnsafeCell` types (as that would need raw pointers and mutable references and such, not because it is explicitly forbidden. We can't explicitly forbid it as such values are OK as long as they aren't mutated.)
* We are not stabilizing `let` bindings in constants that use `&&` and `||` short circuiting operations. These are treated as `&` and `|` inside `const` and `static` items right now. If we stopped treating them as `&` and `|` after stabilizing `let` bindings, we'd break code like `let mut x = false; false && { x = true; false };`. So to use `let` bindings in constants you need to change `&&` and `||` to `&` and `|` respectively.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions