diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-06-12 11:42:58 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-06-19 21:16:04 +0300 |
| commit | 887feeeaf7d40c25caa9532f2d9121cb79fca899 (patch) | |
| tree | b1078b39f5eb7198125a384abe44cfa26eb97bc8 /src/libsyntax | |
| parent | e79b2a18a21e6b178d73473bb8fdbf3d18c66051 (diff) | |
| download | rust-887feeeaf7d40c25caa9532f2d9121cb79fca899.tar.gz rust-887feeeaf7d40c25caa9532f2d9121cb79fca899.zip | |
rustc: replace `GenericArgs::with_generic_args` hack with a plain getter.
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)] |
