From ab78384a8861a59f1d7483845e0a98ae0eec7929 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 2 Jan 2025 21:22:42 +0100 Subject: [PATCH 1/2] turn rustc_box into an intrinsic --- compiler/rustc_feature/src/builtin_attrs.rs | 5 - .../rustc_hir_analysis/src/check/intrinsic.rs | 3 + compiler/rustc_mir_build/messages.ftl | 5 - compiler/rustc_mir_build/src/errors.rs | 19 ---- compiler/rustc_mir_build/src/thir/cx/expr.rs | 57 ++++------ compiler/rustc_span/src/symbol.rs | 1 - library/alloc/src/alloc.rs | 2 +- library/alloc/src/boxed.rs | 24 ++++- library/alloc/src/lib.rs | 1 + library/alloc/src/macros.rs | 5 +- .../disallowed_macros.stderr | 17 ++- tests/mir-opt/box_expr.rs | 5 +- .../building/uniform_array_move_out.rs | 16 +-- tests/mir-opt/const_prop/boxes.rs | 6 +- tests/mir-opt/issue_62289.rs | 7 +- tests/ui/attributes/rustc-box.rs | 18 ---- tests/ui/attributes/rustc-box.stderr | 34 ------ tests/ui/coroutine/issue-105084.rs | 5 +- tests/ui/coroutine/issue-105084.stderr | 16 +-- tests/ui/lint/unused/unused-allocation.rs | 2 - tests/ui/lint/unused/unused-allocation.stderr | 16 +-- tests/ui/macros/vec-macro-in-pattern.rs | 4 +- tests/ui/macros/vec-macro-in-pattern.stderr | 31 ++++-- tests/ui/unpretty/box.rs | 7 +- tests/ui/unpretty/box.stdout | 100 +++++++++++++++--- 25 files changed, 198 insertions(+), 208 deletions(-) delete mode 100644 tests/ui/attributes/rustc-box.rs delete mode 100644 tests/ui/attributes/rustc-box.stderr diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 4112ae8098075..71941c8a206fa 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -933,11 +933,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ "#[rustc_has_incoherent_inherent_impls] allows the addition of incoherent inherent impls for \ the given type by annotating all impl items with #[rustc_allow_incoherent_impl]." ), - rustc_attr!( - rustc_box, AttributeType::Normal, template!(Word), ErrorFollowing, EncodeCrossCrate::No, - "#[rustc_box] allows creating boxes \ - and it is only intended to be used in `alloc`." - ), BuiltinAttribute { name: sym::rustc_diagnostic_item, diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index fd78bf3e8fc60..5595cc3280f22 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -86,6 +86,7 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) - | sym::assert_inhabited | sym::assert_zero_valid | sym::assert_mem_uninitialized_valid + | sym::box_new | sym::breakpoint | sym::size_of | sym::min_align_of @@ -606,6 +607,8 @@ pub fn check_intrinsic_type( sym::ub_checks => (0, 0, Vec::new(), tcx.types.bool), + sym::box_new => (1, 0, vec![param(0)], Ty::new_box(tcx, param(0))), + sym::simd_eq | sym::simd_ne | sym::simd_lt diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index edba247c7b0df..5d61a9d1e752a 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -287,11 +287,6 @@ mir_build_privately_uninhabited = pattern `{$witness_1}` is currently uninhabite mir_build_rust_2024_incompatible_pat = this pattern relies on behavior which may change in edition 2024 -mir_build_rustc_box_attribute_error = `#[rustc_box]` attribute used incorrectly - .attributes = no other attributes may be applied - .not_box = `#[rustc_box]` may only be applied to a `Box::new()` call - .missing_box = `#[rustc_box]` requires the `owned_box` lang item - mir_build_static_in_pattern = statics cannot be referenced in patterns .label = can't be used in patterns mir_build_static_in_pattern_def = `static` defined here diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index be5f8bdffb50b..790d56860d28e 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -1067,25 +1067,6 @@ pub(crate) enum MiscPatternSuggestion { }, } -#[derive(Diagnostic)] -#[diag(mir_build_rustc_box_attribute_error)] -pub(crate) struct RustcBoxAttributeError { - #[primary_span] - pub(crate) span: Span, - #[subdiagnostic] - pub(crate) reason: RustcBoxAttrReason, -} - -#[derive(Subdiagnostic)] -pub(crate) enum RustcBoxAttrReason { - #[note(mir_build_attributes)] - Attributes, - #[note(mir_build_not_box)] - NotBoxNew, - #[note(mir_build_missing_box)] - MissingBox, -} - #[derive(LintDiagnostic)] #[diag(mir_build_rust_2024_incompatible_pat)] pub(crate) struct Rust2024IncompatiblePat<'a> { diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 0338ac674e5e2..9cdf08d749b01 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -20,7 +20,6 @@ use rustc_middle::{bug, span_bug}; use rustc_span::{Span, sym}; use tracing::{debug, info, instrument, trace}; -use crate::errors; use crate::thir::cx::Cx; use crate::thir::util::UserAnnotatedTyHelpers; @@ -380,45 +379,25 @@ impl<'tcx> Cx<'tcx> { from_hir_call: true, fn_span: expr.span, } - } else { - let attrs = tcx.hir().attrs(expr.hir_id); - if attrs.iter().any(|a| a.name_or_empty() == sym::rustc_box) { - if attrs.len() != 1 { - tcx.dcx().emit_err(errors::RustcBoxAttributeError { - span: attrs[0].span, - reason: errors::RustcBoxAttrReason::Attributes, - }); - } else if let Some(box_item) = tcx.lang_items().owned_box() { - if let hir::ExprKind::Path(hir::QPath::TypeRelative(ty, fn_path)) = - fun.kind - && let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = ty.kind - && path.res.opt_def_id().is_some_and(|did| did == box_item) - && fn_path.ident.name == sym::new - && let [value] = args - { - return Expr { - temp_lifetime: TempLifetime { - temp_lifetime, - backwards_incompatible, - }, - ty: expr_ty, - span: expr.span, - kind: ExprKind::Box { value: self.mirror_expr(value) }, - }; - } else { - tcx.dcx().emit_err(errors::RustcBoxAttributeError { - span: expr.span, - reason: errors::RustcBoxAttrReason::NotBoxNew, - }); - } - } else { - tcx.dcx().emit_err(errors::RustcBoxAttributeError { - span: attrs[0].span, - reason: errors::RustcBoxAttrReason::MissingBox, - }); - } + } else if let ty::FnDef(def_id, _) = self.typeck_results().expr_ty(fun).kind() + && let Some(intrinsic) = self.tcx.intrinsic(def_id) + && intrinsic.name == sym::box_new + { + // We don't actually evaluate `fun` here, so make sure that doesn't miss any side-effects. + if !matches!(fun.kind, hir::ExprKind::Path(_)) { + span_bug!( + expr.span, + "`box_new` intrinsic can only be called via path expression" + ); } - + let value = &args[0]; + return Expr { + temp_lifetime: TempLifetime { temp_lifetime, backwards_incompatible }, + ty: expr_ty, + span: expr.span, + kind: ExprKind::Box { value: self.mirror_expr(value) }, + }; + } else { // Tuple-like ADTs are represented as ExprKind::Call. We convert them here. let adt_data = if let hir::ExprKind::Path(ref qpath) = fun.kind && let Some(adt_def) = expr_ty.ty_adt_def() diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 4ecc4201f89d5..bdfbfb1e38dd3 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1696,7 +1696,6 @@ symbols! { rustc_as_ptr, rustc_attrs, rustc_autodiff, - rustc_box, rustc_builtin_macro, rustc_capture_analysis, rustc_clean, diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index ae34fc653260e..e9b7f9856677c 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -339,7 +339,7 @@ unsafe impl Allocator for Global { } } -/// The allocator for unique pointers. +/// The allocator for `Box`. #[cfg(all(not(no_global_oom_handling), not(test)))] #[lang = "exchange_malloc"] #[inline] diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 05e5d712a2737..0f66217b5cb33 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -233,6 +233,27 @@ pub struct Box< #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, >(Unique, A); +/// Constructs a `Box` by calling the `exchange_malloc` lang item and moving the argument into +/// the newly allocated memory. This is an intrinsic to avoid unnecessary copies. +/// +/// This is the surface syntax for `box ` expressions. +#[cfg(not(bootstrap))] +#[rustc_intrinsic] +#[rustc_intrinsic_must_be_overridden] +#[unstable(feature = "liballoc_internals", issue = "none")] +pub fn box_new(_x: T) -> Box { + unreachable!() +} + +/// Transition function for the next bootstrap bump. +#[cfg(bootstrap)] +#[unstable(feature = "liballoc_internals", issue = "none")] +#[inline(always)] +pub fn box_new(x: T) -> Box { + #[rustc_box] + Box::new(x) +} + impl Box { /// Allocates memory on the heap and then places `x` into it. /// @@ -250,8 +271,7 @@ impl Box { #[rustc_diagnostic_item = "box_new"] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub fn new(x: T) -> Self { - #[rustc_box] - Box::new(x) + return box_new(x); } /// Constructs a new box with uninitialized contents. diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 40759cb0ba83c..aff90f5abb3a0 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -168,6 +168,7 @@ #![feature(dropck_eyepatch)] #![feature(fundamental)] #![feature(hashmap_internals)] +#![feature(intrinsics)] #![feature(lang_items)] #![feature(min_specialization)] #![feature(multiple_supertrait_upcastable)] diff --git a/library/alloc/src/macros.rs b/library/alloc/src/macros.rs index 8c6a367869ce0..6ee3907cc8ea2 100644 --- a/library/alloc/src/macros.rs +++ b/library/alloc/src/macros.rs @@ -48,10 +48,9 @@ macro_rules! vec { ); ($($x:expr),+ $(,)?) => ( <[_]>::into_vec( - // This rustc_box is not required, but it produces a dramatic improvement in compile + // Using the intrinsic produces a dramatic improvement in compile // time when constructing arrays with many elements. - #[rustc_box] - $crate::boxed::Box::new([$($x),+]) + $crate::boxed::box_new([$($x),+]) ) ); } diff --git a/src/tools/clippy/tests/ui-toml/disallowed_macros/disallowed_macros.stderr b/src/tools/clippy/tests/ui-toml/disallowed_macros/disallowed_macros.stderr index 2e3386628b4d3..6a6c6168a1f59 100644 --- a/src/tools/clippy/tests/ui-toml/disallowed_macros/disallowed_macros.stderr +++ b/src/tools/clippy/tests/ui-toml/disallowed_macros/disallowed_macros.stderr @@ -1,12 +1,3 @@ -error: use of a disallowed macro `std::vec` - --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:16:5 - | -LL | vec![1, 2, 3]; - | ^^^^^^^^^^^^^ - | - = note: `-D clippy::disallowed-macros` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::disallowed_macros)]` - error: use of a disallowed macro `serde::Serialize` --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:18:14 | @@ -14,6 +5,8 @@ LL | #[derive(Serialize)] | ^^^^^^^^^ | = note: no serializing + = note: `-D clippy::disallowed-macros` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::disallowed_macros)]` error: use of a disallowed macro `macros::attr` --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:31:1 @@ -47,6 +40,12 @@ error: use of a disallowed macro `std::cfg` LL | cfg!(unix); | ^^^^^^^^^^ +error: use of a disallowed macro `std::vec` + --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:16:5 + | +LL | vec![1, 2, 3]; + | ^^^^^^^^^^^^^ + error: use of a disallowed macro `macros::expr` --> tests/ui-toml/disallowed_macros/disallowed_macros.rs:21:13 | diff --git a/tests/mir-opt/box_expr.rs b/tests/mir-opt/box_expr.rs index 41cd4ca57bfee..233946e713ce4 100644 --- a/tests/mir-opt/box_expr.rs +++ b/tests/mir-opt/box_expr.rs @@ -1,7 +1,7 @@ //@ test-mir-pass: ElaborateDrops //@ needs-unwind -#![feature(rustc_attrs, stmt_expr_attributes)] +#![feature(rustc_attrs, liballoc_internals)] // EMIT_MIR box_expr.main.ElaborateDrops.diff fn main() { @@ -17,8 +17,7 @@ fn main() { // CHECK: [[boxref:_.*]] = &mut [[box]]; // CHECK: as Drop>::drop(move [[boxref]]) - let x = #[rustc_box] - Box::new(S::new()); + let x = std::boxed::box_new(S::new()); drop(x); } diff --git a/tests/mir-opt/building/uniform_array_move_out.rs b/tests/mir-opt/building/uniform_array_move_out.rs index 0682891611ddb..aff5996d0b64b 100644 --- a/tests/mir-opt/building/uniform_array_move_out.rs +++ b/tests/mir-opt/building/uniform_array_move_out.rs @@ -1,25 +1,15 @@ // skip-filecheck -#![feature(stmt_expr_attributes, rustc_attrs)] +#![feature(liballoc_internals, rustc_attrs)] // EMIT_MIR uniform_array_move_out.move_out_from_end.built.after.mir fn move_out_from_end() { - let a = [ - #[rustc_box] - Box::new(1), - #[rustc_box] - Box::new(2), - ]; + let a = [std::boxed::box_new(1), std::boxed::box_new(2)]; let [.., _y] = a; } // EMIT_MIR uniform_array_move_out.move_out_by_subslice.built.after.mir fn move_out_by_subslice() { - let a = [ - #[rustc_box] - Box::new(1), - #[rustc_box] - Box::new(2), - ]; + let a = [std::boxed::box_new(1), std::boxed::box_new(2)]; let [_y @ ..] = a; } diff --git a/tests/mir-opt/const_prop/boxes.rs b/tests/mir-opt/const_prop/boxes.rs index f04db260e27f9..a192d6b4133a2 100644 --- a/tests/mir-opt/const_prop/boxes.rs +++ b/tests/mir-opt/const_prop/boxes.rs @@ -2,7 +2,7 @@ //@ compile-flags: -O // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -#![feature(rustc_attrs, stmt_expr_attributes)] +#![feature(rustc_attrs, liballoc_internals)] // Note: this test verifies that we, in fact, do not const prop `#[rustc_box]` @@ -13,7 +13,5 @@ fn main() { // CHECK: (*{{_.*}}) = const 42_i32; // CHECK: [[tmp:_.*]] = copy (*{{_.*}}); // CHECK: [[x]] = copy [[tmp]]; - let x = *(#[rustc_box] - Box::new(42)) - + 0; + let x = *(std::boxed::box_new(42)) + 0; } diff --git a/tests/mir-opt/issue_62289.rs b/tests/mir-opt/issue_62289.rs index 40e8352cff410..d020c2cedca01 100644 --- a/tests/mir-opt/issue_62289.rs +++ b/tests/mir-opt/issue_62289.rs @@ -3,14 +3,11 @@ // initializing it // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -#![feature(rustc_attrs)] +#![feature(rustc_attrs, liballoc_internals)] // EMIT_MIR issue_62289.test.ElaborateDrops.before.mir fn test() -> Option> { - Some( - #[rustc_box] - Box::new(None?), - ) + Some(std::boxed::box_new(None?)) } fn main() { diff --git a/tests/ui/attributes/rustc-box.rs b/tests/ui/attributes/rustc-box.rs deleted file mode 100644 index b3726fb38671b..0000000000000 --- a/tests/ui/attributes/rustc-box.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(rustc_attrs, stmt_expr_attributes)] - -fn foo(_: u32, _: u32) {} -fn bar(_: u32) {} - -fn main() { - #[rustc_box] - Box::new(1); // OK - #[rustc_box] - Box::pin(1); //~ ERROR `#[rustc_box]` attribute used incorrectly - #[rustc_box] - foo(1, 1); //~ ERROR `#[rustc_box]` attribute used incorrectly - #[rustc_box] - bar(1); //~ ERROR `#[rustc_box]` attribute used incorrectly - #[rustc_box] //~ ERROR `#[rustc_box]` attribute used incorrectly - #[rustfmt::skip] - Box::new(1); -} diff --git a/tests/ui/attributes/rustc-box.stderr b/tests/ui/attributes/rustc-box.stderr deleted file mode 100644 index 073a18c7d58ec..0000000000000 --- a/tests/ui/attributes/rustc-box.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error: `#[rustc_box]` attribute used incorrectly - --> $DIR/rustc-box.rs:10:5 - | -LL | Box::pin(1); - | ^^^^^^^^^^^ - | - = note: `#[rustc_box]` may only be applied to a `Box::new()` call - -error: `#[rustc_box]` attribute used incorrectly - --> $DIR/rustc-box.rs:12:5 - | -LL | foo(1, 1); - | ^^^^^^^^^ - | - = note: `#[rustc_box]` may only be applied to a `Box::new()` call - -error: `#[rustc_box]` attribute used incorrectly - --> $DIR/rustc-box.rs:14:5 - | -LL | bar(1); - | ^^^^^^ - | - = note: `#[rustc_box]` may only be applied to a `Box::new()` call - -error: `#[rustc_box]` attribute used incorrectly - --> $DIR/rustc-box.rs:15:5 - | -LL | #[rustc_box] - | ^^^^^^^^^^^^ - | - = note: no other attributes may be applied - -error: aborting due to 4 previous errors - diff --git a/tests/ui/coroutine/issue-105084.rs b/tests/ui/coroutine/issue-105084.rs index 0f6168ec58b02..cddee49901757 100644 --- a/tests/ui/coroutine/issue-105084.rs +++ b/tests/ui/coroutine/issue-105084.rs @@ -2,7 +2,7 @@ #![feature(coroutines)] #![feature(coroutine_clone)] #![feature(coroutine_trait)] -#![feature(rustc_attrs, stmt_expr_attributes)] +#![feature(rustc_attrs, stmt_expr_attributes, liballoc_internals)] use std::ops::Coroutine; use std::pin::Pin; @@ -19,8 +19,7 @@ fn main() { // - create a Box that is ignored for trait computations; // - compute fields (and yields); // - assign to `t`. - let t = #[rustc_box] - Box::new((5, yield)); + let t = std::boxed::box_new((5, yield)); drop(t); }; diff --git a/tests/ui/coroutine/issue-105084.stderr b/tests/ui/coroutine/issue-105084.stderr index 073f1fbea4c63..23c1fdc545922 100644 --- a/tests/ui/coroutine/issue-105084.stderr +++ b/tests/ui/coroutine/issue-105084.stderr @@ -1,5 +1,5 @@ error[E0382]: borrow of moved value: `g` - --> $DIR/issue-105084.rs:39:14 + --> $DIR/issue-105084.rs:38:14 | LL | let mut g = #[coroutine] | ----- move occurs because `g` has type `{coroutine@$DIR/issue-105084.rs:16:5: 16:7}`, which does not implement the `Copy` trait @@ -23,7 +23,7 @@ LL | let mut h = copy(g.clone()); | ++++++++ error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `{coroutine@$DIR/issue-105084.rs:16:5: 16:7}` - --> $DIR/issue-105084.rs:33:17 + --> $DIR/issue-105084.rs:32:17 | LL | || { | -- within this `{coroutine@$DIR/issue-105084.rs:16:5: 16:7}` @@ -32,13 +32,13 @@ LL | let mut h = copy(g); | ^^^^^^^ within `{coroutine@$DIR/issue-105084.rs:16:5: 16:7}`, the trait `Copy` is not implemented for `Box<(i32, ())>` | note: coroutine does not implement `Copy` as this value is used across a yield - --> $DIR/issue-105084.rs:23:22 + --> $DIR/issue-105084.rs:22:41 | -LL | Box::new((5, yield)); - | -------------^^^^^-- - | | | - | | yield occurs here, with `Box::new((5, yield))` maybe used later - | has type `Box<(i32, ())>` which does not implement `Copy` +LL | let t = std::boxed::box_new((5, yield)); + | ------------------------^^^^^-- + | | | + | | yield occurs here, with `std::boxed::box_new((5, yield))` maybe used later + | has type `Box<(i32, ())>` which does not implement `Copy` note: required by a bound in `copy` --> $DIR/issue-105084.rs:10:12 | diff --git a/tests/ui/lint/unused/unused-allocation.rs b/tests/ui/lint/unused/unused-allocation.rs index c1a6f5ceaf178..1d5727362ea64 100644 --- a/tests/ui/lint/unused/unused-allocation.rs +++ b/tests/ui/lint/unused/unused-allocation.rs @@ -1,7 +1,5 @@ -#![feature(rustc_attrs, stmt_expr_attributes)] #![deny(unused_allocation)] fn main() { - _ = (#[rustc_box] Box::new([1])).len(); //~ error: unnecessary allocation, use `&` instead _ = Box::new([1]).len(); //~ error: unnecessary allocation, use `&` instead } diff --git a/tests/ui/lint/unused/unused-allocation.stderr b/tests/ui/lint/unused/unused-allocation.stderr index c9ccfbd30e5d4..4487395e9083f 100644 --- a/tests/ui/lint/unused/unused-allocation.stderr +++ b/tests/ui/lint/unused/unused-allocation.stderr @@ -1,20 +1,14 @@ error: unnecessary allocation, use `&` instead - --> $DIR/unused-allocation.rs:5:9 + --> $DIR/unused-allocation.rs:4:9 | -LL | _ = (#[rustc_box] Box::new([1])).len(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | _ = Box::new([1]).len(); + | ^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/unused-allocation.rs:2:9 + --> $DIR/unused-allocation.rs:1:9 | LL | #![deny(unused_allocation)] | ^^^^^^^^^^^^^^^^^ -error: unnecessary allocation, use `&` instead - --> $DIR/unused-allocation.rs:6:9 - | -LL | _ = Box::new([1]).len(); - | ^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/macros/vec-macro-in-pattern.rs b/tests/ui/macros/vec-macro-in-pattern.rs index 26d7d4280fadb..9b9a1edf54c9e 100644 --- a/tests/ui/macros/vec-macro-in-pattern.rs +++ b/tests/ui/macros/vec-macro-in-pattern.rs @@ -4,7 +4,9 @@ fn main() { match Some(vec![42]) { - Some(vec![43]) => {} //~ ERROR expected pattern, found `#` + Some(vec![43]) => {} //~ ERROR expected a pattern, found a function call + //~| ERROR found associated function + //~| ERROR usage of qualified paths in this context is experimental _ => {} } } diff --git a/tests/ui/macros/vec-macro-in-pattern.stderr b/tests/ui/macros/vec-macro-in-pattern.stderr index f32a2cf8e4350..71ba0ea5ad4f5 100644 --- a/tests/ui/macros/vec-macro-in-pattern.stderr +++ b/tests/ui/macros/vec-macro-in-pattern.stderr @@ -1,14 +1,33 @@ -error: expected pattern, found `#` +error[E0532]: expected a pattern, found a function call + --> $DIR/vec-macro-in-pattern.rs:7:14 + | +LL | Some(vec![43]) => {} + | ^^^^^^^^ not a tuple struct or tuple variant + | + = note: function calls are not allowed in patterns: + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0658]: usage of qualified paths in this context is experimental --> $DIR/vec-macro-in-pattern.rs:7:14 | LL | Some(vec![43]) => {} | ^^^^^^^^ - | | - | expected pattern - | in this macro invocation - | this macro call doesn't expand to a pattern | + = note: see issue #86935 for more information + = help: add `#![feature(more_qualified_paths)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0164]: expected tuple struct or tuple variant, found associated function `<[_]>::into_vec` + --> $DIR/vec-macro-in-pattern.rs:7:14 + | +LL | Some(vec![43]) => {} + | ^^^^^^^^ `fn` calls are not allowed in patterns + | + = help: for more information, visit https://doc.rust-lang.org/book/ch19-00-patterns.html = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error +error: aborting due to 3 previous errors +Some errors have detailed explanations: E0164, E0532, E0658. +For more information about an error, try `rustc --explain E0164`. diff --git a/tests/ui/unpretty/box.rs b/tests/ui/unpretty/box.rs index 8972eccf3b8fd..83fdeff7a1796 100644 --- a/tests/ui/unpretty/box.rs +++ b/tests/ui/unpretty/box.rs @@ -1,9 +1,8 @@ -//@ compile-flags: -Zunpretty=hir +//@ compile-flags: -Zunpretty=thir-tree //@ check-pass -#![feature(stmt_expr_attributes, rustc_attrs)] +#![feature(liballoc_internals)] fn main() { - let _ = #[rustc_box] - Box::new(1); + let _ = std::boxed::box_new(1); } diff --git a/tests/ui/unpretty/box.stdout b/tests/ui/unpretty/box.stdout index e3b9b9ac20715..92155d0c73b9d 100644 --- a/tests/ui/unpretty/box.stdout +++ b/tests/ui/unpretty/box.stdout @@ -1,14 +1,90 @@ -//@ compile-flags: -Zunpretty=hir -//@ check-pass +DefId(0:3 ~ box[efb9]::main): +params: [ +] +body: + Expr { + ty: () + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(11)), backwards_incompatible: None } + span: $DIR/box.rs:6:11: 8:2 (#0) + kind: + Scope { + region_scope: Node(11) + lint_level: Explicit(HirId(DefId(0:3 ~ box[efb9]::main).11)) + value: + Expr { + ty: () + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(11)), backwards_incompatible: None } + span: $DIR/box.rs:6:11: 8:2 (#0) + kind: + Block { + targeted_by_break: false + span: $DIR/box.rs:6:11: 8:2 (#0) + region_scope: Node(1) + safety_mode: Safe + stmts: [ + Stmt { + kind: Let { + remainder_scope: Remainder { block: 1, first_statement_index: 0} + init_scope: Node(2) + pattern: + Pat: { + ty: std::boxed::Box + span: $DIR/box.rs:7:9: 7:10 (#0) + kind: PatKind { + Wild + } + } + , + initializer: Some( + Expr { + ty: std::boxed::Box + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(2)), backwards_incompatible: None } + span: $DIR/box.rs:7:13: 7:35 (#0) + kind: + Scope { + region_scope: Node(3) + lint_level: Explicit(HirId(DefId(0:3 ~ box[efb9]::main).3)) + value: + Expr { + ty: std::boxed::Box + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(2)), backwards_incompatible: None } + span: $DIR/box.rs:7:13: 7:35 (#0) + kind: + Box { + Expr { + ty: i32 + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(2)), backwards_incompatible: None } + span: $DIR/box.rs:7:33: 7:34 (#0) + kind: + Scope { + region_scope: Node(8) + lint_level: Explicit(HirId(DefId(0:3 ~ box[efb9]::main).8)) + value: + Expr { + ty: i32 + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(2)), backwards_incompatible: None } + span: $DIR/box.rs:7:33: 7:34 (#0) + kind: + Literal( lit: Spanned { node: Int(Pu128(1), Unsuffixed), span: $DIR/box.rs:7:33: 7:34 (#0) }, neg: false) + + } + } + } + } + } + } + } + ) + else_block: None + lint_level: Explicit(HirId(DefId(0:3 ~ box[efb9]::main).9)) + span: $DIR/box.rs:7:5: 7:35 (#0) + } + } + ] + expr: [] + } + } + } + } -#![feature(stmt_expr_attributes, rustc_attrs)] -#[prelude_import] -use ::std::prelude::rust_2015::*; -#[macro_use] -extern crate std; -fn main() { - let _ = - #[rustc_box] - Box::new(1); -} From 0c82a137f7f22552267bbb81a8237c5328c8feb7 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 3 Jan 2025 13:19:55 +0100 Subject: [PATCH 2/2] Remove `#[rustc_box]` usage in the `vec![]` macro --- library/alloc/src/macros.rs | 4 +- .../min_const_fn/bad_const_fn_body_ice.rs | 4 +- .../min_const_fn/bad_const_fn_body_ice.stderr | 8 ++-- tests/ui/error-codes/E0010-teach.rs | 4 +- tests/ui/error-codes/E0010-teach.stderr | 9 ++-- tests/ui/error-codes/E0010.rs | 4 +- tests/ui/error-codes/E0010.stderr | 8 ++-- tests/ui/macros/vec-macro-in-pattern.rs | 2 +- tests/ui/macros/vec-macro-in-pattern.stderr | 20 ++++---- tests/ui/statics/check-values-constraints.rs | 14 +++--- .../statics/check-values-constraints.stderr | 46 ++++++++++++------- 11 files changed, 67 insertions(+), 56 deletions(-) diff --git a/library/alloc/src/macros.rs b/library/alloc/src/macros.rs index 6ee3907cc8ea2..3ddf2905ab692 100644 --- a/library/alloc/src/macros.rs +++ b/library/alloc/src/macros.rs @@ -48,9 +48,7 @@ macro_rules! vec { ); ($($x:expr),+ $(,)?) => ( <[_]>::into_vec( - // Using the intrinsic produces a dramatic improvement in compile - // time when constructing arrays with many elements. - $crate::boxed::box_new([$($x),+]) + $crate::boxed::Box::new([$($x),+]) ) ); } diff --git a/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.rs b/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.rs index 6a6b0e666e1c3..74e0a36560b08 100644 --- a/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.rs +++ b/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.rs @@ -1,7 +1,7 @@ const fn foo(a: i32) -> Vec { vec![1, 2, 3] - //~^ ERROR allocations are not allowed - //~| ERROR cannot call non-const method + //~^ ERROR cannot call non-const + //~| ERROR cannot call non-const } fn main() {} diff --git a/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr b/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr index 8e52a7aa35e1e..fd5c489e454cc 100644 --- a/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr +++ b/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr @@ -1,9 +1,10 @@ -error[E0010]: allocations are not allowed in constant functions +error[E0015]: cannot call non-const associated function `Box::<[i32; 3]>::new` in constant functions --> $DIR/bad_const_fn_body_ice.rs:2:5 | LL | vec![1, 2, 3] - | ^^^^^^^^^^^^^ allocation not allowed in constant functions + | ^^^^^^^^^^^^^ | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const method `slice::::into_vec::` in constant functions @@ -17,5 +18,4 @@ LL | vec![1, 2, 3] error: aborting due to 2 previous errors -Some errors have detailed explanations: E0010, E0015. -For more information about an error, try `rustc --explain E0010`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/error-codes/E0010-teach.rs b/tests/ui/error-codes/E0010-teach.rs index 0eef24783873c..5ea526204f8d2 100644 --- a/tests/ui/error-codes/E0010-teach.rs +++ b/tests/ui/error-codes/E0010-teach.rs @@ -2,6 +2,6 @@ #![allow(warnings)] -const CON: Vec = vec![1, 2, 3]; //~ ERROR E0010 -//~| ERROR cannot call non-const method +const CON: Vec = vec![1, 2, 3]; //~ ERROR cannot call non-const +//~| ERROR cannot call non-const fn main() {} diff --git a/tests/ui/error-codes/E0010-teach.stderr b/tests/ui/error-codes/E0010-teach.stderr index 82bbe01aef792..fc4dd3526774b 100644 --- a/tests/ui/error-codes/E0010-teach.stderr +++ b/tests/ui/error-codes/E0010-teach.stderr @@ -1,10 +1,10 @@ -error[E0010]: allocations are not allowed in constants +error[E0015]: cannot call non-const associated function `Box::<[i32; 3]>::new` in constants --> $DIR/E0010-teach.rs:5:23 | LL | const CON: Vec = vec![1, 2, 3]; - | ^^^^^^^^^^^^^ allocation not allowed in constants + | ^^^^^^^^^^^^^ | - = note: The runtime heap is not yet available at compile-time, so no runtime heap allocations can be created. + = note: calls in constants are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const method `slice::::into_vec::` in constants @@ -18,5 +18,4 @@ LL | const CON: Vec = vec![1, 2, 3]; error: aborting due to 2 previous errors -Some errors have detailed explanations: E0010, E0015. -For more information about an error, try `rustc --explain E0010`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/error-codes/E0010.rs b/tests/ui/error-codes/E0010.rs index edb96714dd320..966badfce21f4 100644 --- a/tests/ui/error-codes/E0010.rs +++ b/tests/ui/error-codes/E0010.rs @@ -1,5 +1,5 @@ #![allow(warnings)] -const CON: Vec = vec![1, 2, 3]; //~ ERROR E0010 -//~| ERROR cannot call non-const method +const CON: Vec = vec![1, 2, 3]; //~ ERROR cannot call non-const +//~| ERROR cannot call non-const fn main() {} diff --git a/tests/ui/error-codes/E0010.stderr b/tests/ui/error-codes/E0010.stderr index 87b722b5f6566..e4d4f1498c645 100644 --- a/tests/ui/error-codes/E0010.stderr +++ b/tests/ui/error-codes/E0010.stderr @@ -1,9 +1,10 @@ -error[E0010]: allocations are not allowed in constants +error[E0015]: cannot call non-const associated function `Box::<[i32; 3]>::new` in constants --> $DIR/E0010.rs:3:23 | LL | const CON: Vec = vec![1, 2, 3]; - | ^^^^^^^^^^^^^ allocation not allowed in constants + | ^^^^^^^^^^^^^ | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const method `slice::::into_vec::` in constants @@ -17,5 +18,4 @@ LL | const CON: Vec = vec![1, 2, 3]; error: aborting due to 2 previous errors -Some errors have detailed explanations: E0010, E0015. -For more information about an error, try `rustc --explain E0010`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/macros/vec-macro-in-pattern.rs b/tests/ui/macros/vec-macro-in-pattern.rs index 9b9a1edf54c9e..1a89944f20329 100644 --- a/tests/ui/macros/vec-macro-in-pattern.rs +++ b/tests/ui/macros/vec-macro-in-pattern.rs @@ -4,7 +4,7 @@ fn main() { match Some(vec![42]) { - Some(vec![43]) => {} //~ ERROR expected a pattern, found a function call + Some(vec![43]) => {} //~ ERROR expected tuple struct or tuple variant, found associated function //~| ERROR found associated function //~| ERROR usage of qualified paths in this context is experimental _ => {} diff --git a/tests/ui/macros/vec-macro-in-pattern.stderr b/tests/ui/macros/vec-macro-in-pattern.stderr index 71ba0ea5ad4f5..7878941c112fd 100644 --- a/tests/ui/macros/vec-macro-in-pattern.stderr +++ b/tests/ui/macros/vec-macro-in-pattern.stderr @@ -1,12 +1,3 @@ -error[E0532]: expected a pattern, found a function call - --> $DIR/vec-macro-in-pattern.rs:7:14 - | -LL | Some(vec![43]) => {} - | ^^^^^^^^ not a tuple struct or tuple variant - | - = note: function calls are not allowed in patterns: - = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) - error[E0658]: usage of qualified paths in this context is experimental --> $DIR/vec-macro-in-pattern.rs:7:14 | @@ -27,7 +18,16 @@ LL | Some(vec![43]) => {} = help: for more information, visit https://doc.rust-lang.org/book/ch19-00-patterns.html = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) +error[E0164]: expected tuple struct or tuple variant, found associated function `::alloc::boxed::Box::new` + --> $DIR/vec-macro-in-pattern.rs:7:14 + | +LL | Some(vec![43]) => {} + | ^^^^^^^^ `fn` calls are not allowed in patterns + | + = help: for more information, visit https://doc.rust-lang.org/book/ch19-00-patterns.html + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + error: aborting due to 3 previous errors -Some errors have detailed explanations: E0164, E0532, E0658. +Some errors have detailed explanations: E0164, E0658. For more information about an error, try `rustc --explain E0164`. diff --git a/tests/ui/statics/check-values-constraints.rs b/tests/ui/statics/check-values-constraints.rs index 9df76b5c1497f..53d1d5a501e28 100644 --- a/tests/ui/statics/check-values-constraints.rs +++ b/tests/ui/statics/check-values-constraints.rs @@ -79,7 +79,7 @@ static STATIC10: UnsafeStruct = UnsafeStruct; struct MyOwned; static STATIC11: Vec = vec![MyOwned]; -//~^ ERROR allocations are not allowed in statics +//~^ ERROR cannot call non-const //~^^ ERROR cannot call non-const static mut STATIC12: UnsafeStruct = UnsafeStruct; @@ -93,28 +93,28 @@ static mut STATIC14: SafeStruct = SafeStruct { }; static STATIC15: &'static [Vec] = &[ - vec![MyOwned], //~ ERROR allocations are not allowed in statics + vec![MyOwned], //~ ERROR cannot call non-const //~^ ERROR cannot call non-const - vec![MyOwned], //~ ERROR allocations are not allowed in statics + vec![MyOwned], //~ ERROR cannot call non-const //~^ ERROR cannot call non-const ]; static STATIC16: (&'static Vec, &'static Vec) = ( - &vec![MyOwned], //~ ERROR allocations are not allowed in statics + &vec![MyOwned], //~ ERROR cannot call non-const //~^ ERROR cannot call non-const - &vec![MyOwned], //~ ERROR allocations are not allowed in statics + &vec![MyOwned], //~ ERROR cannot call non-const //~^ ERROR cannot call non-const ); static mut STATIC17: SafeEnum = SafeEnum::Variant1; static STATIC19: Vec = vec![3]; -//~^ ERROR allocations are not allowed in statics +//~^ ERROR cannot call non-const //~^^ ERROR cannot call non-const pub fn main() { let y = { - static x: Vec = vec![3]; //~ ERROR allocations are not allowed in statics + static x: Vec = vec![3]; //~ ERROR cannot call non-const //~^ ERROR cannot call non-const x //~^ ERROR cannot move out of static diff --git a/tests/ui/statics/check-values-constraints.stderr b/tests/ui/statics/check-values-constraints.stderr index eb2d37d297e9f..453de7159add4 100644 --- a/tests/ui/statics/check-values-constraints.stderr +++ b/tests/ui/statics/check-values-constraints.stderr @@ -11,12 +11,14 @@ LL | | } LL | }; | - value is dropped here -error[E0010]: allocations are not allowed in statics +error[E0015]: cannot call non-const associated function `Box::<[MyOwned; 1]>::new` in statics --> $DIR/check-values-constraints.rs:81:33 | LL | static STATIC11: Vec = vec![MyOwned]; - | ^^^^^^^^^^^^^ allocation not allowed in statics + | ^^^^^^^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const method `slice::::into_vec::` in statics @@ -38,12 +40,14 @@ LL | field2: SafeEnum::Variant4("str".to_string()), = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` -error[E0010]: allocations are not allowed in statics +error[E0015]: cannot call non-const associated function `Box::<[MyOwned; 1]>::new` in statics --> $DIR/check-values-constraints.rs:96:5 | LL | vec![MyOwned], - | ^^^^^^^^^^^^^ allocation not allowed in statics + | ^^^^^^^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const method `slice::::into_vec::` in statics @@ -56,12 +60,14 @@ LL | vec![MyOwned], = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0010]: allocations are not allowed in statics +error[E0015]: cannot call non-const associated function `Box::<[MyOwned; 1]>::new` in statics --> $DIR/check-values-constraints.rs:98:5 | LL | vec![MyOwned], - | ^^^^^^^^^^^^^ allocation not allowed in statics + | ^^^^^^^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const method `slice::::into_vec::` in statics @@ -74,12 +80,14 @@ LL | vec![MyOwned], = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0010]: allocations are not allowed in statics +error[E0015]: cannot call non-const associated function `Box::<[MyOwned; 1]>::new` in statics --> $DIR/check-values-constraints.rs:103:6 | LL | &vec![MyOwned], - | ^^^^^^^^^^^^^ allocation not allowed in statics + | ^^^^^^^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const method `slice::::into_vec::` in statics @@ -92,12 +100,14 @@ LL | &vec![MyOwned], = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0010]: allocations are not allowed in statics +error[E0015]: cannot call non-const associated function `Box::<[MyOwned; 1]>::new` in statics --> $DIR/check-values-constraints.rs:105:6 | LL | &vec![MyOwned], - | ^^^^^^^^^^^^^ allocation not allowed in statics + | ^^^^^^^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const method `slice::::into_vec::` in statics @@ -110,12 +120,14 @@ LL | &vec![MyOwned], = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0010]: allocations are not allowed in statics +error[E0015]: cannot call non-const associated function `Box::<[isize; 1]>::new` in statics --> $DIR/check-values-constraints.rs:111:31 | LL | static STATIC19: Vec = vec![3]; - | ^^^^^^^ allocation not allowed in statics + | ^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const method `slice::::into_vec::` in statics @@ -128,12 +140,14 @@ LL | static STATIC19: Vec = vec![3]; = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0010]: allocations are not allowed in statics +error[E0015]: cannot call non-const associated function `Box::<[isize; 1]>::new` in statics --> $DIR/check-values-constraints.rs:117:32 | LL | static x: Vec = vec![3]; - | ^^^^^^^ allocation not allowed in statics + | ^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const method `slice::::into_vec::` in statics @@ -163,5 +177,5 @@ LL | x.clone() error: aborting due to 17 previous errors -Some errors have detailed explanations: E0010, E0015, E0493, E0507. -For more information about an error, try `rustc --explain E0010`. +Some errors have detailed explanations: E0015, E0493, E0507. +For more information about an error, try `rustc --explain E0015`.