Skip to content

Commit 1891c28

Browse files
committed
Auto merge of rust-lang#135101 - workingjubilee:rollup-owp3czl, r=workingjubilee
Rollup of 6 pull requests Successful merges: - rust-lang#135046 (turn rustc_box into an intrinsic) - rust-lang#135061 (crashes: add latest batch of tests) - rust-lang#135070 (std: sync to dep versions of backtrace) - rust-lang#135088 (Force code generation in assembly generation smoke-tests) - rust-lang#135091 (Bump backtrace to 0.3.75) - rust-lang#135094 (bootstrap: If dir_is_empty fails, show the non-existent directory path) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ead4a8f + e2983d8 commit 1891c28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+402
-235
lines changed

Diff for: compiler/rustc_feature/src/builtin_attrs.rs

-5
Original file line numberDiff line numberDiff line change
@@ -933,11 +933,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
933933
"#[rustc_has_incoherent_inherent_impls] allows the addition of incoherent inherent impls for \
934934
the given type by annotating all impl items with #[rustc_allow_incoherent_impl]."
935935
),
936-
rustc_attr!(
937-
rustc_box, AttributeType::Normal, template!(Word), ErrorFollowing, EncodeCrossCrate::No,
938-
"#[rustc_box] allows creating boxes \
939-
and it is only intended to be used in `alloc`."
940-
),
941936

942937
BuiltinAttribute {
943938
name: sym::rustc_diagnostic_item,

Diff for: compiler/rustc_hir_analysis/src/check/intrinsic.rs

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -
8686
| sym::assert_inhabited
8787
| sym::assert_zero_valid
8888
| sym::assert_mem_uninitialized_valid
89+
| sym::box_new
8990
| sym::breakpoint
9091
| sym::size_of
9192
| sym::min_align_of
@@ -606,6 +607,8 @@ pub fn check_intrinsic_type(
606607

607608
sym::ub_checks => (0, 0, Vec::new(), tcx.types.bool),
608609

610+
sym::box_new => (1, 0, vec![param(0)], Ty::new_box(tcx, param(0))),
611+
609612
sym::simd_eq
610613
| sym::simd_ne
611614
| sym::simd_lt

Diff for: compiler/rustc_mir_build/messages.ftl

-5
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,6 @@ mir_build_privately_uninhabited = pattern `{$witness_1}` is currently uninhabite
287287
288288
mir_build_rust_2024_incompatible_pat = this pattern relies on behavior which may change in edition 2024
289289
290-
mir_build_rustc_box_attribute_error = `#[rustc_box]` attribute used incorrectly
291-
.attributes = no other attributes may be applied
292-
.not_box = `#[rustc_box]` may only be applied to a `Box::new()` call
293-
.missing_box = `#[rustc_box]` requires the `owned_box` lang item
294-
295290
mir_build_static_in_pattern = statics cannot be referenced in patterns
296291
.label = can't be used in patterns
297292
mir_build_static_in_pattern_def = `static` defined here

Diff for: compiler/rustc_mir_build/src/errors.rs

-19
Original file line numberDiff line numberDiff line change
@@ -1067,25 +1067,6 @@ pub(crate) enum MiscPatternSuggestion {
10671067
},
10681068
}
10691069

1070-
#[derive(Diagnostic)]
1071-
#[diag(mir_build_rustc_box_attribute_error)]
1072-
pub(crate) struct RustcBoxAttributeError {
1073-
#[primary_span]
1074-
pub(crate) span: Span,
1075-
#[subdiagnostic]
1076-
pub(crate) reason: RustcBoxAttrReason,
1077-
}
1078-
1079-
#[derive(Subdiagnostic)]
1080-
pub(crate) enum RustcBoxAttrReason {
1081-
#[note(mir_build_attributes)]
1082-
Attributes,
1083-
#[note(mir_build_not_box)]
1084-
NotBoxNew,
1085-
#[note(mir_build_missing_box)]
1086-
MissingBox,
1087-
}
1088-
10891070
#[derive(LintDiagnostic)]
10901071
#[diag(mir_build_rust_2024_incompatible_pat)]
10911072
pub(crate) struct Rust2024IncompatiblePat<'a> {

Diff for: compiler/rustc_mir_build/src/thir/cx/expr.rs

+18-39
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use rustc_middle::{bug, span_bug};
2020
use rustc_span::{Span, sym};
2121
use tracing::{debug, info, instrument, trace};
2222

23-
use crate::errors;
2423
use crate::thir::cx::Cx;
2524
use crate::thir::util::UserAnnotatedTyHelpers;
2625

@@ -380,45 +379,25 @@ impl<'tcx> Cx<'tcx> {
380379
from_hir_call: true,
381380
fn_span: expr.span,
382381
}
383-
} else {
384-
let attrs = tcx.hir().attrs(expr.hir_id);
385-
if attrs.iter().any(|a| a.name_or_empty() == sym::rustc_box) {
386-
if attrs.len() != 1 {
387-
tcx.dcx().emit_err(errors::RustcBoxAttributeError {
388-
span: attrs[0].span,
389-
reason: errors::RustcBoxAttrReason::Attributes,
390-
});
391-
} else if let Some(box_item) = tcx.lang_items().owned_box() {
392-
if let hir::ExprKind::Path(hir::QPath::TypeRelative(ty, fn_path)) =
393-
fun.kind
394-
&& let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = ty.kind
395-
&& path.res.opt_def_id().is_some_and(|did| did == box_item)
396-
&& fn_path.ident.name == sym::new
397-
&& let [value] = args
398-
{
399-
return Expr {
400-
temp_lifetime: TempLifetime {
401-
temp_lifetime,
402-
backwards_incompatible,
403-
},
404-
ty: expr_ty,
405-
span: expr.span,
406-
kind: ExprKind::Box { value: self.mirror_expr(value) },
407-
};
408-
} else {
409-
tcx.dcx().emit_err(errors::RustcBoxAttributeError {
410-
span: expr.span,
411-
reason: errors::RustcBoxAttrReason::NotBoxNew,
412-
});
413-
}
414-
} else {
415-
tcx.dcx().emit_err(errors::RustcBoxAttributeError {
416-
span: attrs[0].span,
417-
reason: errors::RustcBoxAttrReason::MissingBox,
418-
});
419-
}
382+
} else if let ty::FnDef(def_id, _) = self.typeck_results().expr_ty(fun).kind()
383+
&& let Some(intrinsic) = self.tcx.intrinsic(def_id)
384+
&& intrinsic.name == sym::box_new
385+
{
386+
// We don't actually evaluate `fun` here, so make sure that doesn't miss any side-effects.
387+
if !matches!(fun.kind, hir::ExprKind::Path(_)) {
388+
span_bug!(
389+
expr.span,
390+
"`box_new` intrinsic can only be called via path expression"
391+
);
420392
}
421-
393+
let value = &args[0];
394+
return Expr {
395+
temp_lifetime: TempLifetime { temp_lifetime, backwards_incompatible },
396+
ty: expr_ty,
397+
span: expr.span,
398+
kind: ExprKind::Box { value: self.mirror_expr(value) },
399+
};
400+
} else {
422401
// Tuple-like ADTs are represented as ExprKind::Call. We convert them here.
423402
let adt_data = if let hir::ExprKind::Path(ref qpath) = fun.kind
424403
&& let Some(adt_def) = expr_ty.ty_adt_def()

Diff for: compiler/rustc_span/src/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,6 @@ symbols! {
16961696
rustc_as_ptr,
16971697
rustc_attrs,
16981698
rustc_autodiff,
1699-
rustc_box,
17001699
rustc_builtin_macro,
17011700
rustc_capture_analysis,
17021701
rustc_clean,

Diff for: library/Cargo.lock

+10-21
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ version = 4
44

55
[[package]]
66
name = "addr2line"
7-
version = "0.22.0"
7+
version = "0.24.2"
88
source = "registry+https://github.com/rust-lang/crates.io-index"
9-
checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678"
9+
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
1010
dependencies = [
1111
"compiler_builtins",
12-
"gimli 0.29.0",
12+
"gimli",
1313
"rustc-std-workspace-alloc",
1414
"rustc-std-workspace-core",
1515
]
1616

1717
[[package]]
18-
name = "adler"
19-
version = "1.0.2"
18+
name = "adler2"
19+
version = "2.0.0"
2020
source = "registry+https://github.com/rust-lang/crates.io-index"
21-
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
21+
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
2222
dependencies = [
2323
"compiler_builtins",
2424
"rustc-std-workspace-core",
@@ -111,17 +111,6 @@ dependencies = [
111111
"unicode-width",
112112
]
113113

114-
[[package]]
115-
name = "gimli"
116-
version = "0.29.0"
117-
source = "registry+https://github.com/rust-lang/crates.io-index"
118-
checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
119-
dependencies = [
120-
"compiler_builtins",
121-
"rustc-std-workspace-alloc",
122-
"rustc-std-workspace-core",
123-
]
124-
125114
[[package]]
126115
name = "gimli"
127116
version = "0.31.1"
@@ -177,11 +166,11 @@ dependencies = [
177166

178167
[[package]]
179168
name = "miniz_oxide"
180-
version = "0.7.4"
169+
version = "0.8.2"
181170
source = "registry+https://github.com/rust-lang/crates.io-index"
182-
checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
171+
checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394"
183172
dependencies = [
184-
"adler",
173+
"adler2",
185174
"compiler_builtins",
186175
"rustc-std-workspace-alloc",
187176
"rustc-std-workspace-core",
@@ -408,7 +397,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
408397
checksum = "51f06a05848f650946acef3bf525fe96612226b61f74ae23ffa4e98bfbb8ab3c"
409398
dependencies = [
410399
"compiler_builtins",
411-
"gimli 0.31.1",
400+
"gimli",
412401
"rustc-std-workspace-core",
413402
]
414403

Diff for: library/alloc/src/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ unsafe impl Allocator for Global {
339339
}
340340
}
341341

342-
/// The allocator for unique pointers.
342+
/// The allocator for `Box`.
343343
#[cfg(all(not(no_global_oom_handling), not(test)))]
344344
#[lang = "exchange_malloc"]
345345
#[inline]

Diff for: library/alloc/src/boxed.rs

+22-2
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,27 @@ pub struct Box<
233233
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
234234
>(Unique<T>, A);
235235

236+
/// Constructs a `Box<T>` by calling the `exchange_malloc` lang item and moving the argument into
237+
/// the newly allocated memory. This is an intrinsic to avoid unnecessary copies.
238+
///
239+
/// This is the surface syntax for `box <expr>` expressions.
240+
#[cfg(not(bootstrap))]
241+
#[rustc_intrinsic]
242+
#[rustc_intrinsic_must_be_overridden]
243+
#[unstable(feature = "liballoc_internals", issue = "none")]
244+
pub fn box_new<T>(_x: T) -> Box<T> {
245+
unreachable!()
246+
}
247+
248+
/// Transition function for the next bootstrap bump.
249+
#[cfg(bootstrap)]
250+
#[unstable(feature = "liballoc_internals", issue = "none")]
251+
#[inline(always)]
252+
pub fn box_new<T>(x: T) -> Box<T> {
253+
#[rustc_box]
254+
Box::new(x)
255+
}
256+
236257
impl<T> Box<T> {
237258
/// Allocates memory on the heap and then places `x` into it.
238259
///
@@ -250,8 +271,7 @@ impl<T> Box<T> {
250271
#[rustc_diagnostic_item = "box_new"]
251272
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
252273
pub fn new(x: T) -> Self {
253-
#[rustc_box]
254-
Box::new(x)
274+
return box_new(x);
255275
}
256276

257277
/// Constructs a new box with uninitialized contents.

Diff for: library/alloc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
#![feature(dropck_eyepatch)]
169169
#![feature(fundamental)]
170170
#![feature(hashmap_internals)]
171+
#![feature(intrinsics)]
171172
#![feature(lang_items)]
172173
#![feature(min_specialization)]
173174
#![feature(multiple_supertrait_upcastable)]

Diff for: library/alloc/src/macros.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ macro_rules! vec {
4848
);
4949
($($x:expr),+ $(,)?) => (
5050
<[_]>::into_vec(
51-
// This rustc_box is not required, but it produces a dramatic improvement in compile
51+
// Using the intrinsic produces a dramatic improvement in compile
5252
// time when constructing arrays with many elements.
53-
#[rustc_box]
54-
$crate::boxed::Box::new([$($x),+])
53+
$crate::boxed::box_new([$($x),+])
5554
)
5655
);
5756
}

Diff for: library/std/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ std_detect = { path = "../stdarch/crates/std_detect", default-features = false,
3030
rustc-demangle = { version = "0.1.24", features = ['rustc-dep-of-std'] }
3131

3232
[target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies]
33-
miniz_oxide = { version = "0.7.0", optional = true, default-features = false }
34-
addr2line = { version = "0.22.0", optional = true, default-features = false }
33+
miniz_oxide = { version = "0.8.0", optional = true, default-features = false }
34+
addr2line = { version = "0.24.0", optional = true, default-features = false }
3535

3636
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
3737
libc = { version = "0.2.169", default-features = false, features = [

Diff for: src/bootstrap/src/utils/helpers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ fn lld_flag_no_threads(builder: &Builder<'_>, lld_mode: LldMode, is_windows: boo
440440
}
441441

442442
pub fn dir_is_empty(dir: &Path) -> bool {
443-
t!(std::fs::read_dir(dir)).next().is_none()
443+
t!(std::fs::read_dir(dir), dir).next().is_none()
444444
}
445445

446446
/// Extract the beta revision from the full version string.

Diff for: src/tools/clippy/tests/ui-toml/disallowed_macros/disallowed_macros.stderr

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
error: use of a disallowed macro `std::vec`
2-
--> tests/ui-toml/disallowed_macros/disallowed_macros.rs:16:5
3-
|
4-
LL | vec![1, 2, 3];
5-
| ^^^^^^^^^^^^^
6-
|
7-
= note: `-D clippy::disallowed-macros` implied by `-D warnings`
8-
= help: to override `-D warnings` add `#[allow(clippy::disallowed_macros)]`
9-
101
error: use of a disallowed macro `serde::Serialize`
112
--> tests/ui-toml/disallowed_macros/disallowed_macros.rs:18:14
123
|
134
LL | #[derive(Serialize)]
145
| ^^^^^^^^^
156
|
167
= note: no serializing
8+
= note: `-D clippy::disallowed-macros` implied by `-D warnings`
9+
= help: to override `-D warnings` add `#[allow(clippy::disallowed_macros)]`
1710

1811
error: use of a disallowed macro `macros::attr`
1912
--> tests/ui-toml/disallowed_macros/disallowed_macros.rs:31:1
@@ -47,6 +40,12 @@ error: use of a disallowed macro `std::cfg`
4740
LL | cfg!(unix);
4841
| ^^^^^^^^^^
4942

43+
error: use of a disallowed macro `std::vec`
44+
--> tests/ui-toml/disallowed_macros/disallowed_macros.rs:16:5
45+
|
46+
LL | vec![1, 2, 3];
47+
| ^^^^^^^^^^^^^
48+
5049
error: use of a disallowed macro `macros::expr`
5150
--> tests/ui-toml/disallowed_macros/disallowed_macros.rs:21:13
5251
|

Diff for: src/tools/tidy/src/deps.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const LICENSES: &[&str] = &[
1818
// tidy-alphabetical-start
1919
"(MIT OR Apache-2.0) AND Unicode-3.0", // unicode_ident (1.0.14)
2020
"(MIT OR Apache-2.0) AND Unicode-DFS-2016", // unicode_ident (1.0.12)
21-
"0BSD OR MIT OR Apache-2.0", // adler license
21+
"0BSD OR MIT OR Apache-2.0", // adler2 license
2222
"0BSD",
2323
"Apache-2.0 / MIT",
2424
"Apache-2.0 OR ISC OR MIT",
@@ -462,7 +462,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
462462
const PERMITTED_STDLIB_DEPENDENCIES: &[&str] = &[
463463
// tidy-alphabetical-start
464464
"addr2line",
465-
"adler",
465+
"adler2",
466466
"allocator-api2",
467467
"cc",
468468
"cfg-if",

Diff for: tests/assembly/targets/targets-elf.rs

+2
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,8 @@
676676
#[lang = "sized"]
677677
trait Sized {}
678678

679+
// Force linkage to ensure code is actually generated
680+
#[no_mangle]
679681
pub fn test() -> u8 {
680682
42
681683
}

Diff for: tests/assembly/targets/targets-macho.rs

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
#[lang = "sized"]
8484
trait Sized {}
8585

86+
// Force linkage to ensure code is actually generated
87+
#[no_mangle]
8688
pub fn test() -> u8 {
8789
42
8890
}

Diff for: tests/crashes/134336.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ known-bug: #134336
2+
#![expect(incomplete_features)]
3+
#![feature(explicit_tail_calls)]
4+
5+
trait Tr {
6+
fn f();
7+
}
8+
9+
fn g<T: Tr>() {
10+
become T::f();
11+
}

Diff for: tests/crashes/134355.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: #134355
2+
3+
//@compile-flags: --crate-type=lib
4+
fn digit() -> str {
5+
return { i32::MIN };
6+
}

0 commit comments

Comments
 (0)