Skip to content

Rollup of 13 pull requests #141941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
200d742
Clarify &mut-methods' docs on sync::OnceLock
lukaslueg May 6, 2025
81f61ac
rustc_llvm: add Windows system libs only when cross-compiling from Wi…
mati865 Apr 27, 2025
f023a69
Async drop - type instead of async drop fn and incorrect drop signatu…
azhogin May 28, 2025
b9007f5
test that the abi of c-variadic functions is checked in `extern` blocks
folkertdev May 29, 2025
30ddd3c
error on a `safe fn` that uses C-variadics
folkertdev May 29, 2025
c5e758d
Fixed a typo in `ManuallyDrop`'s doc
neeko-cat Jun 1, 2025
87054fc
Add missing 2015 edition directives
Veykril Jun 2, 2025
aba70e8
Add missing `dyn` keywords to tests that do not test for them
Veykril Jun 2, 2025
a5f7d44
add test for 141764
jdonszelmann Jun 2, 2025
2e527f0
fix bug where borrowck tries to describe a name from a macro in anoth…
jdonszelmann Jun 2, 2025
80e44de
remove f16: From<u16>
usamoi Jun 2, 2025
6be3c3c
[rustdoc-json] Implement PartialOrd and Ord for rustdoc_types::Id
LukeMathWalker Jun 2, 2025
8b5b6d0
add fixme to improve error matching
jdonszelmann Jun 2, 2025
b0041b8
Disable f64 minimum/maximum tests for arm 32
ehuss Jun 2, 2025
bb5de7d
Update books
rustbot Jun 2, 2025
19e02c8
Remove bootstrap cfgs from library/
cuviper Jun 2, 2025
c87b072
Remove more library bootstrap
cuviper Jun 2, 2025
a9e7b84
Rollup merge of #140715 - lukaslueg:oncecellsyncdocs, r=tgross35
workingjubilee Jun 3, 2025
79d5b99
Rollup merge of #141677 - azhogin:azhogin/async-drop-unexpected-type-…
workingjubilee Jun 3, 2025
5afb5c4
Rollup merge of #141733 - folkertdev:c-variadic-unsafe-at-any-speed, …
workingjubilee Jun 3, 2025
78e8c83
Rollup merge of #141817 - mati865:fix-system-libs-when-cross-compilin…
workingjubilee Jun 3, 2025
beba312
Rollup merge of #141873 - neeko-cat:patch-1, r=tgross35
workingjubilee Jun 3, 2025
ffac42d
Rollup merge of #141886 - ferrocene:lw/2015-edition-directives, r=com…
workingjubilee Jun 3, 2025
13a6647
Rollup merge of #141889 - ferrocene:lw/missing-dyn-kw, r=petrochenkov
workingjubilee Jun 3, 2025
8517605
Rollup merge of #141891 - jdonszelmann:fix-141764, r=jieyouxu
workingjubilee Jun 3, 2025
265e716
Rollup merge of #141893 - usamoi:lossless, r=tgross35
workingjubilee Jun 3, 2025
2e57484
Rollup merge of #141898 - LukeMathWalker:patch-1, r=aDotInTheVoid
workingjubilee Jun 3, 2025
94d7ee0
Rollup merge of #141921 - ehuss:arm-min-max, r=tgross35
workingjubilee Jun 3, 2025
45f104a
Rollup merge of #141923 - rustbot:docs-update, r=ehuss
workingjubilee Jun 3, 2025
316ea33
Rollup merge of #141925 - cuviper:vestigial-bootstrap, r=workingjubilee
workingjubilee Jun 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions compiler/rustc_ast_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
16 changes: 15 additions & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, .. }, _)
Expand Down
15 changes: 14 additions & 1 deletion compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Span>,
}

#[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> {
Expand Down
24 changes: 16 additions & 8 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}",),
);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
16 changes: 14 additions & 2 deletions compiler/rustc_mir_transform/src/elaborate_drop.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion library/alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand Down
1 change: 0 additions & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion library/alloctests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand Down
1 change: 0 additions & 1 deletion library/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion library/core/src/convert/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]);
Expand Down
48 changes: 8 additions & 40 deletions library/core/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,38 +413,7 @@ pub unsafe fn atomic_cxchgweak_seqcst_seqcst<T: Copy>(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<T: Copy, const ORD: AtomicOrdering>(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<T: Copy>(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<T: Copy>(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<T: Copy>(src: *const T) -> T;

/// Stores the value at the specified memory location.
/// `T` must be an integer or pointer type.
Expand Down Expand Up @@ -1767,7 +1736,6 @@ pub const unsafe fn arith_offset<T>(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<
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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")]
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Expand All @@ -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 */
}
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/mem/manually_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ use crate::ptr;
/// use std::mem::ManuallyDrop;
///
/// pub struct BadOption<T> {
/// // Invariant: Has been dropped iff `is_some` is false.
/// // Invariant: Has been dropped if `is_some` is false.
/// value: ManuallyDrop<T>,
/// is_some: bool,
/// }
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion library/core/src/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,6 @@ pub use self::unsafe_pinned::UnsafePinned;
#[rustc_pub_transparent]
#[derive(Copy, Clone)]
pub struct Pin<Ptr> {
/// Only public for bootstrap.
pointer: Ptr,
}

Expand Down
Loading
Loading