Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2f9fea1
Constify more Iterator functions
Randl Jun 20, 2026
7b633cc
implement const Iterator for Range
Randl Jun 20, 2026
0ce5394
Revert some const hacks
Randl Jun 20, 2026
8179204
Fix tests
Randl Jun 20, 2026
1b8478a
yeet DeepRegionResolver
jdonszelmann Sep 14, 2026
ac9666f
Add regression test for malformed RPITIT bound ICE with the new solver
zakrad Sep 15, 2026
e251a4b
wasm: return early on f128/i128
folkertdev Sep 15, 2026
9d60f86
rename `unwrap_trivial_aggregate` -> `is_aggregate_for_abi`
folkertdev Sep 15, 2026
9dcbee9
add `RegKind::from_primitive`
folkertdev Sep 15, 2026
2b72820
add `TyAbiInterface::is_enum`
folkertdev Sep 15, 2026
8aff3e6
wasm: fix ABI of `repr(int)` enums with ZST fields
folkertdev Sep 15, 2026
8420bbd
[rustc_pub] Expand PassMode::Cast with CastTarget
celinval Sep 15, 2026
5a1bf7f
Replace Opaque with ArgAttributes in PassMode
celinval Sep 15, 2026
bd13c1d
Rename ValueAbi to ValueRepr and fix abi docs
celinval Sep 15, 2026
0be3388
Avoid an intermediate vec when ref-decoding to `&'tcx [T]`
Zalathar Sep 16, 2026
3c74470
Remove some unused Decodable and RefDecodable impls
Zalathar Sep 16, 2026
8838b56
Migrate some RefDecodable impls to `impl_ref_decodable_into_arena!`
Zalathar Sep 16, 2026
82a24f2
Move RefDecodable and related impls into a submodule
Zalathar Sep 16, 2026
b993427
Miscellaneous tidying in `ref_decodable`
Zalathar Sep 16, 2026
a87b213
Consolidate the via-RefDecodable impls in `on_disk_cache`
Zalathar Sep 16, 2026
8dd9b9a
Remove an unused via-RefDecodable impl in rmeta decoding
Zalathar Sep 16, 2026
e8c03ab
Add a `#[diagnostic::on_unimplemented(..)]` hint to RefDecodable
Zalathar Sep 16, 2026
a3db66c
Remove the decoder type-param from RefDecodable
Zalathar Sep 16, 2026
0c12d6f
Remove redundant test
Randl Sep 16, 2026
3f8e2bf
Enable LLVM Thin LTO for LoongArch64
heiher Sep 8, 2026
cbf95cf
Rollup merge of #156216 - Randl:const-for-impl, r=clarfonthey
Zalathar Sep 16, 2026
ca7dfce
Rollup merge of #162748 - heiher:loong64-llvm-clang-thin-lto, r=jieyouxu
Zalathar Sep 16, 2026
4cea5cd
Rollup merge of #162769 - jdonszelmann:yeet-opportunistic-region-reso…
Zalathar Sep 16, 2026
08352d9
Rollup merge of #162800 - Zalathar:ref-decodable, r=nnethercote
Zalathar Sep 16, 2026
d41b4d7
Rollup merge of #162826 - folkertdev:wasm-int-enum-abi, r=alexcrichton
Zalathar Sep 16, 2026
34b52ce
Rollup merge of #159359 - celinval:feat/cast-passmode, r=makai410
Zalathar Sep 16, 2026
40f81cb
Rollup merge of #162818 - zakrad:regr-test-156100, r=petrochenkov
Zalathar Sep 16, 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
9 changes: 9 additions & 0 deletions compiler/rustc_abi/src/callconv/reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ pub enum RegKind {
},
}

impl RegKind {
pub fn from_primitive(primitive: Primitive) -> Self {
match primitive {
Primitive::Int(..) | Primitive::Pointer(_) => RegKind::Integer,
Primitive::Float(_) => RegKind::Float,
}
}
}

#[cfg_attr(feature = "nightly", derive(StableHash))]
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub struct Reg {
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_abi/src/layout/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub trait TyAbiInterface<'a, C>: Sized + std::fmt::Debug + std::fmt::Display {
offset: Size,
) -> Option<PointeeInfo>;
fn is_adt(this: TyAndLayout<'a, Self>) -> bool;
fn is_enum(this: TyAndLayout<'a, Self>) -> bool;
fn is_never(this: TyAndLayout<'a, Self>) -> bool;
fn is_tuple(this: TyAndLayout<'a, Self>) -> bool;
fn is_unit(this: TyAndLayout<'a, Self>) -> bool;
Expand Down Expand Up @@ -200,6 +201,13 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
Ty::is_adt(self)
}

pub fn is_enum<C>(self) -> bool
where
Ty: TyAbiInterface<'a, C>,
{
Ty::is_enum(self)
}

pub fn is_never<C>(self) -> bool
where
Ty: TyAbiInterface<'a, C>,
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,20 @@ impl<'tcx> InferCtxt<'tcx> {
value.fold_with(&mut r)
}

/// Where possible, replaces type/const/region variables in `value` with their final value.
/// If a type/const/region variable has not (yet) been unified, it is left as is.
///
/// This is an idempotent operation that does not affect inference state in any way,
/// which means it's safe to call this function at will.
pub fn deeply_resolve_via_unification_table<T>(&self, value: T) -> T
where
T: TypeFoldable<TyCtxt<'tcx>>,
{
use rustc_middle::ty::InferCtxtLike;
#[allow(rustc::usage_of_type_ir_traits)]
InferCtxtLike::deeply_resolve_via_unification_table(self, value)
}

pub fn resolve_numeric_literals_with_default<T>(&self, value: T) -> T
where
T: TypeFoldable<TyCtxt<'tcx>>,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_infer/src/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ impl<'tcx> InferCtxt<'tcx> {
/// right before lexical region resolution.
#[instrument(level = "debug", skip(self, outlives_env))]
pub fn process_registered_region_obligations(&self, outlives_env: &OutlivesEnvironment<'tcx>) {
use rustc_type_ir::InferCtxtLike;
assert!(!self.in_snapshot(), "cannot process registered region obligations in a snapshot");

if self.tcx.assumptions_on_binders() {
Expand Down
51 changes: 0 additions & 51 deletions compiler/rustc_infer/src/infer/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,57 +67,6 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for DeepResolverIgnoringRegions<'a, 'tcx
}
}

/// The region resolver resolves region variables to the variable with the
/// least variable id. It is used when normalizing projections to avoid
/// hitting the recursion limit by creating many versions of a predicate
/// for types that in the end have to unify.
///
/// If you want to resolve type and const variables as well, call
/// [InferCtxt::deeply_resolve_ignoring_regions] first.
pub struct DeepRegionResolver<'a, 'tcx> {
infcx: &'a InferCtxt<'tcx>,
}

impl<'a, 'tcx> DeepRegionResolver<'a, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'tcx>) -> Self {
DeepRegionResolver { infcx }
}
}

impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for DeepRegionResolver<'a, 'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}

fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
if !t.has_infer_regions() {
t // micro-optimize -- if there is nothing in this type that this fold affects...
} else {
t.super_fold_with(self)
}
}

fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
match r.kind() {
ty::ReVar(vid) => self
.infcx
.inner
.borrow_mut()
.unwrap_region_constraints()
.shallow_resolve_region_var(TypeFolder::cx(self), vid),
_ => r,
}
}

fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
if !ct.has_infer_regions() {
ct // micro-optimize -- if there is nothing in this const that this fold affects...
} else {
ct.super_fold_with(self)
}
}
}

///////////////////////////////////////////////////////////////////////////
// FULL TYPE RESOLUTION

Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,12 +667,6 @@ impl<'a, 'tcx> Decodable<MetadataDecodeContext<'a, 'tcx>> for SpanData {
}
}

impl<'a, 'tcx> Decodable<MetadataDecodeContext<'a, 'tcx>> for &'tcx [(ty::Clause<'tcx>, Span)] {
fn decode(d: &mut MetadataDecodeContext<'a, 'tcx>) -> Self {
ty::codec::RefDecodable::decode(d)
}
}

impl<D: LazyDecoder, T> Decodable<D> for LazyValue<T> {
fn decode(decoder: &mut D) -> Self {
decoder.read_lazy()
Expand Down
23 changes: 16 additions & 7 deletions compiler/rustc_middle/src/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
//! `Copy` type, and any `!Copy` type explicitly listed below.

use rustc_serialize::Decodable;
use rustc_span::{Span, Spanned};

use crate::mono::MonoItem;
use crate::ty::codec::{RefDecodable, TyDecoder};
use crate::ty::{Ty, TyCtxt};
use crate::ty::{self, Ty, TyCtxt};

// If a type `T` supported by the arena also needs to support decoding into `&'tcx T`
// backed by an arena allocation (via `RefDecodable`), add it to the list in
Expand Down Expand Up @@ -157,8 +159,10 @@ where
D: TyDecoder<'tcx>,
T: ArenaAllocatable<'tcx, C> + Decodable<D>,
{
let values: Vec<T> = Decodable::decode(decoder);
decoder.interner().arena.alloc_from_iter(values)
// The decoder for slices must match the decoder for `Vec<T>`,
// which is a `usize` length followed by that many `T`.
let len = decoder.read_usize();
decoder.interner().arena.alloc_from_iter((0..len).map(|_| T::decode(decoder)))
}

macro_rules! impl_ref_decodable_into_arena {
Expand All @@ -168,16 +172,16 @@ macro_rules! impl_ref_decodable_into_arena {
)*
) => {
$(
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for $ty {
impl<'tcx> RefDecodable<'tcx> for $ty {
#[inline]
fn decode(decoder: &mut D) -> &'tcx Self {
fn decode(decoder: &mut impl TyDecoder<'tcx>) -> &'tcx Self {
decode_arena_allocatable(decoder)
}
}

impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [$ty] {
impl<'tcx> RefDecodable<'tcx> for [$ty] {
#[inline]
fn decode(decoder: &mut D) -> &'tcx Self {
fn decode(decoder: &mut impl TyDecoder<'tcx>) -> &'tcx Self {
decode_arena_allocatable_slice(decoder)
}
}
Expand All @@ -190,9 +194,14 @@ macro_rules! impl_ref_decodable_into_arena {
//
// Types in this list must be `ArenaAllocatable`, either because they are `Copy`
// or because they are listed in the `declare_arena!` invocation.
//
// Types in this list must also implement `Decodable<D>` for all `D: TyDecoder<'tcx>`.
impl_ref_decodable_into_arena! {
// tidy-alphabetical-start
(rustc_middle::middle::exported_symbols::ExportedSymbol<'tcx>, rustc_middle::middle::exported_symbols::SymbolExportInfo),
(ty::Clause<'tcx>, Span),
(ty::PolyTraitRef<'tcx>, Span),
Spanned<MonoItem<'tcx>>,
rustc_ast::InlineAsmTemplatePiece,
rustc_ast::tokenstream::TokenStream,
rustc_data_structures::unord::UnordMap<rustc_span::def_id::DefId, rustc_middle::ty::EarlyBinder<'tcx, Ty<'tcx>>>,
Expand Down
118 changes: 37 additions & 81 deletions compiler/rustc_middle/src/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,88 +688,44 @@ impl<'a, 'tcx> BlobDecoder for CacheDecoder<'a, 'tcx> {
}
}

impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx UnordSet<LocalDefId> {
#[inline]
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self {
RefDecodable::decode(d)
}
}

impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>>
for &'tcx UnordMap<DefId, ty::EarlyBinder<'tcx, Ty<'tcx>>>
{
#[inline]
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self {
RefDecodable::decode(d)
}
}

impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>>
for &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>>
{
#[inline]
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self {
RefDecodable::decode(d)
}
}

impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [(ty::Clause<'tcx>, Span)] {
#[inline]
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self {
RefDecodable::decode(d)
}
}

impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [rustc_ast::InlineAsmTemplatePiece] {
#[inline]
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self {
RefDecodable::decode(d)
}
}

impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [Spanned<MonoItem<'tcx>>] {
#[inline]
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self {
RefDecodable::decode(d)
}
}

impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>>
for &'tcx crate::traits::specialization_graph::Graph
{
#[inline]
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self {
RefDecodable::decode(d)
}
}

impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx rustc_ast::tokenstream::TokenStream {
#[inline]
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self {
RefDecodable::decode(d)
}
}

macro_rules! impl_ref_decoder {
(<$tcx:tt> $($ty:ty,)*) => {
$(impl<'a, $tcx> Decodable<CacheDecoder<'a, $tcx>> for &$tcx [$ty] {
#[inline]
fn decode(d: &mut CacheDecoder<'a, $tcx>) -> Self {
RefDecodable::decode(d)
/// Implements [`Decodable`] for `&'tcx T`, where [`T: RefDecodable`](RefDecodable).
///
/// Due to orphan-rule restrictions, these foreign impls cannot use a blanket
/// [`D: TyDecoder`](TyDecoder), and must instead specify a specific decoder.
///
/// For impls on types defined in `rustc_middle`, see
/// `impl_decodable_via_ref_decodable_for_local_type!` instead.
macro_rules! impl_decodable_via_ref_decodable_for_foreign_types {
(
$(
&'tcx $T:ty,
)*
) => {
$(
impl<'tcx> Decodable<CacheDecoder<'_, 'tcx>> for &'tcx $T {
fn decode(decoder: &mut CacheDecoder<'_, 'tcx>) -> Self {
RefDecodable::decode(decoder)
}
}
})*
};
}

impl_ref_decoder! {<'tcx>
Span,
rustc_hir::Attribute,
rustc_span::Ident,
ty::Variance,
rustc_span::def_id::DefId,
rustc_span::def_id::LocalDefId,
(rustc_middle::middle::exported_symbols::ExportedSymbol<'tcx>, rustc_middle::middle::exported_symbols::SymbolExportInfo),
rustc_middle::middle::deduced_param_attrs::DeducedParamAttrs,
)*
}
}

impl_decodable_via_ref_decodable_for_foreign_types! {
// tidy-alphabetical-start
&'tcx IndexVec<mir::Promoted, mir::Body<'tcx>>,
&'tcx UnordMap<DefId, ty::EarlyBinder<'tcx, Ty<'tcx>>>,
&'tcx UnordSet<LocalDefId>,
&'tcx [(
rustc_middle::middle::exported_symbols::ExportedSymbol<'tcx>,
rustc_middle::middle::exported_symbols::SymbolExportInfo,
)],
&'tcx [(ty::Clause<'tcx>, Span)],
&'tcx [DefId],
&'tcx [Spanned<MonoItem<'tcx>>],
&'tcx [ty::Variance],
&'tcx rustc_ast::tokenstream::TokenStream,
// tidy-alphabetical-end
}

//- ENCODING -------------------------------------------------------------------
Expand Down
Loading
Loading