From 200d742984ddd7eb1c96db09882217fcb1a1a146 Mon Sep 17 00:00:00 2001 From: Lukas Lueg Date: Tue, 6 May 2025 21:49:56 +0200 Subject: [PATCH 01/17] Clarify &mut-methods' docs on sync::OnceLock --- library/std/src/sync/once_lock.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/library/std/src/sync/once_lock.rs b/library/std/src/sync/once_lock.rs index 324b5451873bf..a5c3a6c46a433 100644 --- a/library/std/src/sync/once_lock.rs +++ b/library/std/src/sync/once_lock.rs @@ -159,8 +159,11 @@ impl OnceLock { /// Gets the mutable reference to the underlying value. /// - /// Returns `None` if the cell is uninitialized, or being initialized. - /// This method never blocks. + /// Returns `None` if the cell is uninitialized. + /// + /// This method never blocks. Since it borrows the `OnceLock` mutably, + /// it is statically guaranteed that no active borrows to the `OnceLock` + /// exist, including from other threads. #[inline] #[stable(feature = "once_cell", since = "1.70.0")] pub fn get_mut(&mut self) -> Option<&mut T> { @@ -315,7 +318,9 @@ impl OnceLock { /// Gets the mutable reference of the contents of the cell, initializing /// it to `f()` if the cell was uninitialized. /// - /// This method never blocks. + /// This method never blocks. Since it borrows the `OnceLock` mutably, + /// it is statically guaranteed that no active borrows to the `OnceLock` + /// exist, including from other threads. /// /// # Panics /// @@ -405,7 +410,9 @@ impl OnceLock { /// it to `f()` if the cell was uninitialized. If the cell was uninitialized /// and `f()` failed, an error is returned. /// - /// This method never blocks. + /// This method never blocks. Since it borrows the `OnceLock` mutably, + /// it is statically guaranteed that no active borrows to the `OnceLock` + /// exist, including from other threads. /// /// # Panics /// @@ -469,7 +476,8 @@ impl OnceLock { /// /// Has no effect and returns `None` if the `OnceLock` was uninitialized. /// - /// Safety is guaranteed by requiring a mutable reference. + /// Since this method borrows the `OnceLock` mutably, it is statically guaranteed that + /// no active borrows to the `OnceLock` exist, including from other threads. /// /// # Examples /// From 81f61acf77b539af47291f23d5eb2617878a3e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sun, 27 Apr 2025 13:10:06 +0200 Subject: [PATCH 02/17] rustc_llvm: add Windows system libs only when cross-compiling from Windows This obviously doesn't work when cross-compiling from Linux. Split out from: https://github.com/rust-lang/rust/pull/140772 --- compiler/rustc_llvm/build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index a662694ac38f2..9a6549379d39c 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -228,10 +228,10 @@ fn main() { let mut cmd = Command::new(&llvm_config); cmd.arg(llvm_link_arg).arg("--libs"); - // Don't link system libs if cross-compiling unless targeting Windows. + // Don't link system libs if cross-compiling unless targeting Windows from Windows host. // On Windows system DLLs aren't linked directly, instead import libraries are used. // These import libraries are independent of the host. - if !is_crossed || target.contains("windows") { + if !is_crossed || target.contains("windows") && host.contains("windows") { cmd.arg("--system-libs"); } From f023a69f32352531a8da2f43e2ca4cd087317f8c Mon Sep 17 00:00:00 2001 From: Andrew Zhogin Date: Wed, 28 May 2025 13:56:23 +0700 Subject: [PATCH 03/17] Async drop - type instead of async drop fn and incorrect drop signature don't ICE now --- .../rustc_mir_transform/src/elaborate_drop.rs | 16 ++++++++-- tests/crashes/140484.rs | 14 -------- tests/crashes/140500.rs | 14 -------- .../async-await/async-drop/type-parameter.rs | 16 ++++++++++ .../async-drop/type-parameter.stderr | 11 +++++++ .../async-await/async-drop/unexpected-sort.rs | 18 +++++++++++ .../async-drop/unexpected-sort.stderr | 32 +++++++++++++++++++ 7 files changed, 91 insertions(+), 30 deletions(-) delete mode 100644 tests/crashes/140484.rs delete mode 100644 tests/crashes/140500.rs create mode 100644 tests/ui/async-await/async-drop/type-parameter.rs create mode 100644 tests/ui/async-await/async-drop/type-parameter.stderr create mode 100644 tests/ui/async-await/async-drop/unexpected-sort.rs create mode 100644 tests/ui/async-await/async-drop/unexpected-sort.stderr diff --git a/compiler/rustc_mir_transform/src/elaborate_drop.rs b/compiler/rustc_mir_transform/src/elaborate_drop.rs index 14f7c2a263b62..3fea328081e9a 100644 --- a/compiler/rustc_mir_transform/src/elaborate_drop.rs +++ b/compiler/rustc_mir_transform/src/elaborate_drop.rs @@ -1,6 +1,7 @@ use std::{fmt, iter, mem}; use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx}; +use rustc_hir::def::DefKind; use rustc_hir::lang_items::LangItem; use rustc_index::Idx; use rustc_middle::mir::*; @@ -254,8 +255,19 @@ where // impl_item_refs may be empty if drop fn is not implemented in 'impl AsyncDrop for ...' // (#140974). // Such code will report error, so just generate sync drop here and return - let Some(drop_fn_def_id) = - tcx.associated_item_def_ids(drop_trait).into_iter().nth(0).copied() + let Some(drop_fn_def_id) = tcx + .associated_item_def_ids(drop_trait) + .first() + .and_then(|def_id| { + if tcx.def_kind(def_id) == DefKind::AssocFn + && tcx.check_args_compatible(*def_id, trait_args) + { + Some(def_id) + } else { + None + } + }) + .copied() else { tcx.dcx().span_delayed_bug( self.elaborator.body().span, diff --git a/tests/crashes/140484.rs b/tests/crashes/140484.rs deleted file mode 100644 index 92ec19843982d..0000000000000 --- a/tests/crashes/140484.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ known-bug: #140484 -//@edition:2024 -#![feature(async_drop)] -use std::future::AsyncDrop; -struct a; -impl Drop for a { - fn b() {} -} -impl AsyncDrop for a { - type c; -} -async fn bar() { - a; -} diff --git a/tests/crashes/140500.rs b/tests/crashes/140500.rs deleted file mode 100644 index ee5b93ab82132..0000000000000 --- a/tests/crashes/140500.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ known-bug: #140500 - -#![feature(async_drop)] -use std::future::AsyncDrop; -struct a; -impl Drop for a { - fn b() {} -} -impl AsyncDrop for a { - fn c(d: impl Sized) {} -} -async fn bar() { - a; -} diff --git a/tests/ui/async-await/async-drop/type-parameter.rs b/tests/ui/async-await/async-drop/type-parameter.rs new file mode 100644 index 0000000000000..dde5f9f8e6444 --- /dev/null +++ b/tests/ui/async-await/async-drop/type-parameter.rs @@ -0,0 +1,16 @@ +//@ edition: 2024 +// ex-ice: #140500 +#![crate_type = "lib"] +#![feature(async_drop)] +#![expect(incomplete_features)] +use std::future::AsyncDrop; +struct A; +impl Drop for A { + fn drop(&mut self) {} +} +impl AsyncDrop for A { + fn drop(_wrong: impl Sized) {} //~ ERROR: method `drop` has a `self: Pin<&mut Self>` declaration in the trait, but not in the impl +} +async fn bar() { + A; +} diff --git a/tests/ui/async-await/async-drop/type-parameter.stderr b/tests/ui/async-await/async-drop/type-parameter.stderr new file mode 100644 index 0000000000000..841576b839e68 --- /dev/null +++ b/tests/ui/async-await/async-drop/type-parameter.stderr @@ -0,0 +1,11 @@ +error[E0186]: method `drop` has a `self: Pin<&mut Self>` declaration in the trait, but not in the impl + --> $DIR/type-parameter.rs:12:5 + | +LL | fn drop(_wrong: impl Sized) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `self: Pin<&mut Self>` in impl + | + = note: `drop` from trait: `fn(Pin<&mut Self>) -> impl Future` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0186`. diff --git a/tests/ui/async-await/async-drop/unexpected-sort.rs b/tests/ui/async-await/async-drop/unexpected-sort.rs new file mode 100644 index 0000000000000..659e21eb24119 --- /dev/null +++ b/tests/ui/async-await/async-drop/unexpected-sort.rs @@ -0,0 +1,18 @@ +// Ex-ice: #140484 +//@ edition: 2024 +#![crate_type = "lib"] +#![allow(incomplete_features)] +#![allow(non_camel_case_types)] +#![feature(async_drop)] +use std::future::AsyncDrop; +struct a; +impl Drop for a { //~ ERROR: not all trait items implemented, missing: `drop` + fn b() {} //~ ERROR: method `b` is not a member of trait `Drop` +} +impl AsyncDrop for a { //~ ERROR: not all trait items implemented, missing: `drop` + type c = (); + //~^ ERROR: type `c` is not a member of trait `AsyncDrop` +} +async fn bar() { + a; +} diff --git a/tests/ui/async-await/async-drop/unexpected-sort.stderr b/tests/ui/async-await/async-drop/unexpected-sort.stderr new file mode 100644 index 0000000000000..a6e4f9fd57307 --- /dev/null +++ b/tests/ui/async-await/async-drop/unexpected-sort.stderr @@ -0,0 +1,32 @@ +error[E0407]: method `b` is not a member of trait `Drop` + --> $DIR/unexpected-sort.rs:10:5 + | +LL | fn b() {} + | ^^^^^^^^^ not a member of trait `Drop` + +error[E0437]: type `c` is not a member of trait `AsyncDrop` + --> $DIR/unexpected-sort.rs:13:5 + | +LL | type c = (); + | ^^^^^^^^^^^^ not a member of trait `AsyncDrop` + +error[E0046]: not all trait items implemented, missing: `drop` + --> $DIR/unexpected-sort.rs:9:1 + | +LL | impl Drop for a { + | ^^^^^^^^^^^^^^^ missing `drop` in implementation + | + = help: implement the missing item: `fn drop(&mut self) { todo!() }` + +error[E0046]: not all trait items implemented, missing: `drop` + --> $DIR/unexpected-sort.rs:12:1 + | +LL | impl AsyncDrop for a { + | ^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation + | + = help: implement the missing item: `async fn drop(self: Pin<&mut Self>) { todo!() }` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0046, E0407, E0437. +For more information about an error, try `rustc --explain E0046`. From b9007f5e1d17bb0fe782dbe3548db5dfb5ddffa4 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Thu, 29 May 2025 13:55:00 +0200 Subject: [PATCH 04/17] test that the abi of c-variadic functions is checked in `extern` blocks --- ...ature-gate-extended_varargs_abi_support.rs | 15 +++++++++ ...e-gate-extended_varargs_abi_support.stderr | 32 ++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs b/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs index 58370bff2200e..e0be6faf40113 100644 --- a/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs +++ b/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs @@ -13,4 +13,19 @@ fn win(f: extern "win64" fn(usize, ...)) { f(22, 44); } +extern "efiapi" { + fn extern_efiapi(...); + //~^ ERROR using calling conventions other than `C` or `cdecl` for varargs functions is unstable [E0658] +} + +extern "sysv64" { + fn extern_sysv64(...); + //~^ ERROR using calling conventions other than `C` or `cdecl` for varargs functions is unstable [E0658] +} + +extern "win64" { + fn extern_win64(...); + //~^ ERROR using calling conventions other than `C` or `cdecl` for varargs functions is unstable [E0658] +} + fn main() {} diff --git a/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr b/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr index 9565575dc4279..3f6685faa9d2e 100644 --- a/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr +++ b/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr @@ -28,6 +28,36 @@ LL | fn win(f: extern "win64" fn(usize, ...)) { = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 3 previous errors +error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable + --> $DIR/feature-gate-extended_varargs_abi_support.rs:17:5 + | +LL | fn extern_efiapi(...); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #100189 for more information + = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable + --> $DIR/feature-gate-extended_varargs_abi_support.rs:22:5 + | +LL | fn extern_sysv64(...); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #100189 for more information + = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable + --> $DIR/feature-gate-extended_varargs_abi_support.rs:27:5 + | +LL | fn extern_win64(...); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #100189 for more information + = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0658`. From 30ddd3cd5dc62d3cfe4681d85af19c2a98b5a04d Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Thu, 29 May 2025 14:02:45 +0200 Subject: [PATCH 05/17] error on a `safe fn` that uses C-variadics --- compiler/rustc_ast_passes/messages.ftl | 9 ++++- .../rustc_ast_passes/src/ast_validation.rs | 16 +++++++- compiler/rustc_ast_passes/src/errors.rs | 15 +++++++- .../variadic-ffi-semantic-restrictions.rs | 9 +++++ .../variadic-ffi-semantic-restrictions.stderr | 38 ++++++++++++++++++- 5 files changed, 82 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_ast_passes/messages.ftl b/compiler/rustc_ast_passes/messages.ftl index 80754a8f65a69..d3636ef061e4a 100644 --- a/compiler/rustc_ast_passes/messages.ftl +++ b/compiler/rustc_ast_passes/messages.ftl @@ -24,8 +24,6 @@ ast_passes_auto_super_lifetime = auto traits cannot have super traits or lifetim .label = {ast_passes_auto_super_lifetime} .suggestion = remove the super traits or lifetime bounds -ast_passes_bad_c_variadic = only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg - ast_passes_bare_fn_invalid_safety = function pointers cannot be declared with `safe` safety qualifier .suggestion = remove safe from this item @@ -36,6 +34,13 @@ ast_passes_body_in_extern = incorrect `{$kind}` inside `extern` block ast_passes_bound_in_context = bounds on `type`s in {$ctx} have no effect +ast_passes_c_variadic_bad_calling_convention = + only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + +ast_passes_c_variadic_safe_foreign_function = + foreign functions with a C-variadic argument cannot be safe + .suggestion = remove the `safe` keyword from this definition + ast_passes_const_and_c_variadic = functions cannot be both `const` and C-variadic .const = `const` because of this .variadic = C-variadic because of this diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index d6fe04d2994b5..c4d8e9d954545 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -554,7 +554,21 @@ impl<'a> AstValidator<'a> { } match (fk.ctxt(), fk.header()) { - (Some(FnCtxt::Foreign), _) => return, + (Some(FnCtxt::Foreign), Some(header)) => match header.safety { + Safety::Default | Safety::Unsafe(_) => return, + Safety::Safe(span) => { + self.dcx().emit_err(errors::CVariadicSafeForeignFunction { + // The span of the "safe " string that should be removed. + safe_span: self + .sess + .psess + .source_map() + .span_until_non_whitespace(span.until(fk.decl().output.span())), + }); + return; + } + }, + (Some(FnCtxt::Free), Some(header)) => match header.ext { Extern::Explicit(StrLit { symbol_unescaped: sym::C, .. }, _) | Extern::Explicit(StrLit { symbol_unescaped: sym::C_dash_unwind, .. }, _) diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index 6f9737e08314e..e6dc83b291158 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -308,12 +308,25 @@ pub(crate) struct ExternItemAscii { } #[derive(Diagnostic)] -#[diag(ast_passes_bad_c_variadic)] +#[diag(ast_passes_c_variadic_bad_calling_convention)] pub(crate) struct BadCVariadic { #[primary_span] pub span: Vec, } +#[derive(Diagnostic)] +#[diag(ast_passes_c_variadic_safe_foreign_function)] +pub(crate) struct CVariadicSafeForeignFunction { + #[primary_span] + #[suggestion( + ast_passes_suggestion, + applicability = "machine-applicable", + code = "", + style = "verbose" + )] + pub safe_span: Span, +} + #[derive(Diagnostic)] #[diag(ast_passes_item_underscore)] pub(crate) struct ItemUnderscore<'a> { diff --git a/tests/ui/parser/variadic-ffi-semantic-restrictions.rs b/tests/ui/parser/variadic-ffi-semantic-restrictions.rs index 1cd6d13d56b6b..11ede2cded6fc 100644 --- a/tests/ui/parser/variadic-ffi-semantic-restrictions.rs +++ b/tests/ui/parser/variadic-ffi-semantic-restrictions.rs @@ -83,3 +83,12 @@ trait T { //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg //~| ERROR `...` must be the last argument of a C-variadic function } + +unsafe extern "C" { + safe fn s_f1(...); + //~^ ERROR foreign functions with a C-variadic argument cannot be safe + safe fn printf(format: *const u8, ...); + //~^ ERROR foreign functions with a C-variadic argument cannot be safe + safe fn snprintf(s: *mut u8, n: usize, format: *const u8, ...); + //~^ ERROR foreign functions with a C-variadic argument cannot be safe +} diff --git a/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr b/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr index b740cef020055..9a4fb5a254647 100644 --- a/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr +++ b/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr @@ -201,6 +201,42 @@ error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` function LL | fn t_f6(..., x: isize); | ^^^ +error: foreign functions with a C-variadic argument cannot be safe + --> $DIR/variadic-ffi-semantic-restrictions.rs:88:5 + | +LL | safe fn s_f1(...); + | ^^^^^ + | +help: remove the `safe` keyword from this definition + | +LL - safe fn s_f1(...); +LL + fn s_f1(...); + | + +error: foreign functions with a C-variadic argument cannot be safe + --> $DIR/variadic-ffi-semantic-restrictions.rs:90:5 + | +LL | safe fn printf(format: *const u8, ...); + | ^^^^^ + | +help: remove the `safe` keyword from this definition + | +LL - safe fn printf(format: *const u8, ...); +LL + fn printf(format: *const u8, ...); + | + +error: foreign functions with a C-variadic argument cannot be safe + --> $DIR/variadic-ffi-semantic-restrictions.rs:92:5 + | +LL | safe fn snprintf(s: *mut u8, n: usize, format: *const u8, ...); + | ^^^^^ + | +help: remove the `safe` keyword from this definition + | +LL - safe fn snprintf(s: *mut u8, n: usize, format: *const u8, ...); +LL + fn snprintf(s: *mut u8, n: usize, format: *const u8, ...); + | + error[E0493]: destructor of `VaListImpl<'_>` cannot be evaluated at compile-time --> $DIR/variadic-ffi-semantic-restrictions.rs:32:43 | @@ -225,6 +261,6 @@ LL | const fn i_f5(x: isize, ...) {} | | | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 36 previous errors +error: aborting due to 39 previous errors For more information about this error, try `rustc --explain E0493`. From c5e758d3ad5e17579644c1d0a17a194ceba60328 Mon Sep 17 00:00:00 2001 From: neeko-cat <60898184+neeko-cat@users.noreply.github.com> Date: Mon, 2 Jun 2025 01:55:29 +0200 Subject: [PATCH 06/17] Fixed a typo in `ManuallyDrop`'s doc --- library/core/src/mem/manually_drop.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/mem/manually_drop.rs b/library/core/src/mem/manually_drop.rs index 7d519384e373c..02bb81792931e 100644 --- a/library/core/src/mem/manually_drop.rs +++ b/library/core/src/mem/manually_drop.rs @@ -84,7 +84,7 @@ use crate::ptr; /// use std::mem::ManuallyDrop; /// /// pub struct BadOption { -/// // Invariant: Has been dropped iff `is_some` is false. +/// // Invariant: Has been dropped if `is_some` is false. /// value: ManuallyDrop, /// is_some: bool, /// } From 87054fc811c123cdbe187bf9c5df61302fa29d14 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 2 Jun 2025 10:11:10 +0200 Subject: [PATCH 07/17] Add missing 2015 edition directives These tests specifically test 2015 edition behavior, so ensure that they can only be run with this edition --- tests/ui/did_you_mean/E0178.rs | 1 + tests/ui/did_you_mean/E0178.stderr | 8 ++++---- .../trait-object-reference-without-parens-suggestion.rs | 1 + ...rait-object-reference-without-parens-suggestion.stderr | 8 ++++---- tests/ui/editions/async-block-2015.rs | 1 + tests/ui/editions/async-block-2015.stderr | 8 ++++---- tests/ui/ergonomic-clones/async/edition-2015.rs | 1 + tests/ui/ergonomic-clones/async/edition-2015.stderr | 2 +- tests/ui/errors/dynless-turbofish-e0191-issue-91997.rs | 1 + .../ui/errors/dynless-turbofish-e0191-issue-91997.stderr | 4 ++-- tests/ui/expr/scope.rs | 1 + tests/ui/imports/import-glob-crate.rs | 1 + 12 files changed, 22 insertions(+), 15 deletions(-) diff --git a/tests/ui/did_you_mean/E0178.rs b/tests/ui/did_you_mean/E0178.rs index 095df640c38f2..cdaddac35a357 100644 --- a/tests/ui/did_you_mean/E0178.rs +++ b/tests/ui/did_you_mean/E0178.rs @@ -1,3 +1,4 @@ +//@ edition:2015 #![allow(bare_trait_objects)] trait Foo {} diff --git a/tests/ui/did_you_mean/E0178.stderr b/tests/ui/did_you_mean/E0178.stderr index 36e4dbdf7c45d..7b69f860381ea 100644 --- a/tests/ui/did_you_mean/E0178.stderr +++ b/tests/ui/did_you_mean/E0178.stderr @@ -1,5 +1,5 @@ error[E0178]: expected a path on the left-hand side of `+` - --> $DIR/E0178.rs:6:8 + --> $DIR/E0178.rs:7:8 | LL | w: &'a Foo + Copy, | ^^^^^^^ @@ -10,7 +10,7 @@ LL | w: &'a (Foo + Copy), | + + error[E0178]: expected a path on the left-hand side of `+` - --> $DIR/E0178.rs:7:8 + --> $DIR/E0178.rs:8:8 | LL | x: &'a Foo + 'a, | ^^^^^^^ @@ -21,7 +21,7 @@ LL | x: &'a (Foo + 'a), | + + error[E0178]: expected a path on the left-hand side of `+` - --> $DIR/E0178.rs:8:8 + --> $DIR/E0178.rs:9:8 | LL | y: &'a mut Foo + 'a, | ^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | y: &'a mut (Foo + 'a), | + + error[E0178]: expected a path on the left-hand side of `+` - --> $DIR/E0178.rs:9:8 + --> $DIR/E0178.rs:10:8 | LL | z: fn() -> Foo + 'a, | ^^^^^^^^^^^----- diff --git a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs index b7470864a30db..eff431f4665f9 100644 --- a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs +++ b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 #![allow(bare_trait_objects)] fn main() { diff --git a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr index 57dbc79a0fda2..b051d181ad80a 100644 --- a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr +++ b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr @@ -1,5 +1,5 @@ error[E0178]: expected a path on the left-hand side of `+` - --> $DIR/trait-object-reference-without-parens-suggestion.rs:4:12 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:5:12 | LL | let _: &Copy + 'static; | ^^^^^ @@ -10,7 +10,7 @@ LL | let _: &(Copy + 'static); | + + error[E0178]: expected a path on the left-hand side of `+` - --> $DIR/trait-object-reference-without-parens-suggestion.rs:6:12 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:7:12 | LL | let _: &'static Copy + 'static; | ^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | let _: &'static (Copy + 'static); | + + error[E0038]: the trait `Copy` is not dyn compatible - --> $DIR/trait-object-reference-without-parens-suggestion.rs:4:13 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:5:13 | LL | let _: &Copy + 'static; | ^^^^ `Copy` is not dyn compatible @@ -31,7 +31,7 @@ LL | let _: &Copy + 'static; for more information, visit error[E0038]: the trait `Copy` is not dyn compatible - --> $DIR/trait-object-reference-without-parens-suggestion.rs:6:21 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:7:21 | LL | let _: &'static Copy + 'static; | ^^^^ `Copy` is not dyn compatible diff --git a/tests/ui/editions/async-block-2015.rs b/tests/ui/editions/async-block-2015.rs index a079b4aad911e..21549f059de26 100644 --- a/tests/ui/editions/async-block-2015.rs +++ b/tests/ui/editions/async-block-2015.rs @@ -1,3 +1,4 @@ +//@ edition:2015 async fn foo() { //~^ ERROR `async fn` is not permitted in Rust 2015 //~| NOTE to use `async fn`, switch to Rust 2018 or later diff --git a/tests/ui/editions/async-block-2015.stderr b/tests/ui/editions/async-block-2015.stderr index 574bcacc1cfa7..139df1758cc43 100644 --- a/tests/ui/editions/async-block-2015.stderr +++ b/tests/ui/editions/async-block-2015.stderr @@ -1,5 +1,5 @@ error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/async-block-2015.rs:1:1 + --> $DIR/async-block-2015.rs:2:1 | LL | async fn foo() { | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -8,7 +8,7 @@ LL | async fn foo() { = note: for more on editions, read https://doc.rust-lang.org/edition-guide error: expected identifier, found keyword `let` - --> $DIR/async-block-2015.rs:11:9 + --> $DIR/async-block-2015.rs:12:9 | LL | let y = async { | ----- `async` blocks are only allowed in Rust 2018 or later @@ -19,7 +19,7 @@ LL | let x = 42; = note: for more on editions, read https://doc.rust-lang.org/edition-guide error: expected identifier, found `42` - --> $DIR/async-block-2015.rs:19:9 + --> $DIR/async-block-2015.rs:20:9 | LL | let z = async { | ----- `async` blocks are only allowed in Rust 2018 or later @@ -30,7 +30,7 @@ LL | 42 = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0422]: cannot find struct, variant or union type `async` in this scope - --> $DIR/async-block-2015.rs:7:13 + --> $DIR/async-block-2015.rs:8:13 | LL | let x = async {}; | ^^^^^ `async` blocks are only allowed in Rust 2018 or later diff --git a/tests/ui/ergonomic-clones/async/edition-2015.rs b/tests/ui/ergonomic-clones/async/edition-2015.rs index d3b2071b9f91f..7883124942902 100644 --- a/tests/ui/ergonomic-clones/async/edition-2015.rs +++ b/tests/ui/ergonomic-clones/async/edition-2015.rs @@ -1,3 +1,4 @@ +//@ edition:2015 #![feature(ergonomic_clones)] #![allow(incomplete_features)] diff --git a/tests/ui/ergonomic-clones/async/edition-2015.stderr b/tests/ui/ergonomic-clones/async/edition-2015.stderr index b218e6b242e19..8de90f4bfd3c9 100644 --- a/tests/ui/ergonomic-clones/async/edition-2015.stderr +++ b/tests/ui/ergonomic-clones/async/edition-2015.stderr @@ -1,5 +1,5 @@ error: `async use` blocks are only allowed in Rust 2018 or later - --> $DIR/edition-2015.rs:5:5 + --> $DIR/edition-2015.rs:6:5 | LL | async use {}; | ^^^^^^^^^ diff --git a/tests/ui/errors/dynless-turbofish-e0191-issue-91997.rs b/tests/ui/errors/dynless-turbofish-e0191-issue-91997.rs index 69a4c13530bd3..d6bb64662270e 100644 --- a/tests/ui/errors/dynless-turbofish-e0191-issue-91997.rs +++ b/tests/ui/errors/dynless-turbofish-e0191-issue-91997.rs @@ -1,3 +1,4 @@ +//@ edition:2015 trait MyIterator : Iterator {} fn main() { diff --git a/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr b/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr index 24f00cfa6be91..7f3022c29233e 100644 --- a/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr +++ b/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr @@ -1,5 +1,5 @@ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/dynless-turbofish-e0191-issue-91997.rs:4:13 + --> $DIR/dynless-turbofish-e0191-issue-91997.rs:5:13 | LL | let _ = MyIterator::next; | ^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | let _ = ::next; | ++++ + error[E0191]: the value of the associated type `Item` in `Iterator` must be specified - --> $DIR/dynless-turbofish-e0191-issue-91997.rs:4:13 + --> $DIR/dynless-turbofish-e0191-issue-91997.rs:5:13 | LL | let _ = MyIterator::next; | ^^^^^^^^^^ help: specify the associated type: `MyIterator::` diff --git a/tests/ui/expr/scope.rs b/tests/ui/expr/scope.rs index 3a1c8b87da8fa..b059e43de9ee2 100644 --- a/tests/ui/expr/scope.rs +++ b/tests/ui/expr/scope.rs @@ -1,3 +1,4 @@ +//@ edition:2015 //@ run-pass // Regression test for issue #762 diff --git a/tests/ui/imports/import-glob-crate.rs b/tests/ui/imports/import-glob-crate.rs index 0a2ca6ef2c315..ee0679318766b 100644 --- a/tests/ui/imports/import-glob-crate.rs +++ b/tests/ui/imports/import-glob-crate.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ run-pass use std::mem::*; From aba70e8f9d66dce7d9980808cc1ce88fab967d3d Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 2 Jun 2025 10:11:10 +0200 Subject: [PATCH 08/17] Add missing `dyn` keywords to tests that do not test for them This ensures that these tests can be run on editions other than 2015 --- tests/ui/allocator/auxiliary/helper.rs | 2 +- tests/ui/coercion/retslot-cast.rs | 8 ++++---- tests/ui/coercion/retslot-cast.stderr | 4 ++-- tests/ui/coroutine/auxiliary/xcrate.rs | 2 +- tests/ui/deprecation/deprecation-lint.rs | 4 ++-- tests/ui/dyn-drop/dyn-drop.rs | 3 +-- tests/ui/dyn-drop/dyn-drop.stderr | 14 ++++++------- tests/ui/error-codes/E0657.rs | 4 ++-- tests/ui/error-codes/E0657.stderr | 24 +++++++++++------------ tests/ui/intrinsics/non-integer-atomic.rs | 2 +- 10 files changed, 33 insertions(+), 34 deletions(-) diff --git a/tests/ui/allocator/auxiliary/helper.rs b/tests/ui/allocator/auxiliary/helper.rs index c638546a9475f..4267b901ca07f 100644 --- a/tests/ui/allocator/auxiliary/helper.rs +++ b/tests/ui/allocator/auxiliary/helper.rs @@ -6,6 +6,6 @@ extern crate alloc; use alloc::fmt; -pub fn work_with(p: &fmt::Debug) { +pub fn work_with(p: &dyn fmt::Debug) { drop(p); } diff --git a/tests/ui/coercion/retslot-cast.rs b/tests/ui/coercion/retslot-cast.rs index ae500cb15dfdd..a87ac35a8e1e0 100644 --- a/tests/ui/coercion/retslot-cast.rs +++ b/tests/ui/coercion/retslot-cast.rs @@ -1,7 +1,7 @@ #![allow(warnings)] -pub fn fail(x: Option<&(Iterator+Send)>) - -> Option<&Iterator> { +pub fn fail(x: Option<&(dyn Iterator+Send)>) + -> Option<&dyn Iterator> { // This call used to trigger an LLVM assertion because the return // slot had type "Option<&Iterator>"* instead of // "Option<&(Iterator+Send)>"* -- but this now yields a @@ -13,8 +13,8 @@ pub fn fail(x: Option<&(Iterator+Send)>) inner(x) //~ ERROR mismatched types } -pub fn inner(x: Option<&(Iterator+Send)>) - -> Option<&(Iterator+Send)> { +pub fn inner(x: Option<&(dyn Iterator+Send)>) + -> Option<&(dyn Iterator+Send)> { x } diff --git a/tests/ui/coercion/retslot-cast.stderr b/tests/ui/coercion/retslot-cast.stderr index dac21a7f25b2b..a5242c13edd1b 100644 --- a/tests/ui/coercion/retslot-cast.stderr +++ b/tests/ui/coercion/retslot-cast.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types --> $DIR/retslot-cast.rs:13:5 | -LL | -> Option<&Iterator> { - | -------------------------- expected `Option<&dyn Iterator>` because of return type +LL | -> Option<&dyn Iterator> { + | ------------------------------ expected `Option<&dyn Iterator>` because of return type ... LL | inner(x) | ^^^^^^^^ expected trait `Iterator`, found trait `Iterator + Send` diff --git a/tests/ui/coroutine/auxiliary/xcrate.rs b/tests/ui/coroutine/auxiliary/xcrate.rs index 52f188135bd1b..524eaafc75299 100644 --- a/tests/ui/coroutine/auxiliary/xcrate.rs +++ b/tests/ui/coroutine/auxiliary/xcrate.rs @@ -12,7 +12,7 @@ pub fn foo() -> impl Coroutine<(), Yield = (), Return = ()> { } } -pub fn bar(t: T) -> Box + Unpin> { +pub fn bar(t: T) -> Box + Unpin> { Box::new( #[coroutine] || { diff --git a/tests/ui/deprecation/deprecation-lint.rs b/tests/ui/deprecation/deprecation-lint.rs index dc11a4d56a2d6..5eda38732c8c9 100644 --- a/tests/ui/deprecation/deprecation-lint.rs +++ b/tests/ui/deprecation/deprecation-lint.rs @@ -71,7 +71,7 @@ mod cross_crate { ::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated` foo.trait_deprecated_text(); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text } @@ -299,7 +299,7 @@ mod this_crate { ::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated` foo.trait_deprecated_text(); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text } diff --git a/tests/ui/dyn-drop/dyn-drop.rs b/tests/ui/dyn-drop/dyn-drop.rs index e1668a3f188d5..f336949d2cb74 100644 --- a/tests/ui/dyn-drop/dyn-drop.rs +++ b/tests/ui/dyn-drop/dyn-drop.rs @@ -1,8 +1,7 @@ #![deny(dyn_drop)] -#![allow(bare_trait_objects)] fn foo(_: Box) {} //~ ERROR fn bar(_: &dyn Drop) {} //~ERROR -fn baz(_: *mut Drop) {} //~ ERROR +fn baz(_: *mut dyn Drop) {} //~ ERROR struct Foo { _x: Box //~ ERROR } diff --git a/tests/ui/dyn-drop/dyn-drop.stderr b/tests/ui/dyn-drop/dyn-drop.stderr index 1b1dbc4d12d4c..8210d8a4c48f9 100644 --- a/tests/ui/dyn-drop/dyn-drop.stderr +++ b/tests/ui/dyn-drop/dyn-drop.stderr @@ -1,5 +1,5 @@ error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped - --> $DIR/dyn-drop.rs:3:19 + --> $DIR/dyn-drop.rs:2:19 | LL | fn foo(_: Box) {} | ^^^^ @@ -11,25 +11,25 @@ LL | #![deny(dyn_drop)] | ^^^^^^^^ error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped - --> $DIR/dyn-drop.rs:4:16 + --> $DIR/dyn-drop.rs:3:16 | LL | fn bar(_: &dyn Drop) {} | ^^^^ error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped - --> $DIR/dyn-drop.rs:5:16 + --> $DIR/dyn-drop.rs:4:20 | -LL | fn baz(_: *mut Drop) {} - | ^^^^ +LL | fn baz(_: *mut dyn Drop) {} + | ^^^^ error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped - --> $DIR/dyn-drop.rs:7:15 + --> $DIR/dyn-drop.rs:6:15 | LL | _x: Box | ^^^^ error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped - --> $DIR/dyn-drop.rs:14:16 + --> $DIR/dyn-drop.rs:13:16 | LL | type T = dyn Drop; | ^^^^ diff --git a/tests/ui/error-codes/E0657.rs b/tests/ui/error-codes/E0657.rs index 212c1d9e581a2..f046788153d58 100644 --- a/tests/ui/error-codes/E0657.rs +++ b/tests/ui/error-codes/E0657.rs @@ -7,7 +7,7 @@ impl<'a> Lt<'a> for () {} impl Id for T {} fn free_fn_capture_hrtb_in_impl_trait() - -> Box Id>> + -> Box Id>> //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type { Box::new(()) @@ -16,7 +16,7 @@ fn free_fn_capture_hrtb_in_impl_trait() struct Foo; impl Foo { fn impl_fn_capture_hrtb_in_impl_trait() - -> Box Id>> + -> Box Id>> //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type { Box::new(()) diff --git a/tests/ui/error-codes/E0657.stderr b/tests/ui/error-codes/E0657.stderr index c539007cdcf19..c9dfc9eb9069d 100644 --- a/tests/ui/error-codes/E0657.stderr +++ b/tests/ui/error-codes/E0657.stderr @@ -1,26 +1,26 @@ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type - --> $DIR/E0657.rs:10:31 + --> $DIR/E0657.rs:10:35 | -LL | -> Box Id>> - | ^^ +LL | -> Box Id>> + | ^^ | note: lifetime declared here - --> $DIR/E0657.rs:10:16 + --> $DIR/E0657.rs:10:20 | -LL | -> Box Id>> - | ^^ +LL | -> Box Id>> + | ^^ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type - --> $DIR/E0657.rs:19:35 + --> $DIR/E0657.rs:19:39 | -LL | -> Box Id>> - | ^^ +LL | -> Box Id>> + | ^^ | note: lifetime declared here - --> $DIR/E0657.rs:19:20 + --> $DIR/E0657.rs:19:24 | -LL | -> Box Id>> - | ^^ +LL | -> Box Id>> + | ^^ error: aborting due to 2 previous errors diff --git a/tests/ui/intrinsics/non-integer-atomic.rs b/tests/ui/intrinsics/non-integer-atomic.rs index dd129e5594510..5464bf747faed 100644 --- a/tests/ui/intrinsics/non-integer-atomic.rs +++ b/tests/ui/intrinsics/non-integer-atomic.rs @@ -8,7 +8,7 @@ use std::intrinsics::{self, AtomicOrdering}; #[derive(Copy, Clone)] pub struct Foo(i64); -pub type Bar = &'static Fn(); +pub type Bar = &'static dyn Fn(); pub type Quux = [u8; 100]; pub unsafe fn test_bool_load(p: &mut bool, v: bool) { From a5f7d44405146a7cc5dadd65601c8d71546e382f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Mon, 2 Jun 2025 10:57:01 +0200 Subject: [PATCH 09/17] add test for 141764 --- tests/ui/macros/auxiliary/borrowck-error-in-macro.rs | 10 ++++++++++ tests/ui/macros/borrowck-error-in-macro.rs | 5 +++++ 2 files changed, 15 insertions(+) create mode 100644 tests/ui/macros/auxiliary/borrowck-error-in-macro.rs create mode 100644 tests/ui/macros/borrowck-error-in-macro.rs diff --git a/tests/ui/macros/auxiliary/borrowck-error-in-macro.rs b/tests/ui/macros/auxiliary/borrowck-error-in-macro.rs new file mode 100644 index 0000000000000..2d5f2bda2edfe --- /dev/null +++ b/tests/ui/macros/auxiliary/borrowck-error-in-macro.rs @@ -0,0 +1,10 @@ +#[macro_export] +macro_rules! ice { + () => { + fn main() { + let d = &mut 0; + let c = || *d += 1; + c(); + } + }; +} diff --git a/tests/ui/macros/borrowck-error-in-macro.rs b/tests/ui/macros/borrowck-error-in-macro.rs new file mode 100644 index 0000000000000..74764b1b3a3ec --- /dev/null +++ b/tests/ui/macros/borrowck-error-in-macro.rs @@ -0,0 +1,5 @@ +//@ aux-build: borrowck-error-in-macro.rs + +extern crate borrowck_error_in_macro as a; + +a::ice! {} From 2e527f03d1c6b428cedbea52c1b644c4d0abe1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Mon, 2 Jun 2025 11:15:20 +0200 Subject: [PATCH 10/17] fix bug where borrowck tries to describe a name from a macro in another crate --- .../src/diagnostics/mutability_errors.rs | 24 ++++++++++++------- tests/ui/macros/borrowck-error-in-macro.rs | 2 ++ .../ui/macros/borrowck-error-in-macro.stderr | 19 +++++++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 tests/ui/macros/borrowck-error-in-macro.stderr diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 56cc432758511..a5c9bad3ac2db 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -840,14 +840,22 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { } else { bug!("not an upvar") }; - err.span_label( - *span, - format!( - "calling `{}` requires mutable binding due to {}", - self.describe_place(the_place_err).unwrap(), - reason - ), - ); + // sometimes we deliberately don't store the name of a place when coming from a macro in + // another crate. We generally want to limit those diagnostics a little, to hide + // implementation details (such as those from pin!() or format!()). In that case show a + // slightly different error message, or none at all if something else happened. In other + // cases the message is likely not useful. + if let Some(place_name) = self.describe_place(the_place_err) { + err.span_label( + *span, + format!("calling `{place_name}` requires mutable binding due to {reason}"), + ); + } else if span.from_expansion() { + err.span_label( + *span, + format!("a call in this macro requires a mutable binding due to {reason}",), + ); + } } } diff --git a/tests/ui/macros/borrowck-error-in-macro.rs b/tests/ui/macros/borrowck-error-in-macro.rs index 74764b1b3a3ec..86ac74cb4c1e7 100644 --- a/tests/ui/macros/borrowck-error-in-macro.rs +++ b/tests/ui/macros/borrowck-error-in-macro.rs @@ -1,5 +1,7 @@ //@ aux-build: borrowck-error-in-macro.rs +//@ error-pattern: a call in this macro requires a mutable binding due to mutable borrow of `d` extern crate borrowck_error_in_macro as a; a::ice! {} +//~^ ERROR cannot borrow value as mutable, as it is not declared as mutable diff --git a/tests/ui/macros/borrowck-error-in-macro.stderr b/tests/ui/macros/borrowck-error-in-macro.stderr new file mode 100644 index 0000000000000..3d1e67d9a2543 --- /dev/null +++ b/tests/ui/macros/borrowck-error-in-macro.stderr @@ -0,0 +1,19 @@ +error[E0596]: cannot borrow value as mutable, as it is not declared as mutable + --> $DIR/borrowck-error-in-macro.rs:6:1 + | +LL | a::ice! {} + | ^^^^^^^^^^ + | | + | cannot borrow as mutable + | a call in this macro requires a mutable binding due to mutable borrow of `d` + | + = note: this error originates in the macro `a::ice` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider changing this to be mutable + --> $DIR/auxiliary/borrowck-error-in-macro.rs:6:17 + | +LL | let mut c = || *d += 1; + | +++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0596`. From 80e44de2d37c7f9597707cbba1287fdd03cdcae5 Mon Sep 17 00:00:00 2001 From: usamoi Date: Mon, 2 Jun 2025 17:49:28 +0800 Subject: [PATCH 11/17] remove f16: From --- library/core/src/convert/num.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/library/core/src/convert/num.rs b/library/core/src/convert/num.rs index d5cb10a5d1c8b..50616732b7776 100644 --- a/library/core/src/convert/num.rs +++ b/library/core/src/convert/num.rs @@ -175,7 +175,6 @@ impl_from!(u8 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0") impl_from!(u8 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); impl_from!(u8 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); impl_from!(u8 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); -impl_from!(u16 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); impl_from!(u16 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); impl_from!(u16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); impl_from!(u16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); From 6be3c3ceb7351677999c661dfba0110992b37132 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Mon, 2 Jun 2025 13:43:51 +0200 Subject: [PATCH 12/17] [rustdoc-json] Implement PartialOrd and Ord for rustdoc_types::Id --- src/rustdoc-json-types/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index c091c955ed5eb..f1c375bd2fe1c 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -388,7 +388,7 @@ pub enum AssocItemConstraintKind { /// Rustdoc makes no guarantees about the inner value of Id's. Applications /// should treat them as opaque keys to lookup items, and avoid attempting /// to parse them, or otherwise depend on any implementation details. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] // FIXME(aDotInTheVoid): Consider making this non-public in rustdoc-types. pub struct Id(pub u32); From 8b5b6d053a044895fd8a88e2cb3c1e9127b3c7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Mon, 2 Jun 2025 13:21:18 +0200 Subject: [PATCH 13/17] add fixme to improve error matching --- tests/ui/macros/borrowck-error-in-macro.rs | 1 + tests/ui/macros/borrowck-error-in-macro.stderr | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ui/macros/borrowck-error-in-macro.rs b/tests/ui/macros/borrowck-error-in-macro.rs index 86ac74cb4c1e7..fe75188efd203 100644 --- a/tests/ui/macros/borrowck-error-in-macro.rs +++ b/tests/ui/macros/borrowck-error-in-macro.rs @@ -1,5 +1,6 @@ //@ aux-build: borrowck-error-in-macro.rs //@ error-pattern: a call in this macro requires a mutable binding due to mutable borrow of `d` +//FIXME: remove error-pattern (see #141896) extern crate borrowck_error_in_macro as a; diff --git a/tests/ui/macros/borrowck-error-in-macro.stderr b/tests/ui/macros/borrowck-error-in-macro.stderr index 3d1e67d9a2543..ec0302ee287ec 100644 --- a/tests/ui/macros/borrowck-error-in-macro.stderr +++ b/tests/ui/macros/borrowck-error-in-macro.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow value as mutable, as it is not declared as mutable - --> $DIR/borrowck-error-in-macro.rs:6:1 + --> $DIR/borrowck-error-in-macro.rs:7:1 | LL | a::ice! {} | ^^^^^^^^^^ From b0041b8a05e2d6090dbf59f715b52cba3ca73359 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 2 Jun 2025 08:49:54 -0700 Subject: [PATCH 14/17] Disable f64 minimum/maximum tests for arm 32 This disables the f64 minimum/maximum tests for the arm-unknown-linux-gnueabihf job. The next release will be supporting cross-compiled doctests, and these tests fail on that platform. It looks like this was just fixed via https://github.com/llvm/llvm-project/pull/142170, but I assume that will not trickle down to our copy of llvm in the next couple of weeks. Assuming that does get fixed when llvm is updated, then these can be removed. cc https://github.com/rust-lang/rust/issues/141087 --- library/core/src/num/f64.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index 0a63ed828aedf..be933cfa41ae9 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -943,7 +943,7 @@ impl f64 { /// This returns NaN when *either* argument is NaN, as opposed to /// [`f64::max`] which only returns NaN when *both* arguments are NaN. /// - /// ``` + /// ```ignore-arm-unknown-linux-gnueabihf (see https://github.com/rust-lang/rust/issues/141087) /// #![feature(float_minimum_maximum)] /// let x = 1.0_f64; /// let y = 2.0_f64; @@ -970,7 +970,7 @@ impl f64 { /// This returns NaN when *either* argument is NaN, as opposed to /// [`f64::min`] which only returns NaN when *both* arguments are NaN. /// - /// ``` + /// ```ignore-arm-unknown-linux-gnueabihf (see https://github.com/rust-lang/rust/issues/141087) /// #![feature(float_minimum_maximum)] /// let x = 1.0_f64; /// let y = 2.0_f64; From bb5de7d72b7965d8bbd80b024f644b0dfcdd0e5b Mon Sep 17 00:00:00 2001 From: rustbot <47979223+rustbot@users.noreply.github.com> Date: Mon, 2 Jun 2025 19:01:18 +0200 Subject: [PATCH 15/17] Update books --- src/doc/book | 2 +- src/doc/embedded-book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doc/book b/src/doc/book index 230c68bc1e08f..634724ea85ebb 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 230c68bc1e08f5f3228384a28cc228c81dfbd10d +Subproject commit 634724ea85ebb08a542970bf8871ac8b0f77fd15 diff --git a/src/doc/embedded-book b/src/doc/embedded-book index 0b8219ac23a3e..10fa1e084365f 160000 --- a/src/doc/embedded-book +++ b/src/doc/embedded-book @@ -1 +1 @@ -Subproject commit 0b8219ac23a3e09464e4e0166c768cf1c4bba0d5 +Subproject commit 10fa1e084365f23f24ad0000df541923385b73b6 diff --git a/src/doc/nomicon b/src/doc/nomicon index c76a20f0d9871..8b61acfaea822 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit c76a20f0d987145dcedf05c5c073ce8d91f2e82a +Subproject commit 8b61acfaea822e9ac926190bc8f15791c33336e8 diff --git a/src/doc/reference b/src/doc/reference index 118fd1f1f0854..8e0f593a30f3b 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 118fd1f1f0854f50e3ae1fe4b64862aad23009ca +Subproject commit 8e0f593a30f3b56ddb0908fb7ab9249974e08738 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index c9d151f9147c4..21f4e32b8b40d 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit c9d151f9147c4808c77f0375ba3fa5d54443cb9e +Subproject commit 21f4e32b8b40d36453fae16ec07ad4b857c445b6 From 19e02c82119cf25f92fe6325d7caa483fa84b4bb Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 2 Jun 2025 10:19:58 -0700 Subject: [PATCH 16/17] Remove bootstrap cfgs from library/ --- library/core/src/intrinsics/mod.rs | 48 +++++-------------------- library/core/src/lib.rs | 2 -- library/core/src/macros/mod.rs | 2 -- library/core/src/slice/index.rs | 57 +++--------------------------- library/core/src/sync/atomic.rs | 17 --------- library/coretests/tests/num/mod.rs | 6 ---- library/std/src/lib.rs | 3 +- 7 files changed, 13 insertions(+), 122 deletions(-) diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index d147cf889cc03..bde90464acba6 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -413,38 +413,7 @@ pub unsafe fn atomic_cxchgweak_seqcst_seqcst(dst: *mut T, old: T, src: /// [`atomic`] types via the `load` method. For example, [`AtomicBool::load`]. #[rustc_intrinsic] #[rustc_nounwind] -#[cfg(not(bootstrap))] pub unsafe fn atomic_load(src: *const T) -> T; -/// Loads the current value of the pointer. -/// `T` must be an integer or pointer type. -/// -/// The stabilized version of this intrinsic is available on the -/// [`atomic`] types via the `load` method by passing -/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::load`]. -#[rustc_intrinsic] -#[rustc_nounwind] -#[cfg(bootstrap)] -pub unsafe fn atomic_load_seqcst(src: *const T) -> T; -/// Loads the current value of the pointer. -/// `T` must be an integer or pointer type. -/// -/// The stabilized version of this intrinsic is available on the -/// [`atomic`] types via the `load` method by passing -/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::load`]. -#[rustc_intrinsic] -#[rustc_nounwind] -#[cfg(bootstrap)] -pub unsafe fn atomic_load_acquire(src: *const T) -> T; -/// Loads the current value of the pointer. -/// `T` must be an integer or pointer type. -/// -/// The stabilized version of this intrinsic is available on the -/// [`atomic`] types via the `load` method by passing -/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::load`]. -#[rustc_intrinsic] -#[rustc_nounwind] -#[cfg(bootstrap)] -pub unsafe fn atomic_load_relaxed(src: *const T) -> T; /// Stores the value at the specified memory location. /// `T` must be an integer or pointer type. @@ -1767,7 +1736,6 @@ pub const unsafe fn arith_offset(dst: *const T, offset: isize) -> *const T; /// - `index < PtrMetadata(slice_ptr)`, so the indexing is in-bounds for the slice /// - the resulting offsetting is in-bounds of the allocated object, which is /// always the case for references, but needs to be upheld manually for pointers -#[cfg(not(bootstrap))] #[rustc_nounwind] #[rustc_intrinsic] pub const unsafe fn slice_get_unchecked< @@ -3710,7 +3678,7 @@ pub const fn minnumf128(x: f128, y: f128) -> f128; /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn minimumf16(x: f16, y: f16) -> f16 { if x < y { x @@ -3731,7 +3699,7 @@ pub const fn minimumf16(x: f16, y: f16) -> f16 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn minimumf32(x: f32, y: f32) -> f32 { if x < y { x @@ -3752,7 +3720,7 @@ pub const fn minimumf32(x: f32, y: f32) -> f32 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn minimumf64(x: f64, y: f64) -> f64 { if x < y { x @@ -3773,7 +3741,7 @@ pub const fn minimumf64(x: f64, y: f64) -> f64 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn minimumf128(x: f128, y: f128) -> f128 { if x < y { x @@ -3848,7 +3816,7 @@ pub const fn maxnumf128(x: f128, y: f128) -> f128; /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn maximumf16(x: f16, y: f16) -> f16 { if x > y { x @@ -3868,7 +3836,7 @@ pub const fn maximumf16(x: f16, y: f16) -> f16 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn maximumf32(x: f32, y: f32) -> f32 { if x > y { x @@ -3888,7 +3856,7 @@ pub const fn maximumf32(x: f32, y: f32) -> f32 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn maximumf64(x: f64, y: f64) -> f64 { if x > y { x @@ -3908,7 +3876,7 @@ pub const fn maximumf64(x: f64, y: f64) -> f64 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn maximumf128(x: f128, y: f128) -> f128 { if x > y { x diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 989ab80b77d41..f2a5c40bada0b 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -187,7 +187,6 @@ // // Target features: // tidy-alphabetical-start -#![cfg_attr(bootstrap, feature(avx512_target_feature))] #![feature(aarch64_unstable_target_feature)] #![feature(arm_target_feature)] #![feature(hexagon_target_feature)] @@ -225,7 +224,6 @@ pub mod assert_matches { // We don't export this through #[macro_export] for now, to avoid breakage. #[unstable(feature = "autodiff", issue = "124509")] -#[cfg(not(bootstrap))] /// Unstable module containing the unstable `autodiff` macro. pub mod autodiff { #[unstable(feature = "autodiff", issue = "124509")] diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index e70a1dab6e9a9..d5efb03cfbcbf 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -1533,7 +1533,6 @@ pub(crate) mod builtin { #[unstable(feature = "autodiff", issue = "124509")] #[allow_internal_unstable(rustc_attrs)] #[rustc_builtin_macro] - #[cfg(not(bootstrap))] pub macro autodiff_forward($item:item) { /* compiler built-in */ } @@ -1552,7 +1551,6 @@ pub(crate) mod builtin { #[unstable(feature = "autodiff", issue = "124509")] #[allow_internal_unstable(rustc_attrs)] #[rustc_builtin_macro] - #[cfg(not(bootstrap))] pub macro autodiff_reverse($item:item) { /* compiler built-in */ } diff --git a/library/core/src/slice/index.rs b/library/core/src/slice/index.rs index 69160a911b212..f725c3fdd94cc 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -1,6 +1,5 @@ //! Indexing implementations for `[T]`. -#[cfg(not(bootstrap))] use crate::intrinsics::slice_get_unchecked; use crate::panic::const_panic; use crate::ub_checks::assert_unsafe_precondition; @@ -85,22 +84,6 @@ const fn slice_end_index_overflow_fail() -> ! { // Both the safe and unsafe public methods share these helpers, // which use intrinsics directly to get *no* extra checks. -#[cfg(bootstrap)] -#[inline(always)] -const unsafe fn get_noubcheck(ptr: *const [T], index: usize) -> *const T { - let ptr = ptr as *const T; - // SAFETY: The caller already checked these preconditions - unsafe { crate::intrinsics::offset(ptr, index) } -} - -#[cfg(bootstrap)] -#[inline(always)] -const unsafe fn get_mut_noubcheck(ptr: *mut [T], index: usize) -> *mut T { - let ptr = ptr as *mut T; - // SAFETY: The caller already checked these preconditions - unsafe { crate::intrinsics::offset(ptr, index) } -} - #[inline(always)] const unsafe fn get_offset_len_noubcheck( ptr: *const [T], @@ -231,16 +214,8 @@ unsafe impl SliceIndex<[T]> for usize { #[inline] fn get(self, slice: &[T]) -> Option<&T> { if self < slice.len() { - #[cfg(bootstrap)] - // SAFETY: `self` is checked to be in bounds. - unsafe { - Some(&*get_noubcheck(slice, self)) - } - #[cfg(not(bootstrap))] // SAFETY: `self` is checked to be in bounds. - unsafe { - Some(slice_get_unchecked(slice, self)) - } + unsafe { Some(slice_get_unchecked(slice, self)) } } else { None } @@ -249,16 +224,8 @@ unsafe impl SliceIndex<[T]> for usize { #[inline] fn get_mut(self, slice: &mut [T]) -> Option<&mut T> { if self < slice.len() { - #[cfg(bootstrap)] // SAFETY: `self` is checked to be in bounds. - unsafe { - Some(&mut *get_mut_noubcheck(slice, self)) - } - #[cfg(not(bootstrap))] - // SAFETY: `self` is checked to be in bounds. - unsafe { - Some(slice_get_unchecked(slice, self)) - } + unsafe { Some(slice_get_unchecked(slice, self)) } } else { None } @@ -280,14 +247,7 @@ unsafe impl SliceIndex<[T]> for usize { // Use intrinsics::assume instead of hint::assert_unchecked so that we don't check the // precondition of this function twice. crate::intrinsics::assume(self < slice.len()); - #[cfg(bootstrap)] - { - get_noubcheck(slice, self) - } - #[cfg(not(bootstrap))] - { - slice_get_unchecked(slice, self) - } + slice_get_unchecked(slice, self) } } @@ -300,16 +260,7 @@ unsafe impl SliceIndex<[T]> for usize { (this: usize = self, len: usize = slice.len()) => this < len ); // SAFETY: see comments for `get_unchecked` above. - unsafe { - #[cfg(bootstrap)] - { - get_mut_noubcheck(slice, self) - } - #[cfg(not(bootstrap))] - { - slice_get_unchecked(slice, self) - } - } + unsafe { slice_get_unchecked(slice, self) } } #[inline] diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index b43f3bad6e2c3..ea459f6d92d86 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -3822,23 +3822,6 @@ unsafe fn atomic_store(dst: *mut T, val: T, order: Ordering) { #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces -#[cfg(bootstrap)] -unsafe fn atomic_load(dst: *const T, order: Ordering) -> T { - // SAFETY: the caller must uphold the safety contract for `atomic_load`. - unsafe { - match order { - Relaxed => intrinsics::atomic_load_relaxed(dst), - Acquire => intrinsics::atomic_load_acquire(dst), - SeqCst => intrinsics::atomic_load_seqcst(dst), - Release => panic!("there is no such thing as a release load"), - AcqRel => panic!("there is no such thing as an acquire-release load"), - } - } -} - -#[inline] -#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces -#[cfg(not(bootstrap))] unsafe fn atomic_load(dst: *const T, order: Ordering) -> T { use intrinsics::AtomicOrdering; // SAFETY: the caller must uphold the safety contract for `atomic_load`. diff --git a/library/coretests/tests/num/mod.rs b/library/coretests/tests/num/mod.rs index fa05bbdd9b774..c68b569f86b3a 100644 --- a/library/coretests/tests/num/mod.rs +++ b/library/coretests/tests/num/mod.rs @@ -951,7 +951,6 @@ macro_rules! test_float { assert!(<$fty>::NAN.div_euclid(<$fty>::INFINITY).is_nan()); } #[test] - #[cfg(not(bootstrap))] fn floor() { $fassert!((0.0 as $fty).floor(), 0.0); $fassert!((0.0 as $fty).floor().is_sign_positive()); @@ -969,7 +968,6 @@ macro_rules! test_float { $fassert!(<$fty>::NEG_INFINITY.floor(), <$fty>::NEG_INFINITY); } #[test] - #[cfg(not(bootstrap))] fn ceil() { $fassert!((0.0 as $fty).ceil(), 0.0); $fassert!((0.0 as $fty).ceil().is_sign_positive()); @@ -986,7 +984,6 @@ macro_rules! test_float { $fassert!(<$fty>::NEG_INFINITY.ceil(), <$fty>::NEG_INFINITY); } #[test] - #[cfg(not(bootstrap))] fn round() { $fassert!((0.0 as $fty).round(), 0.0); $fassert!((0.0 as $fty).round().is_sign_positive()); @@ -1003,7 +1000,6 @@ macro_rules! test_float { $fassert!(<$fty>::NEG_INFINITY.round(), <$fty>::NEG_INFINITY); } #[test] - #[cfg(not(bootstrap))] fn round_ties_even() { $fassert!((0.0 as $fty).round_ties_even(), 0.0); $fassert!((0.0 as $fty).round_ties_even().is_sign_positive()); @@ -1022,7 +1018,6 @@ macro_rules! test_float { $fassert!(<$fty>::NEG_INFINITY.round_ties_even(), <$fty>::NEG_INFINITY); } #[test] - #[cfg(not(bootstrap))] fn trunc() { $fassert!((0.0 as $fty).trunc(), 0.0); $fassert!((0.0 as $fty).trunc().is_sign_positive()); @@ -1041,7 +1036,6 @@ macro_rules! test_float { $fassert!(<$fty>::NEG_INFINITY.trunc(), <$fty>::NEG_INFINITY); } #[test] - #[cfg(not(bootstrap))] fn fract() { $fassert!((0.0 as $fty).fract(), 0.0); $fassert!((0.0 as $fty).fract().is_sign_positive()); diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 74a3433986020..f729c2ab43336 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -276,12 +276,12 @@ // tidy-alphabetical-start // stabilization was reverted after it hit beta -#![cfg_attr(not(bootstrap), feature(autodiff))] #![feature(alloc_error_handler)] #![feature(allocator_internals)] #![feature(allow_internal_unsafe)] #![feature(allow_internal_unstable)] #![feature(asm_experimental_arch)] +#![feature(autodiff)] #![feature(cfg_sanitizer_cfi)] #![feature(cfg_target_thread_local)] #![feature(cfi_encoding)] @@ -641,7 +641,6 @@ pub mod simd { } #[unstable(feature = "autodiff", issue = "124509")] -#[cfg(not(bootstrap))] /// This module provides support for automatic differentiation. pub mod autodiff { /// This macro handles automatic differentiation. From c87b072952b75f2cfb05882efca49c58894f20aa Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 2 Jun 2025 14:30:00 -0700 Subject: [PATCH 17/17] Remove more library bootstrap --- library/alloc/Cargo.toml | 1 - library/alloc/src/lib.rs | 1 - library/alloctests/Cargo.toml | 1 - library/core/Cargo.toml | 1 - library/core/src/pin.rs | 1 - library/std/Cargo.toml | 1 - library/std/src/lib.rs | 7 +------ 7 files changed, 1 insertion(+), 12 deletions(-) diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml index 365c9dc00dfc5..31b6014af7c17 100644 --- a/library/alloc/Cargo.toml +++ b/library/alloc/Cargo.toml @@ -32,7 +32,6 @@ optimize_for_size = ["core/optimize_for_size"] [lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ - 'cfg(bootstrap)', 'cfg(no_global_oom_handling)', 'cfg(no_rc)', 'cfg(no_sync)', diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index abda5aefab645..30540f48aa105 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -66,7 +66,6 @@ )] #![doc(cfg_hide( not(test), - not(any(test, bootstrap)), no_global_oom_handling, not(no_global_oom_handling), not(no_rc), diff --git a/library/alloctests/Cargo.toml b/library/alloctests/Cargo.toml index 306375f5f01cc..07c45d1b82484 100644 --- a/library/alloctests/Cargo.toml +++ b/library/alloctests/Cargo.toml @@ -39,7 +39,6 @@ harness = false [lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ - 'cfg(bootstrap)', 'cfg(no_global_oom_handling)', 'cfg(no_rc)', 'cfg(no_sync)', diff --git a/library/core/Cargo.toml b/library/core/Cargo.toml index 83ba17b93f519..f88661ee00151 100644 --- a/library/core/Cargo.toml +++ b/library/core/Cargo.toml @@ -29,7 +29,6 @@ debug_typeid = [] [lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ - 'cfg(bootstrap)', 'cfg(no_fp_fmt_parse)', # core use #[path] imports to portable-simd `core_simd` crate # and to stdarch `core_arch` crate which messes-up with Cargo list diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index aad073cc8cdd0..ba687434bf102 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -1092,7 +1092,6 @@ pub use self::unsafe_pinned::UnsafePinned; #[rustc_pub_transparent] #[derive(Copy, Clone)] pub struct Pin { - /// Only public for bootstrap. pointer: Ptr, } diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 31371f06b3865..196b904d56a1e 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -157,7 +157,6 @@ test = true [lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ - 'cfg(bootstrap)', # std use #[path] imports to portable-simd `std_float` crate # and to the `backtrace` crate which messes-up with Cargo list # of declared features, we therefor expect any feature cfg diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index f729c2ab43336..7c54e731edc62 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -235,12 +235,7 @@ test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))) )] #![doc(rust_logo)] -#![doc(cfg_hide( - not(test), - not(any(test, bootstrap)), - no_global_oom_handling, - not(no_global_oom_handling) -))] +#![doc(cfg_hide(not(test), no_global_oom_handling, not(no_global_oom_handling)))] // Don't link to std. We are std. #![no_std] // Tell the compiler to link to either panic_abort or panic_unwind