diff --git a/compiler/rustc_ast/src/lib.rs b/compiler/rustc_ast/src/lib.rs index 538bfc2129017..a7c23dbb79ca5 100644 --- a/compiler/rustc_ast/src/lib.rs +++ b/compiler/rustc_ast/src/lib.rs @@ -9,6 +9,8 @@ test(attr(deny(warnings))) )] #![feature(box_patterns)] +#![feature(const_default_impls)] +#![feature(const_trait_impl)] #![feature(crate_visibility_modifier)] #![feature(if_let_guard)] #![feature(label_break_value)] diff --git a/compiler/rustc_ast/src/ptr.rs b/compiler/rustc_ast/src/ptr.rs index 70dbda8222445..89a0857992e49 100644 --- a/compiler/rustc_ast/src/ptr.rs +++ b/compiler/rustc_ast/src/ptr.rs @@ -128,14 +128,7 @@ impl> Encodable for P { impl P<[T]> { 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]>) - }, - } + P { ptr: Box::default() } } #[inline(never)]