diff options
| author | bors <bors@rust-lang.org> | 2019-06-20 07:46:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-20 07:46:11 +0000 |
| commit | 4fb77a0398d0339f35f1b18595b375428babd431 (patch) | |
| tree | 5218a52f0662893cd3f4067c6349629a7205dc5f /src/libsyntax | |
| parent | 3c805ce183840bd20bd81a54a02b3c8b6dccc9dd (diff) | |
| parent | 942a7fec30e93ca466a30287c8764cfdd8158d9e (diff) | |
| download | rust-4fb77a0398d0339f35f1b18595b375428babd431.tar.gz rust-4fb77a0398d0339f35f1b18595b375428babd431.zip | |
Auto merge of #61983 - Centril:rollup-wnfo07y, r=Centril
Rollup of 4 pull requests
Successful merges:
- #60454 (Add custom nth_back to Skip)
- #60772 (Implement nth_back for slice::{Iter, IterMut})
- #61782 (suggest tuple struct syntax)
- #61968 (rustc: disallow cloning HIR nodes.)
Failed merges:
r? @ghost
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/lib.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ptr.rs | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 55db8da3276..337b8424736 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -12,6 +12,8 @@ #![deny(unused_lifetimes)] #![feature(bind_by_move_pattern_guards)] +#![feature(const_fn)] +#![feature(const_transmute)] #![feature(crate_visibility_modifier)] #![feature(label_break_value)] #![feature(nll)] diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index d577243fb3d..f0cfa5a84a8 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -133,8 +133,15 @@ impl<T: Encodable> Encodable for P<T> { } impl<T> P<[T]> { - pub fn new() -> P<[T]> { - P { ptr: Default::default() } + pub const fn new() -> P<[T]> { + // HACK(eddyb) bypass the lack of a `const fn` to create an empty `Box<[T]>` + // (as trait methods, `default` in this case, can't be `const fn` yet). + P { + ptr: unsafe { + use std::ptr::NonNull; + std::mem::transmute(NonNull::<[T; 0]>::dangling() as NonNull<[T]>) + }, + } } #[inline(never)] |
