Skip to content

Rollup of 8 pull requests #144217

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 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c42b177
Add `uX::strict_sub_signed`
nxsaken Jul 1, 2025
79ed7c1
Test upper overflow in `strict_sub_signed`
nxsaken Jul 1, 2025
004478a
int_log10.rs: change top level doc comments to outer
hkBst Jul 2, 2025
f96d5d9
collect.rs: remove empty line after doc comment
hkBst Jul 2, 2025
ca4a712
clippy fix: markdown indentation for indented items after line break
hkBst Jul 3, 2025
8388b31
Split some multi-snapshot tests to make blessing easier
Zalathar Jul 18, 2025
7a217e1
Don't trigger an LLVM build from check builds using the stage 0 compiler
Zalathar Jul 16, 2025
a028ca5
Clean up an unused compiler-stage parameter
Zalathar Jul 16, 2025
cadcc1c
bootstrap: Ignore `rust.debuginfo-level-tests` for codegen tests
Enselic Jul 17, 2025
664d742
rustc_codegen_ssa: Don't skip target-features after crt-static
Gelbpunkt Jul 18, 2025
1b35d5f
tests: Add a regression test for crt-static with target features
Gelbpunkt Jul 18, 2025
2d51acd
tests: assembly: cstring-merging: Disable GlobalMerge pass
Gelbpunkt Jul 18, 2025
c79f62d
clippy fix: bound in one place
hkBst Jul 2, 2025
14d097f
Give a message with a span on validation error
scottmcm Jul 19, 2025
0586c63
Allow `Rvalue::Repeat` to return true in `rvalue_creates_operand` too
scottmcm Jul 10, 2025
4b8f869
Split repeat-operand codegen test
scottmcm Jul 20, 2025
9d530b9
Rollup merge of #143282 - nxsaken:strict_sub_signed, r=jhpratt
GuillaumeGomez Jul 20, 2025
6ab5f7a
Rollup merge of #143423 - hkBst:clippy-fix-1, r=workingjubilee
GuillaumeGomez Jul 20, 2025
8ceccd6
Rollup merge of #143720 - scottmcm:rvalue-always-operand, r=lcnr
GuillaumeGomez Jul 20, 2025
a17f123
Rollup merge of #144011 - Zalathar:check-compiler-no-llvm, r=Kobzol
GuillaumeGomez Jul 20, 2025
c8bd764
Rollup merge of #144112 - Enselic:no-debuginfo-in-codegen, r=Mark-Sim…
GuillaumeGomez Jul 20, 2025
d4e36c4
Rollup merge of #144143 - Gelbpunkt:target-features-crt-static, r=Ral…
GuillaumeGomez Jul 20, 2025
fe4b209
Rollup merge of #144150 - Gelbpunkt:globalmerge, r=Mark-Simulacrum
GuillaumeGomez Jul 20, 2025
30fdfca
Rollup merge of #144190 - scottmcm:spanned-errors-in-mir-validation, …
GuillaumeGomez Jul 20, 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
16 changes: 12 additions & 4 deletions compiler/rustc_codegen_ssa/src/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
OperandRef { val: OperandValue::Immediate(static_), layout }
}
mir::Rvalue::Use(ref operand) => self.codegen_operand(bx, operand),
mir::Rvalue::Repeat(..) => bug!("{rvalue:?} in codegen_rvalue_operand"),
mir::Rvalue::Repeat(ref elem, len_const) => {
// All arrays have `BackendRepr::Memory`, so only the ZST cases
// end up here. Anything else forces the destination local to be
// `Memory`, and thus ends up handled in `codegen_rvalue` instead.
let operand = self.codegen_operand(bx, elem);
let array_ty = Ty::new_array_with_const_len(bx.tcx(), operand.layout.ty, len_const);
let array_ty = self.monomorphize(array_ty);
let array_layout = bx.layout_of(array_ty);
assert!(array_layout.is_zst());
OperandRef { val: OperandValue::ZeroSized, layout: array_layout }
}
mir::Rvalue::Aggregate(ref kind, ref fields) => {
let (variant_index, active_field_index) = match **kind {
mir::AggregateKind::Adt(_, variant_index, _, _, active_field_index) => {
Expand Down Expand Up @@ -1000,12 +1010,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
mir::Rvalue::NullaryOp(..) |
mir::Rvalue::ThreadLocalRef(_) |
mir::Rvalue::Use(..) |
mir::Rvalue::Repeat(..) | // (*)
mir::Rvalue::Aggregate(..) | // (*)
mir::Rvalue::WrapUnsafeBinder(..) => // (*)
true,
// Arrays are always aggregates, so it's not worth checking anything here.
// (If it's really `[(); N]` or `[T; 0]` and we use the place path, fine.)
mir::Rvalue::Repeat(..) => false,
}

// (*) this is only true if the type is suitable
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ fn parse_rust_feature_flag<'a>(
if let Some(base_feature) = feature.strip_prefix('+') {
// Skip features that are not target features, but rustc features.
if RUSTC_SPECIFIC_FEATURES.contains(&base_feature) {
return;
continue;
}

callback(base_feature, sess.target.implied_target_features(base_feature), true)
} else if let Some(base_feature) = feature.strip_prefix('-') {
// Skip features that are not target features, but rustc features.
if RUSTC_SPECIFIC_FEATURES.contains(&base_feature) {
return;
continue;
}

// If `f1` implies `f2`, then `!f2` implies `!f1` -- this is standard logical
Expand Down
18 changes: 10 additions & 8 deletions compiler/rustc_mir_transform/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,16 @@ impl<'a, 'tcx> CfgChecker<'a, 'tcx> {
#[track_caller]
fn fail(&self, location: Location, msg: impl AsRef<str>) {
// We might see broken MIR when other errors have already occurred.
assert!(
self.tcx.dcx().has_errors().is_some(),
"broken MIR in {:?} ({}) at {:?}:\n{}",
self.body.source.instance,
self.when,
location,
msg.as_ref(),
);
if self.tcx.dcx().has_errors().is_none() {
span_bug!(
self.body.source_info(location).span,
"broken MIR in {:?} ({}) at {:?}:\n{}",
self.body.source.instance,
self.when,
location,
msg.as_ref(),
);
}
}

fn check_edge(&mut self, location: Location, bb: BasicBlock, edge_kind: EdgeKind) {
Expand Down
10 changes: 5 additions & 5 deletions library/core/src/async_iter/async_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ pub trait AsyncIterator {
/// async iterator state:
///
/// - `Poll::Pending` means that this async iterator's next value is not ready
/// yet. Implementations will ensure that the current task will be notified
/// when the next value may be ready.
/// yet. Implementations will ensure that the current task will be notified
/// when the next value may be ready.
///
/// - `Poll::Ready(Some(val))` means that the async iterator has successfully
/// produced a value, `val`, and may produce further values on subsequent
/// `poll_next` calls.
/// produced a value, `val`, and may produce further values on subsequent
/// `poll_next` calls.
///
/// - `Poll::Ready(None)` means that the async iterator has terminated, and
/// `poll_next` should not be invoked again.
/// `poll_next` should not be invoked again.
///
/// # Panics
///
Expand Down
5 changes: 3 additions & 2 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1482,13 +1482,14 @@ pub trait PartialOrd<Rhs: PointeeSized = Self>: PartialEq<Rhs> + PointeeSized {
}
}

fn default_chaining_impl<T: PointeeSized, U: PointeeSized>(
fn default_chaining_impl<T, U>(
lhs: &T,
rhs: &U,
p: impl FnOnce(Ordering) -> bool,
) -> ControlFlow<bool>
where
T: PartialOrd<U>,
T: PartialOrd<U> + PointeeSized,
U: PointeeSized,
{
// It's important that this only call `partial_cmp` once, not call `eq` then
// one of the relational operators. We don't want to `bcmp`-then-`memcp` a
Expand Down
1 change: 0 additions & 1 deletion library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,6 @@ impl Display for Arguments<'_> {
/// }";
/// assert_eq!(format!("The origin is: {origin:#?}"), expected);
/// ```

#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_on_unimplemented(
on(
Expand Down
1 change: 0 additions & 1 deletion library/core/src/iter/traits/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ pub trait Extend<A> {
/// **For implementors:** For a collection to unsafely rely on this method's safety precondition (that is,
/// invoke UB if they are violated), it must implement `extend_reserve` correctly. In other words,
/// callers may assume that if they `extend_reserve`ed enough space they can call this method.

// This method is for internal usage only. It is only on the trait because of specialization's limitations.
#[unstable(feature = "extend_one_unchecked", issue = "none")]
#[doc(hidden)]
Expand Down
8 changes: 4 additions & 4 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3414,10 +3414,10 @@ pub trait Iterator {
/// ```
#[stable(feature = "iter_copied", since = "1.36.0")]
#[rustc_diagnostic_item = "iter_copied"]
fn copied<'a, T: 'a>(self) -> Copied<Self>
fn copied<'a, T>(self) -> Copied<Self>
where
T: Copy + 'a,
Self: Sized + Iterator<Item = &'a T>,
T: Copy,
{
Copied::new(self)
}
Expand Down Expand Up @@ -3462,10 +3462,10 @@ pub trait Iterator {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "iter_cloned"]
fn cloned<'a, T: 'a>(self) -> Cloned<Self>
fn cloned<'a, T>(self) -> Cloned<Self>
where
T: Clone + 'a,
Self: Sized + Iterator<Item = &'a T>,
T: Clone,
{
Cloned::new(self)
}
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
//! return. You should mark your implementation using `#[panic_handler]`.
//!
//! * `rust_eh_personality` - is used by the failure mechanisms of the
//! compiler. This is often mapped to GCC's personality function, but crates
//! which do not trigger a panic can be assured that this function is never
//! called. The `lang` attribute is called `eh_personality`.
//! compiler. This is often mapped to GCC's personality function, but crates
//! which do not trigger a panic can be assured that this function is never
//! called. The `lang` attribute is called `eh_personality`.

#![stable(feature = "core", since = "1.6.0")]
#![doc(
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub use crate::intrinsics::transmute;
/// * If you want to leak memory, see [`Box::leak`].
/// * If you want to obtain a raw pointer to the memory, see [`Box::into_raw`].
/// * If you want to dispose of a value properly, running its destructor, see
/// [`mem::drop`].
/// [`mem::drop`].
///
/// # Safety
///
Expand Down
1 change: 0 additions & 1 deletion library/core/src/net/ip_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,6 @@ impl Ipv4Addr {
/// [IANA IPv4 Special-Purpose Address Registry]: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
/// [unspecified address]: Ipv4Addr::UNSPECIFIED
/// [broadcast address]: Ipv4Addr::BROADCAST
///
/// # Examples
///
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/num/int_log10.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// These functions compute the integer logarithm of their type, assuming
/// that someone has already checked that the value is strictly positive.
//! These functions compute the integer logarithm of their type, assuming
//! that someone has already checked that the value is strictly positive.
// 0 < val <= u8::MAX
#[inline]
Expand Down
45 changes: 41 additions & 4 deletions library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ macro_rules! uint_impl {
pub const fn strict_add(self, rhs: Self) -> Self {
let (a, b) = self.overflowing_add(rhs);
if b { overflow_panic::add() } else { a }
}
}

/// Unchecked integer addition. Computes `self + rhs`, assuming overflow
/// cannot occur.
Expand Down Expand Up @@ -653,7 +653,7 @@ macro_rules! uint_impl {
pub const fn strict_add_signed(self, rhs: $SignedT) -> Self {
let (a, b) = self.overflowing_add_signed(rhs);
if b { overflow_panic::add() } else { a }
}
}

/// Checked integer subtraction. Computes `self - rhs`, returning
/// `None` if overflow occurred.
Expand Down Expand Up @@ -713,7 +713,7 @@ macro_rules! uint_impl {
pub const fn strict_sub(self, rhs: Self) -> Self {
let (a, b) = self.overflowing_sub(rhs);
if b { overflow_panic::sub() } else { a }
}
}

/// Unchecked integer subtraction. Computes `self - rhs`, assuming overflow
/// cannot occur.
Expand Down Expand Up @@ -805,6 +805,43 @@ macro_rules! uint_impl {
}
}

/// Strict subtraction with a signed integer. Computes `self - rhs`,
/// panicking if overflow occurred.
///
/// # Panics
///
/// ## Overflow behavior
///
/// This function will always panic on overflow, regardless of whether overflow checks are enabled.
///
/// # Examples
///
/// ```
/// #![feature(strict_overflow_ops)]
#[doc = concat!("assert_eq!(3", stringify!($SelfT), ".strict_sub_signed(2), 1);")]
/// ```
///
/// The following panic because of overflow:
///
/// ```should_panic
/// #![feature(strict_overflow_ops)]
#[doc = concat!("let _ = 1", stringify!($SelfT), ".strict_sub_signed(2);")]
/// ```
///
/// ```should_panic
/// #![feature(strict_overflow_ops)]
#[doc = concat!("let _ = (", stringify!($SelfT), "::MAX).strict_sub_signed(-1);")]
/// ```
#[unstable(feature = "strict_overflow_ops", issue = "118260")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[track_caller]
pub const fn strict_sub_signed(self, rhs: $SignedT) -> Self {
let (a, b) = self.overflowing_sub_signed(rhs);
if b { overflow_panic::sub() } else { a }
}

#[doc = concat!(
"Checked integer subtraction. Computes `self - rhs` and checks if the result fits into an [`",
stringify!($SignedT), "`], returning `None` if overflow occurred."
Expand Down Expand Up @@ -913,7 +950,7 @@ macro_rules! uint_impl {
pub const fn strict_mul(self, rhs: Self) -> Self {
let (a, b) = self.overflowing_mul(rhs);
if b { overflow_panic::mul() } else { a }
}
}

/// Unchecked integer multiplication. Computes `self * rhs`, assuming overflow
/// cannot occur.
Expand Down
1 change: 0 additions & 1 deletion library/core/src/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,6 @@ mod prim_f16 {}
/// x = a + b + c + d; // As written
/// x = (a + c) + (b + d); // Reordered to shorten critical path and enable vectorization
/// ```

#[stable(feature = "rust1", since = "1.0.0")]
mod prim_f32 {}

Expand Down
20 changes: 10 additions & 10 deletions library/core/src/ptr/docs/as_uninit_slice.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ When calling this method, you have to ensure that *either* the pointer is null *
all of the following is true:

* The pointer must be [valid] for reads for `ptr.len() * size_of::<T>()` many bytes,
and it must be properly aligned. This means in particular:
and it must be properly aligned. This means in particular:

* The entire memory range of this slice must be contained within a single [allocation]!
Slices can never span across multiple allocations.
Slices can never span across multiple allocations.

* The pointer must be aligned even for zero-length slices. One
reason for this is that enum layout optimizations may rely on references
(including slices of any length) being aligned and non-null to distinguish
them from other data. You can obtain a pointer that is usable as `data`
for zero-length slices using [`NonNull::dangling()`].
reason for this is that enum layout optimizations may rely on references
(including slices of any length) being aligned and non-null to distinguish
them from other data. You can obtain a pointer that is usable as `data`
for zero-length slices using [`NonNull::dangling()`].

* The total size `ptr.len() * size_of::<T>()` of the slice must be no larger than `isize::MAX`.
See the safety documentation of [`pointer::offset`].
See the safety documentation of [`pointer::offset`].

* You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
In particular, while this reference exists, the memory the pointer points to must
not get mutated (except inside `UnsafeCell`).
arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
In particular, while this reference exists, the memory the pointer points to must
not get mutated (except inside `UnsafeCell`).

This applies even if the result of this method is unused!

Expand Down
1 change: 0 additions & 1 deletion library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2651,7 +2651,6 @@ impl str {
/// you're trying to parse into.
///
/// `parse` can parse into any type that implements the [`FromStr`] trait.

///
/// # Errors
///
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ impl Step for CodegenBackend {
cargo
.arg("--manifest-path")
.arg(builder.src.join(format!("compiler/rustc_codegen_{backend}/Cargo.toml")));
rustc_cargo_env(builder, &mut cargo, target, build_compiler.stage);
rustc_cargo_env(builder, &mut cargo, target);

let _guard = builder.msg_check(format!("rustc_codegen_{backend}"), target, None);

Expand Down
Loading
Loading