about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-01-02 21:22:42 +0100
committerRalf Jung <post@ralfj.de>2025-01-03 12:01:31 +0100
commitac9cb908ac4301dfc25e7a2edee574320022ae2c (patch)
tree5b56b884318fc58bf28c82a38d0a2e7efd9d9207
parentbf6f8a4d328f7f3b0f6ea8205ad28591cc11aafd (diff)
downloadrust-ac9cb908ac4301dfc25e7a2edee574320022ae2c.tar.gz
rust-ac9cb908ac4301dfc25e7a2edee574320022ae2c.zip
turn rustc_box into an intrinsic
-rw-r--r--compiler/rustc_feature/src/builtin_attrs.rs5
-rw-r--r--compiler/rustc_hir_analysis/src/check/intrinsic.rs3
-rw-r--r--compiler/rustc_mir_build/messages.ftl5
-rw-r--r--compiler/rustc_mir_build/src/errors.rs19
-rw-r--r--compiler/rustc_mir_build/src/thir/cx/expr.rs57
-rw-r--r--compiler/rustc_span/src/symbol.rs1
-rw-r--r--library/alloc/src/alloc.rs2
-rw-r--r--library/alloc/src/boxed.rs24
-rw-r--r--library/alloc/src/lib.rs1
-rw-r--r--library/alloc/src/macros.rs5
-rw-r--r--src/tools/clippy/tests/ui-toml/disallowed_macros/disallowed_macros.stderr17
-rw-r--r--tests/mir-opt/box_expr.rs5
-rw-r--r--tests/mir-opt/building/uniform_array_move_out.rs16
-rw-r--r--tests/mir-opt/const_prop/boxes.rs6
-rw-r--r--tests/mir-opt/issue_62289.rs7
-rw-r--r--tests/ui/attributes/rustc-box.rs18
-rw-r--r--tests/ui/attributes/rustc-box.stderr34
-rw-r--r--tests/ui/coroutine/issue-105084.rs5
-rw-r--r--tests/ui/coroutine/issue-105084.stderr16
-rw-r--r--tests/ui/lint/unused/unused-allocation.rs2
-rw-r--r--tests/ui/lint/unused/unused-allocation.stderr16
-rw-r--r--tests/ui/macros/vec-macro-in-pattern.rs4
-rw-r--r--tests/ui/macros/vec-macro-in-pattern.stderr31
-rw-r--r--tests/ui/unpretty/box.rs7
-rw-r--r--tests/ui/unpretty/box.stdout100
25 files changed, 198 insertions, 208 deletions
diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs
index 4112ae80980..71941c8a206 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 fd78bf3e8fc..5595cc3280f 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 edba247c7b0..5d61a9d1e75 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 be5f8bdffb5..790d56860d2 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 0338ac674e5..9cdf08d749b 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 4ecc4201f89..bdfbfb1e38d 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 ae34fc65326..e9b7f985667 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 05e5d712a27..0f66217b5cb 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<T>, A);
 
+/// Constructs a `Box<T>` 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 <expr>` expressions.
+#[cfg(not(bootstrap))]
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+#[unstable(feature = "liballoc_internals", issue = "none")]
+pub fn box_new<T>(_x: T) -> Box<T> {
+    unreachable!()
+}
+
+/// Transition function for the next bootstrap bump.
+#[cfg(bootstrap)]
+#[unstable(feature = "liballoc_internals", issue = "none")]
+#[inline(always)]
+pub fn box_new<T>(x: T) -> Box<T> {
+    #[rustc_box]
+    Box::new(x)
+}
+
 impl<T> Box<T> {
     /// Allocates memory on the heap and then places `x` into it.
     ///
@@ -250,8 +271,7 @@ impl<T> Box<T> {
     #[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 40759cb0ba8..aff90f5abb3 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 8c6a367869c..6ee3907cc8e 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 2e3386628b4..6a6c6168a1f 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 41cd4ca57bf..233946e713c 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:   <Box<S> 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 0682891611d..aff5996d0b6 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 f04db260e27..a192d6b4133 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 40e8352cff4..d020c2cedca 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<Box<u32>> {
-    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 b3726fb3867..00000000000
--- 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 073a18c7d58..00000000000
--- 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 0f6168ec58b..cddee499017 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 073f1fbea4c..23c1fdc5459 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 c1a6f5ceaf1..1d5727362ea 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 c9ccfbd30e5..4487395e908 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 26d7d4280fa..9b9a1edf54c 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 f32a2cf8e43..71ba0ea5ad4 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: <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[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 <https://github.com/rust-lang/rust/issues/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 8972eccf3b8..83fdeff7a17 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 e3b9b9ac207..92155d0c73b 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<i32, std::alloc::Global>
+                                                    span: $DIR/box.rs:7:9: 7:10 (#0)
+                                                    kind: PatKind {
+                                                        Wild
+                                                    }
+                                                }
+                                            ,
+                                            initializer: Some(
+                                                Expr {
+                                                    ty: std::boxed::Box<i32, std::alloc::Global>
+                                                    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<i32, std::alloc::Global>
+                                                                    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);
-}