Rollup merge of #40441 - tschottdorf:promotable-rfc, r=eddyb
Add feature gate for rvalue-static-promotion Probably needs more tests (which ones?) and there may be other things that need to be done. Also not sure whether the version that introduces the flag is really `1.15.1`. See https://github.com/rust-lang/rfcs/pull/1414. Updates #38865.
This commit is contained in:
commit
7b686ce4ca
6 changed files with 61 additions and 3 deletions
|
|
@ -71,6 +71,7 @@
|
|||
- [repr_simd](repr-simd.md)
|
||||
- [rustc_attrs](rustc-attrs.md)
|
||||
- [rustc_diagnostic_macros](rustc-diagnostic-macros.md)
|
||||
- [rvalue_static_promotion](rvalue-static-promotion.md)
|
||||
- [sanitizer_runtime](sanitizer-runtime.md)
|
||||
- [simd](simd.md)
|
||||
- [simd_ffi](simd-ffi.md)
|
||||
|
|
|
|||
23
src/doc/unstable-book/src/rvalue-static-promotion.md
Normal file
23
src/doc/unstable-book/src/rvalue-static-promotion.md
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# `rvalue_static_promotion`
|
||||
|
||||
The tracking issue for this feature is: [#38865]
|
||||
|
||||
[#38865]: https://github.com/rust-lang/rust/issues/38865
|
||||
|
||||
------------------------
|
||||
|
||||
The `rvalue_static_promotion` feature allows directly creating `'static` references to
|
||||
constant `rvalue`s, which in particular allowing for more concise code in the common case
|
||||
in which a `'static` reference is all that's needed.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
```rust
|
||||
#![feature(rvalue_static_promotion)]
|
||||
|
||||
fn main() {
|
||||
let DEFAULT_VALUE: &'static u32 = &42;
|
||||
assert_eq!(*DEFAULT_VALUE, 42);
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue