Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6f2cdf7
Only create a reset block if there are flags to reset.
cjgillot Jun 5, 2026
a3a56d7
Emit global arrays specifying the ranges of interior mutable and pinn…
icmccorm Jul 12, 2026
024bd5e
Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>
zakrad Jul 24, 2026
e4b881f
Align expect messages with guidance
pluiee Jul 27, 2026
aa1b09a
make atomic operations const
RalfJung Jul 28, 2026
0c06c43
Add tool-attribute test to ensure tools are not preserved across crate
nbdd0121 Jul 29, 2026
aed6786
Remove an outdated FIXME
ada4a Jul 30, 2026
a87d3c3
Add fast path for ZSTs.
icmccorm Jul 30, 2026
6436f0c
Reject invalid identifiers in register_tool
nbdd0121 Jul 29, 2026
83ed6e4
Add lint for duplicate tools
nbdd0121 Jul 29, 2026
6da3077
Structurally prevent zero-count `BackendRepr::SimdVector`s
scottmcm Jul 29, 2026
ed76f84
remove `hidden_glob_reexports`
mejrs Jul 25, 2026
f5b4f8d
Prefix `rustc_ast::token` types with `tk::`
mejrs Jul 25, 2026
64d75c3
Add regression test showing old behaviour
JonathanBrouwer Jul 31, 2026
c1bcbb4
Improve diagnostic for patterns in function pointer types
JonathanBrouwer Jul 31, 2026
6d0b490
Add documentation for the `non_exhaustive` attribute
Kristianerik Jul 31, 2026
0a32236
Preemptively fetch the typeck results when linting bodies.
Jarcho Jun 15, 2026
102b6fd
Remove `maybe_typeck_results` from `LateContext`.
Jarcho Jun 15, 2026
4af1e41
Make `#[fundamental]` only apply to the first argument of `Box`
nia-e Jul 31, 2026
507283d
Emit better diagnostic suggestions for trait implementations on tuples
rperier Jul 18, 2026
c9681b2
Update `minifier` version to `0.4.0`
GuillaumeGomez Jul 31, 2026
e0d1389
Rollup merge of #159195 - cjgillot:elaborate-drop-flags, r=saethlin
jhpratt Aug 1, 2026
b10c756
Rollup merge of #159245 - BorrowSanitizer:codegen-emit-retag-5, r=sae…
jhpratt Aug 1, 2026
6c66864
Rollup merge of #159864 - zakrad:fix-136797-rc-arc-capacity-overflow,…
jhpratt Aug 1, 2026
b85cffb
Rollup merge of #160079 - RalfJung:const-atomic, r=folkertdev
jhpratt Aug 1, 2026
44ef1dd
Rollup merge of #160124 - scottmcm:simd-count, r=oli-obk
jhpratt Aug 1, 2026
9c8584b
Rollup merge of #160162 - nia-e:per-arg-fundamental, r=jackh726
jhpratt Aug 1, 2026
5000500
Rollup merge of #160210 - ada4a:push-mnsnynmrtlyp, r=notriddle
jhpratt Aug 1, 2026
029d771
Rollup merge of #160282 - JonathanBrouwer:arg-pattern, r=petrochenkov
jhpratt Aug 1, 2026
b4c0b5d
Rollup merge of #157928 - Jarcho:eager_typeck, r=adwinwhite
jhpratt Aug 1, 2026
28e4174
Rollup merge of #159672 - rperier:better_suggestions_for_trait_impls_…
jhpratt Aug 1, 2026
b47a31a
Rollup merge of #159861 - Kristianerik:docs-non-exhaustive-attribute,…
jhpratt Aug 1, 2026
48e4b2b
Rollup merge of #159907 - mejrs:fix_globby, r=TaKO8Ki
jhpratt Aug 1, 2026
c79434d
Rollup merge of #159998 - pluiee:pluiee/expect-msg, r=fee1-dead
jhpratt Aug 1, 2026
3c8cf2c
Rollup merge of #160145 - nbdd0121:register_tool, r=mejrs
jhpratt Aug 1, 2026
49811c9
Rollup merge of #160307 - GuillaumeGomez:update-minifier, r=Guillaume…
jhpratt Aug 1, 2026
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
22 changes: 11 additions & 11 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]

[[package]]
Expand Down Expand Up @@ -1261,7 +1261,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]

[[package]]
Expand Down Expand Up @@ -1388,7 +1388,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]

[[package]]
Expand Down Expand Up @@ -2166,7 +2166,7 @@ dependencies = [
"portable-atomic",
"portable-atomic-util",
"serde_core",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]

[[package]]
Expand Down Expand Up @@ -2515,9 +2515,9 @@ dependencies = [

[[package]]
name = "minifier"
version = "0.3.6"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14f1541610994bba178cb36757e102d06a52a2d9612aa6d34c64b3b377c5d943"
checksum = "245c950e30794ed20f72ff60c85ae1cddb0ba54fda4623017a678943f98f636c"

[[package]]
name = "minimal-lexical"
Expand Down Expand Up @@ -2653,7 +2653,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]

[[package]]
Expand Down Expand Up @@ -5085,7 +5085,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]

[[package]]
Expand Down Expand Up @@ -5517,7 +5517,7 @@ dependencies = [
"getrandom 0.3.3",
"once_cell",
"rustix",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]

[[package]]
Expand All @@ -5536,7 +5536,7 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8c27177b12a6399ffc08b98f76f7c9a1f4fe9fc967c784c5a071fa8d93cf7e1"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]

[[package]]
Expand Down Expand Up @@ -6514,7 +6514,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]

[[package]]
Expand Down
23 changes: 11 additions & 12 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::fmt::{self, Write};
use std::num::NonZero;
use std::ops::Deref;
use std::range::{RangeFrom, RangeInclusive, RangeToInclusive};
use std::{cmp, iter};
Expand All @@ -9,8 +10,8 @@ use rustc_index::bit_set::BitMatrix;
use tracing::{debug, trace};

use crate::{
AbiAlign, Align, BackendRepr, FieldsShape, HasDataLayout, IndexSlice, IndexVec, Integer,
LayoutData, Niche, NonZeroUsize, NumScalableVectors, Primitive, ReprOptions, Scalar, Size,
AbiAlign, Align, BackendLaneCount, BackendRepr, FieldsShape, HasDataLayout, IndexSlice,
IndexVec, Integer, LayoutData, Niche, NumScalableVectors, Primitive, ReprOptions, Scalar, Size,
StructKind, TagEncoding, TargetDataLayout, VariantLayout, Variants, WrappingRange,
};

Expand Down Expand Up @@ -127,7 +128,7 @@ pub enum LayoutCalculatorError<F> {
ZeroLengthSimdType,

/// The length of an SIMD type exceeds the maximum number of lanes
OversizedSimdType { max_lanes: u64 },
OversizedSimdType { max_lanes: usize },

/// An element type of an SIMD type isn't a primitive
NonPrimitiveSimdType(F),
Expand Down Expand Up @@ -495,7 +496,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
},
};

let Some(union_field_count) = NonZeroUsize::new(only_variant.len()) else {
let Some(union_field_count) = NonZero::new(only_variant.len()) else {
return Err(LayoutCalculatorError::EmptyUnion);
};

Expand Down Expand Up @@ -1476,19 +1477,17 @@ where
F: AsRef<LayoutData<FieldIdx, VariantIdx>> + fmt::Debug,
{
let elt = element.as_ref();
if count == 0 {
return Err(LayoutCalculatorError::ZeroLengthSimdType);
} else if count > crate::MAX_SIMD_LANES {
return Err(LayoutCalculatorError::OversizedSimdType { max_lanes: crate::MAX_SIMD_LANES });
}
let count = BackendLaneCount::new(count)?;

let BackendRepr::Scalar(element) = elt.backend_repr else {
return Err(LayoutCalculatorError::NonPrimitiveSimdType(element));
};

// Compute the size and alignment of the vector
let size =
elt.size.checked_mul(count, dl).ok_or_else(|| LayoutCalculatorError::SizeOverflow)?;
let size = elt
.size
.checked_mul(count.as_u64(), dl)
.ok_or_else(|| LayoutCalculatorError::SizeOverflow)?;
let (repr, size, align) = match kind {
SimdVectorKind::Scalable(number_of_vectors) => (
BackendRepr::SimdScalableVector { element, count, number_of_vectors },
Expand Down Expand Up @@ -1521,6 +1520,6 @@ where
align: AbiAlign::new(align),
max_repr_align: None,
unadjusted_abi_align: elt.align.abi,
randomization_seed: elt.randomization_seed.wrapping_add(Hash64::new(count)),
randomization_seed: elt.randomization_seed.wrapping_add(Hash64::new(count.as_u64())),
})
}
47 changes: 41 additions & 6 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use std::cmp::min;
use std::fmt;
#[cfg(feature = "nightly")]
use std::iter::Step;
use std::num::{NonZeroUsize, ParseIntError};
use std::num::{NonZero, ParseIntError};
use std::ops::{Add, AddAssign, Deref, Mul, Sub};
use std::range::RangeInclusive;
use std::str::FromStr;
Expand Down Expand Up @@ -244,7 +244,42 @@ impl ReprOptions {
/// This value is selected based on backend support:
/// * LLVM does not appear to have a vector width limit.
/// * Cranelift stores the base-2 log of the lane count in a 4 bit integer.
pub const MAX_SIMD_LANES: u64 = 1 << 0xF;
pub const MAX_SIMD_LANES: u16 = 1 << 0xF;

/// The number of lanes in a [`BackendRepr::SimdVector`], `1..=`[`MAX_SIMD_LANES`].
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))]
pub struct BackendLaneCount(NonZero<u16>);

impl BackendLaneCount {
pub fn new<N>(count: u64) -> Result<Self, LayoutCalculatorError<N>> {
let Ok(count @ ..=MAX_SIMD_LANES) = u16::try_from(count) else {
return Err(LayoutCalculatorError::OversizedSimdType {
max_lanes: crate::MAX_SIMD_LANES.into(),
});
};
if let Some(count) = NonZero::new(count) {
Ok(BackendLaneCount(count))
} else {
Err(LayoutCalculatorError::ZeroLengthSimdType)
}
}

#[inline]
pub fn is_power_of_two(self) -> bool {
self.0.is_power_of_two()
}

#[inline]
pub fn as_u64(self) -> u64 {
self.0.get().into()
}

#[inline]
pub fn as_u32(self) -> u32 {
self.0.get().into()
}
}

/// How pointers are represented in a given address space
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -1611,7 +1646,7 @@ pub enum FieldsShape<FieldIdx: Idx> {
Primitive,

/// All fields start at no offset. The `usize` is the field count.
Union(NonZeroUsize),
Union(NonZero<usize>),

/// Array/vector-like placement, with all fields of identical types.
Array { stride: Size, count: u64 },
Expand Down Expand Up @@ -1770,12 +1805,12 @@ pub enum BackendRepr {
},
SimdScalableVector {
element: Scalar,
count: u64,
count: BackendLaneCount,
number_of_vectors: NumScalableVectors,
},
SimdVector {
element: Scalar,
count: u64,
count: BackendLaneCount,
},
// FIXME: I sometimes use memory, sometimes use an IR aggregate!
Memory {
Expand Down Expand Up @@ -2260,7 +2295,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
}

/// Returns the elements count of a scalable vector.
pub fn scalable_vector_element_count(&self) -> Option<u64> {
pub fn scalable_vector_element_count(&self) -> Option<BackendLaneCount> {
match self.backend_repr {
BackendRepr::SimdScalableVector { count, .. } => Some(count),
_ => None,
Expand Down
33 changes: 15 additions & 18 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ pub use TokenKind::*;
use rustc_macros::{Decodable, Encodable, StableHash};
use rustc_span::edition::Edition;
use rustc_span::symbol::IdentPrintMode;
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, kw, sym};
#[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint.
#[allow(hidden_glob_reexports)]
use rustc_span::{Ident, Symbol};
use rustc_span::{self as sp, DUMMY_SP, ErrorGuaranteed, Span, Symbol, kw, sym};

use crate::ast;
use crate::util::case::Case;
Expand Down Expand Up @@ -506,7 +503,7 @@ pub enum TokenKind {
/// This identifier (and its span) is the identifier passed to the
/// declarative macro. The span in the surrounding `Token` is the span of
/// the `ident` metavariable in the macro's RHS.
NtIdent(Ident, IdentIsRaw),
NtIdent(sp::Ident, IdentIsRaw),

/// Lifetime identifier token.
/// Do not forget about `NtLifetime` when you want to match on lifetime identifiers.
Expand All @@ -517,7 +514,7 @@ pub enum TokenKind {
/// This identifier (and its span) is the lifetime passed to the
/// declarative macro. The span in the surrounding `Token` is the span of
/// the `lifetime` metavariable in the macro's RHS.
NtLifetime(Ident, IdentIsRaw),
NtLifetime(sp::Ident, IdentIsRaw),

/// A doc comment token.
/// `Symbol` is the doc comment's data excluding its "quotes" (`///`, `/**`, etc)
Expand Down Expand Up @@ -637,7 +634,7 @@ impl Token {
}

/// Recovers a `Token` from an `Ident`. This creates a raw identifier if necessary.
pub fn from_ast_ident(ident: Ident) -> Self {
pub fn from_ast_ident(ident: sp::Ident) -> Self {
Token::new(Ident(ident.name, ident.is_raw_guess().into()), ident.span)
}

Expand Down Expand Up @@ -845,21 +842,21 @@ impl Token {

/// Returns an identifier if this token is an identifier.
#[inline]
pub fn ident(&self) -> Option<(Ident, IdentIsRaw)> {
pub fn ident(&self) -> Option<(sp::Ident, IdentIsRaw)> {
// We avoid using `Token::uninterpolate` here because it's slow.
match self.kind {
Ident(name, is_raw) => Some((Ident::new(name, self.span), is_raw)),
Ident(name, is_raw) => Some((sp::Ident::new(name, self.span), is_raw)),
NtIdent(ident, is_raw) => Some((ident, is_raw)),
_ => None,
}
}

/// Returns a lifetime identifier if this token is a lifetime.
#[inline]
pub fn lifetime(&self) -> Option<(Ident, IdentIsRaw)> {
pub fn lifetime(&self) -> Option<(sp::Ident, IdentIsRaw)> {
// We avoid using `Token::uninterpolate` here because it's slow.
match self.kind {
Lifetime(name, is_raw) => Some((Ident::new(name, self.span), is_raw)),
Lifetime(name, is_raw) => Some((sp::Ident::new(name, self.span), is_raw)),
NtLifetime(ident, is_raw) => Some((ident, is_raw)),
_ => None,
}
Expand Down Expand Up @@ -934,32 +931,32 @@ impl Token {
}

pub fn is_path_segment_keyword(&self) -> bool {
self.is_non_raw_ident_where(Ident::is_path_segment_keyword)
self.is_non_raw_ident_where(sp::Ident::is_path_segment_keyword)
}

/// Returns true for reserved identifiers used internally for elided lifetimes,
/// unnamed method parameters, crate root module, error recovery etc.
pub fn is_special_ident(&self) -> bool {
self.is_non_raw_ident_where(Ident::is_special)
self.is_non_raw_ident_where(sp::Ident::is_special)
}

/// Returns `true` if the token is a keyword used in the language.
pub fn is_used_keyword(&self) -> bool {
self.is_non_raw_ident_where(Ident::is_used_keyword)
self.is_non_raw_ident_where(sp::Ident::is_used_keyword)
}

/// Returns `true` if the token is a keyword reserved for possible future use.
pub fn is_unused_keyword(&self) -> bool {
self.is_non_raw_ident_where(Ident::is_unused_keyword)
self.is_non_raw_ident_where(sp::Ident::is_unused_keyword)
}

/// Returns `true` if the token is either a special identifier or a keyword.
pub fn is_reserved_ident(&self) -> bool {
self.is_non_raw_ident_where(Ident::is_reserved)
self.is_non_raw_ident_where(sp::Ident::is_reserved)
}

pub fn is_non_reserved_ident(&self) -> bool {
self.ident().is_some_and(|(id, raw)| raw == IdentIsRaw::Yes || !Ident::is_reserved(id))
self.ident().is_some_and(|(id, raw)| raw == IdentIsRaw::Yes || !sp::Ident::is_reserved(id))
}

/// Returns `true` if the token is the identifier `true` or `false`.
Expand All @@ -980,7 +977,7 @@ impl Token {
}

/// Returns `true` if the token is a non-raw identifier for which `pred` holds.
pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(Ident) -> bool) -> bool {
pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(sp::Ident) -> bool) -> bool {
match self.ident() {
Some((id, IdentIsRaw::No)) => pred(id),
_ => false,
Expand Down
Loading
Loading