diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 489ef5e8fe796..00bb4d6557906 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 747431e5312aa..8aa95d1c1d516 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/Cargo.lock b/library/Cargo.lock index 40edd2c211cd3..207c744ee2248 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -4,21 +4,21 @@ version = 4 [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "compiler_builtins", - "gimli 0.29.0", + "gimli", "rustc-std-workspace-alloc", "rustc-std-workspace-core", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" dependencies = [ "compiler_builtins", "rustc-std-workspace-core", @@ -111,17 +111,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "gimli" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - [[package]] name = "gimli" version = "0.31.1" @@ -177,11 +166,11 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ - "adler", + "adler2", "compiler_builtins", "rustc-std-workspace-alloc", "rustc-std-workspace-core", @@ -408,7 +397,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51f06a05848f650946acef3bf525fe96612226b61f74ae23ffa4e98bfbb8ab3c" dependencies = [ "compiler_builtins", - "gimli 0.31.1", + "gimli", "rustc-std-workspace-core", ] 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/library/backtrace b/library/backtrace index 4d7906bb24ae9..f8cc6ac9acc4e 160000 --- a/library/backtrace +++ b/library/backtrace @@ -1 +1 @@ -Subproject commit 4d7906bb24ae91ee6587127020d360f5298f9e7e +Subproject commit f8cc6ac9acc4e663ecd96f9bcf1ff4542636d1b9 diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 6380c941e6ab5..e7f7f38cb4154 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -30,8 +30,8 @@ std_detect = { path = "../stdarch/crates/std_detect", default-features = false, rustc-demangle = { version = "0.1.24", features = ['rustc-dep-of-std'] } [target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies] -miniz_oxide = { version = "0.7.0", optional = true, default-features = false } -addr2line = { version = "0.22.0", optional = true, default-features = false } +miniz_oxide = { version = "0.8.0", optional = true, default-features = false } +addr2line = { version = "0.24.0", optional = true, default-features = false } [target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies] libc = { version = "0.2.169", default-features = false, features = [ diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index c4780cc56b2d3..3657d9b31121e 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -440,7 +440,7 @@ fn lld_flag_no_threads(builder: &Builder<'_>, lld_mode: LldMode, is_windows: boo } pub fn dir_is_empty(dir: &Path) -> bool { - t!(std::fs::read_dir(dir)).next().is_none() + t!(std::fs::read_dir(dir), dir).next().is_none() } /// Extract the beta revision from the full version string. 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/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index d00d5a9b4da58..912cbb668b05f 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -18,7 +18,7 @@ const LICENSES: &[&str] = &[ // tidy-alphabetical-start "(MIT OR Apache-2.0) AND Unicode-3.0", // unicode_ident (1.0.14) "(MIT OR Apache-2.0) AND Unicode-DFS-2016", // unicode_ident (1.0.12) - "0BSD OR MIT OR Apache-2.0", // adler license + "0BSD OR MIT OR Apache-2.0", // adler2 license "0BSD", "Apache-2.0 / MIT", "Apache-2.0 OR ISC OR MIT", @@ -462,7 +462,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ const PERMITTED_STDLIB_DEPENDENCIES: &[&str] = &[ // tidy-alphabetical-start "addr2line", - "adler", + "adler2", "allocator-api2", "cc", "cfg-if", diff --git a/tests/assembly/targets/targets-elf.rs b/tests/assembly/targets/targets-elf.rs index 7d50647bed18e..59d27ed649c0f 100644 --- a/tests/assembly/targets/targets-elf.rs +++ b/tests/assembly/targets/targets-elf.rs @@ -676,6 +676,8 @@ #[lang = "sized"] trait Sized {} +// Force linkage to ensure code is actually generated +#[no_mangle] pub fn test() -> u8 { 42 } diff --git a/tests/assembly/targets/targets-macho.rs b/tests/assembly/targets/targets-macho.rs index 8095ae9029b75..25e9059afeb18 100644 --- a/tests/assembly/targets/targets-macho.rs +++ b/tests/assembly/targets/targets-macho.rs @@ -83,6 +83,8 @@ #[lang = "sized"] trait Sized {} +// Force linkage to ensure code is actually generated +#[no_mangle] pub fn test() -> u8 { 42 } diff --git a/tests/crashes/134336.rs b/tests/crashes/134336.rs new file mode 100644 index 0000000000000..14b88e14f04f0 --- /dev/null +++ b/tests/crashes/134336.rs @@ -0,0 +1,11 @@ +//@ known-bug: #134336 +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +trait Tr { + fn f(); +} + +fn g() { + become T::f(); +} diff --git a/tests/crashes/134355.rs b/tests/crashes/134355.rs new file mode 100644 index 0000000000000..b662341e6b1b3 --- /dev/null +++ b/tests/crashes/134355.rs @@ -0,0 +1,6 @@ +//@ known-bug: #134355 + +//@compile-flags: --crate-type=lib +fn digit() -> str { + return { i32::MIN }; +} diff --git a/tests/crashes/134479.rs b/tests/crashes/134479.rs new file mode 100644 index 0000000000000..0e4ddb2bfd56d --- /dev/null +++ b/tests/crashes/134479.rs @@ -0,0 +1,24 @@ +//@ known-bug: #134479 +//@ compile-flags: -Csymbol-mangling-version=v0 -Cdebuginfo=1 + +#![feature(generic_const_exprs)] + +fn main() { + test::<2>(); +} + +struct Test; + +fn new() -> Test +where + [(); N * 1]: Sized, +{ + Test +} + +fn test() -> Test<{ N - 1 }> +where + [(); (N - 1) * 1]: Sized, +{ + new() +} diff --git a/tests/crashes/134587.rs b/tests/crashes/134587.rs new file mode 100644 index 0000000000000..6d4441012e062 --- /dev/null +++ b/tests/crashes/134587.rs @@ -0,0 +1,27 @@ +//@ known-bug: #134587 + +use std::ops::Add; + +pub fn foo(slf: *const T) +where + *const T: Add, +{ + slf + slf; +} + +pub fn foo2(slf: *const T) +where + *const T: Add, +{ + slf + 1_u8; +} + + +pub trait TimesTwo + where *const Self: Add<*const Self>, +{ + extern "C" fn t2_ptr(slf: *const Self) + -> <*const Self as Add<*const Self>>::Output { + slf + slf + } +} diff --git a/tests/crashes/134615.rs b/tests/crashes/134615.rs new file mode 100644 index 0000000000000..d7aa51389a0d7 --- /dev/null +++ b/tests/crashes/134615.rs @@ -0,0 +1,16 @@ +//@ known-bug: #134615 + +#![feature(generic_const_exprs)] + +trait Trait { + const CONST: usize; +} + +fn f() +where + for<'a> (): Trait, + [(); <() as Trait>::CONST]:, +{ +} + +pub fn main() {} diff --git a/tests/crashes/134641.rs b/tests/crashes/134641.rs new file mode 100644 index 0000000000000..e3e5ab69287b7 --- /dev/null +++ b/tests/crashes/134641.rs @@ -0,0 +1,13 @@ +//@ known-bug: #134641 +#![feature(associated_const_equality)] + +pub trait IsVoid { + const IS_VOID: bool; +} +impl IsVoid for () { + const IS_VOID: bool = true; +} + +pub trait Maybe {} +impl Maybe for () {} +impl Maybe for () where (): IsVoid {} diff --git a/tests/crashes/134654.rs b/tests/crashes/134654.rs new file mode 100644 index 0000000000000..8a8d18359e96f --- /dev/null +++ b/tests/crashes/134654.rs @@ -0,0 +1,12 @@ +//@ known-bug: #134654 +//@ compile-flags: -Zmir-enable-passes=+GVN -Zmir-enable-passes=+Inline -Zvalidate-mir +//@ only-x86_64 + +fn function_with_bytes() -> &'static [u8] { + BYTES +} + +fn main() { + function_with_bytes::() == &[]; +} diff --git a/tests/crashes/134838.rs b/tests/crashes/134838.rs new file mode 100644 index 0000000000000..ac8af09b31bbd --- /dev/null +++ b/tests/crashes/134838.rs @@ -0,0 +1,14 @@ +//@ known-bug: #134838 +#![feature(type_ascription)] +#![allow(dead_code)] + +struct Ty(()); + +fn mk() -> impl Sized { + if false { + let _ = type_ascribe!(mk(), Ty).0; + } + Ty(()) +} + +fn main() {} diff --git a/tests/crashes/134905.rs b/tests/crashes/134905.rs new file mode 100644 index 0000000000000..9f0f0f4b3f227 --- /dev/null +++ b/tests/crashes/134905.rs @@ -0,0 +1,16 @@ +//@ known-bug: #134905 + +trait Iterate<'a> { + type Ty: Valid; +} +impl<'a, T> Iterate<'a> for T +where + T: Check, +{ + default type Ty = (); +} + +trait Check {} +impl<'a, T> Eq for T where >::Ty: Valid {} + +trait Valid {} diff --git a/tests/crashes/135020.rs b/tests/crashes/135020.rs new file mode 100644 index 0000000000000..b44056eb3af30 --- /dev/null +++ b/tests/crashes/135020.rs @@ -0,0 +1,11 @@ +//@ known-bug: #135020 + +pub fn problem_thingy(items: &mut impl Iterator) { + let mut peeker = items.peekable(); + match peeker.peek() { + Some(_) => (), + None => return (), + } +} + +pub fn main() {} diff --git a/tests/crashes/135039.rs b/tests/crashes/135039.rs new file mode 100644 index 0000000000000..c4c5336fd4fdd --- /dev/null +++ b/tests/crashes/135039.rs @@ -0,0 +1,34 @@ +//@ known-bug: #135039 +//@ edition:2021 + +pub type UserId = <::User as AuthUser>::Id; + +pub trait AuthUser { + type Id; +} + +pub trait AuthnBackend { + type User: AuthUser; +} + +pub struct AuthSession { + user: Option, + data: Option>, +} + +pub trait Authz: Sized { + type AuthnBackend: AuthnBackend; +} + +pub trait Query { + type Output; + async fn run(&self) -> Result; +} + +pub async fn run_query + 'static>( + auth: AuthSession, + query: Q, +) -> Result { + let user = auth.user; + query.run().await +} 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); -}