Auto merge of #135101 - workingjubilee:rollup-owp3czl, r=workingjubilee

Rollup of 6 pull requests

Successful merges:

 - #135046 (turn rustc_box into an intrinsic)
 - #135061 (crashes: add latest batch of tests)
 - #135070 (std: sync to dep versions of backtrace)
 - #135088 (Force code generation in assembly generation smoke-tests)
 - #135091 (Bump backtrace to 0.3.75)
 - #135094 (bootstrap: If dir_is_empty fails, show the non-existent directory path)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-01-04 21:11:28 +00:00
commit 1891c28669
43 changed files with 402 additions and 235 deletions

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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> {

View File

@ -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()

View File

@ -1696,7 +1696,6 @@ symbols! {
rustc_as_ptr,
rustc_attrs,
rustc_autodiff,
rustc_box,
rustc_builtin_macro,
rustc_capture_analysis,
rustc_clean,

View File

@ -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",
]

View File

@ -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]

View File

@ -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.

View File

@ -168,6 +168,7 @@
#![feature(dropck_eyepatch)]
#![feature(fundamental)]
#![feature(hashmap_internals)]
#![feature(intrinsics)]
#![feature(lang_items)]
#![feature(min_specialization)]
#![feature(multiple_supertrait_upcastable)]

View File

@ -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),+])
)
);
}

@ -1 +1 @@
Subproject commit 4d7906bb24ae91ee6587127020d360f5298f9e7e
Subproject commit f8cc6ac9acc4e663ecd96f9bcf1ff4542636d1b9

View File

@ -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 = [

View File

@ -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.

View File

@ -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
|

View File

@ -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",

View File

@ -676,6 +676,8 @@
#[lang = "sized"]
trait Sized {}
// Force linkage to ensure code is actually generated
#[no_mangle]
pub fn test() -> u8 {
42
}

View File

@ -83,6 +83,8 @@
#[lang = "sized"]
trait Sized {}
// Force linkage to ensure code is actually generated
#[no_mangle]
pub fn test() -> u8 {
42
}

11
tests/crashes/134336.rs Normal file
View File

@ -0,0 +1,11 @@
//@ known-bug: #134336
#![expect(incomplete_features)]
#![feature(explicit_tail_calls)]
trait Tr {
fn f();
}
fn g<T: Tr>() {
become T::f();
}

6
tests/crashes/134355.rs Normal file
View File

@ -0,0 +1,6 @@
//@ known-bug: #134355
//@compile-flags: --crate-type=lib
fn digit() -> str {
return { i32::MIN };
}

24
tests/crashes/134479.rs Normal file
View File

@ -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<const N: usize>;
fn new<const N: usize>() -> Test<N>
where
[(); N * 1]: Sized,
{
Test
}
fn test<const N: usize>() -> Test<{ N - 1 }>
where
[(); (N - 1) * 1]: Sized,
{
new()
}

27
tests/crashes/134587.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #134587
use std::ops::Add;
pub fn foo<T>(slf: *const T)
where
*const T: Add,
{
slf + slf;
}
pub fn foo2<T>(slf: *const T)
where
*const T: Add<u8>,
{
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
}
}

16
tests/crashes/134615.rs Normal file
View File

@ -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() {}

13
tests/crashes/134641.rs Normal file
View File

@ -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<IS_VOID = true> {}

12
tests/crashes/134654.rs Normal file
View File

@ -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<const BYTES:
&'static [u8; 0xa9008fb6c9d81e42_0e25730562a601c8_u128]>() -> &'static [u8] {
BYTES
}
fn main() {
function_with_bytes::<b"aa">() == &[];
}

14
tests/crashes/134838.rs Normal file
View File

@ -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() {}

16
tests/crashes/134905.rs Normal file
View File

@ -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 <T as Iterate<'a>>::Ty: Valid {}
trait Valid {}

11
tests/crashes/135020.rs Normal file
View File

@ -0,0 +1,11 @@
//@ known-bug: #135020
pub fn problem_thingy(items: &mut impl Iterator<Item = str>) {
let mut peeker = items.peekable();
match peeker.peek() {
Some(_) => (),
None => return (),
}
}
pub fn main() {}

34
tests/crashes/135039.rs Normal file
View File

@ -0,0 +1,34 @@
//@ known-bug: #135039
//@ edition:2021
pub type UserId<Backend> = <<Backend as AuthnBackend>::User as AuthUser>::Id;
pub trait AuthUser {
type Id;
}
pub trait AuthnBackend {
type User: AuthUser;
}
pub struct AuthSession<Backend: AuthnBackend> {
user: Option<Backend::User>,
data: Option<UserId<Backend>>,
}
pub trait Authz: Sized {
type AuthnBackend: AuthnBackend<User = Self>;
}
pub trait Query<User: Authz> {
type Output;
async fn run(&self) -> Result<Self::Output, ()>;
}
pub async fn run_query<User: Authz, Q: Query<User> + 'static>(
auth: AuthSession<User::AuthnBackend>,
query: Q,
) -> Result<Q::Output, ()> {
let user = auth.user;
query.run().await
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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() {

View File

@ -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);
}

View File

@ -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

View File

@ -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);
};

View File

@ -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
|

View File

@ -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
}

View File

@ -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

View File

@ -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
_ => {}
}
}

View File

@ -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: aborting due to 1 previous error
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 3 previous errors
Some errors have detailed explanations: E0164, E0532, E0658.
For more information about an error, try `rustc --explain E0164`.

View File

@ -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);
}

View File

@ -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);
}