Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bdbfee0
Split `aarch64-apple{,-macos-26}` => `aarch64-apple{,-macos-26}-{1,2}…
jieyouxu Aug 3, 2026
e90ed38
Remove unused args from `ConstAnalysis` methods
nnethercote Aug 4, 2026
6377970
Split `apply_primary_terminator_effect`
nnethercote Aug 4, 2026
099db74
Update error message in documentation comments
SzilvasiPeter Aug 5, 2026
0ae62fb
Add regression test for array type recovery in generic arguments
zakrad Aug 5, 2026
0aa333d
Add tests for new solver issues
Randl Aug 5, 2026
7eac635
fix: use fully qualified paths in `walk_visitable_list!`
ada4a Aug 5, 2026
fee8922
rustc_abi: Add `LayoutData::is_variant_uninhabited` method
moulins Aug 2, 2026
187cf5d
Add a doc comment to `TyAndLayout` discouraging its uses when possible
moulins Aug 5, 2026
3a7ae70
use `VisitorResult` helper macros
ada4a Aug 5, 2026
be9602c
expand: Feature gate AST-based attribute macros on expressions and no…
petrochenkov Aug 5, 2026
640032d
fix: Check the fallback map before queueing child in `visible_parent_…
zalanlevai Aug 3, 2026
354cedd
add test showing difference between datalog polonius and alpha
lqd Aug 5, 2026
0a0f6df
Rename `#[unroll]` => `#[rustc_unroll]` to mitigate nameres ambiguity
jieyouxu Aug 6, 2026
44d291e
Update attr name in `#[unroll]` codegen-llvm tests
jieyouxu Jul 30, 2026
91ee1f3
Update attr name in `#[unroll]` ui tests
jieyouxu Jul 30, 2026
945d2f3
Rebless `rustc-attrs` feature gate test
jieyouxu Jul 30, 2026
d1265b7
Update attr name for `#[unroll]` in Unstable Book
jieyouxu Jul 30, 2026
39b3ad8
Suggest if-let chain continuation on unclosed delimiter
Diacod-I Aug 5, 2026
f207c16
Avoid the std DLL copy alongside rustc
Zoxc Aug 6, 2026
e67d1be
Rollup merge of #160415 - jieyouxu:jieyouxu/ci/macos-fission, r=Mark-…
JonathanBrouwer Aug 6, 2026
96e411a
Rollup merge of #160464 - zalanlevai:fix-visible-parent-map-fallback-…
JonathanBrouwer Aug 6, 2026
3322584
Rollup merge of #160555 - nnethercote:split-apply_terminator, r=cjgillot
JonathanBrouwer Aug 6, 2026
40c3872
Rollup merge of #160592 - Diacod-I:if-let-chain-unclosed-delim-hint, …
JonathanBrouwer Aug 6, 2026
32e03ba
Rollup merge of #160600 - Zoxc:no-extra-std-dll, r=Kobzol
JonathanBrouwer Aug 6, 2026
f49856a
Rollup merge of #160211 - jieyouxu:froot-loops, r=mati865
JonathanBrouwer Aug 6, 2026
5a58e41
Rollup merge of #160304 - Randl:new_tests, r=adwinwhite
JonathanBrouwer Aug 6, 2026
cc3023d
Rollup merge of #160398 - moulins:layout-is-variant-uninhabited, r=ol…
JonathanBrouwer Aug 6, 2026
c33036e
Rollup merge of #160546 - SzilvasiPeter:main, r=JohnTitor
JonathanBrouwer Aug 6, 2026
08617a5
Rollup merge of #160568 - ada4a:ada/push-vklwmykymnxk, r=jdonszelmann
JonathanBrouwer Aug 6, 2026
6fb0630
Rollup merge of #160571 - zakrad:regr-test-81097, r=jieyouxu
JonathanBrouwer Aug 6, 2026
c278e88
Rollup merge of #160577 - petrochenkov:astgate, r=khyperia
JonathanBrouwer Aug 6, 2026
378ce78
Rollup merge of #160588 - lqd:nighty-wheat-thins, r=jackh726
JonathanBrouwer Aug 6, 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
7 changes: 7 additions & 0 deletions compiler/rustc_abi/src/layout/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ pub trait TyAbiInterface<'a, C>: Sized + std::fmt::Debug + std::fmt::Display {
}

impl<'a, Ty> TyAndLayout<'a, Ty> {
/// Synthetize a layout representing the variant-specific fields of an enum-like layout.
///
/// Note that the resulting layout *does not* fully describes `self.ty` at that specific
/// variant: prefix fields (e.g. in coroutines) and tag information are lost.
///
/// If you don't need type information about the variant's fields, prefer using
/// `self.layout.variants` directly.
pub fn for_variant<C>(self, cx: &C, variant_index: VariantIdx) -> Self
where
Ty: TyAbiInterface<'a, C>,
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2203,6 +2203,17 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
pub fn is_uninhabited(&self) -> bool {
self.uninhabited
}

/// Returns `true` if the given variant is uninhabited.
pub fn is_variant_uninhabited(&self, variant: VariantIdx) -> bool {
match self.variants {
Variants::Empty => true,
Variants::Single { index } => variant != index || self.uninhabited,
Variants::Multiple { ref variants, .. } => {
variants.get(variant).map(|v| v.uninhabited).unwrap_or(true)
}
}
}
}

impl<FieldIdx: Idx, VariantIdx: Idx> fmt::Debug for LayoutData<FieldIdx, VariantIdx>
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_ir/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ macro_rules! walk_list {
macro_rules! walk_visitable_list {
($visitor: expr, $list: expr $(, $($extra_args: expr),* )?) => {
for elem in $list {
$crate::try_visit!(elem.visit_with($visitor $(, $($extra_args,)* )?));
$crate::try_visit!(::rustc_type_ir::TypeVisitable::visit_with(elem, $visitor $(, $($extra_args,)* )?));
}
}
}
3 changes: 2 additions & 1 deletion compiler/rustc_attr_parsing/src/attributes/unroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use super::prelude::*;

pub(crate) struct UnrollParser;
impl SingleAttributeParser for UnrollParser {
const PATH: &[Symbol] = &[sym::unroll];
// FIXME(#159429): temporarily renamed to mitigate `#[unroll]` nameres ambiguity.
const PATH: &[Symbol] = &[sym::rustc_unroll];
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[
Allow(Target::Loop),
Allow(Target::ForLoop),
Expand Down
21 changes: 7 additions & 14 deletions compiler/rustc_borrowck/src/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use std::fmt;

use rustc_data_structures::fx::FxIndexMap;
use rustc_index::bit_set::{DenseBitSet, MixedBitSet};
use rustc_middle::mir::{
self, BasicBlock, Body, CallReturnPlaces, Location, Place, TerminatorEdges,
};
use rustc_middle::mir::{self, BasicBlock, Body, CallReturnPlaces, Location, Place};
use rustc_middle::ty::{RegionVid, TyCtxt};
use rustc_mir_dataflow::fmt::DebugWithContext;
use rustc_mir_dataflow::impls::{
Expand Down Expand Up @@ -76,19 +74,15 @@ impl<'a, 'tcx> Analysis<'tcx> for Borrowck<'a, 'tcx> {
self.ever_inits.apply_early_terminator_effect(&mut state.ever_inits, term, loc);
}

fn apply_primary_terminator_effect<'mir>(
fn apply_primary_terminator_effect(
&self,
state: &mut Self::Domain,
term: &'mir mir::Terminator<'tcx>,
term: &mir::Terminator<'tcx>,
loc: Location,
) -> TerminatorEdges<'mir, 'tcx> {
) {
self.borrows.apply_primary_terminator_effect(&mut state.borrows, term, loc);
self.uninits.apply_primary_terminator_effect(&mut state.uninits, term, loc);
self.ever_inits.apply_primary_terminator_effect(&mut state.ever_inits, term, loc);

// This return value doesn't matter. It's only used by `iterate_to_fixpoint`, which this
// analysis doesn't use.
TerminatorEdges::None
}

fn apply_call_return_effect(
Expand Down Expand Up @@ -598,12 +592,12 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
self.kill_loans_out_of_scope_at_location(state, location);
}

fn apply_primary_terminator_effect<'mir>(
fn apply_primary_terminator_effect(
&self,
state: &mut Self::Domain,
terminator: &'mir mir::Terminator<'tcx>,
terminator: &mir::Terminator<'tcx>,
_location: Location,
) -> TerminatorEdges<'mir, 'tcx> {
) {
if let mir::TerminatorKind::InlineAsm { operands, .. } = &terminator.kind {
for op in operands {
if let mir::InlineAsmOperand::Out { place: Some(place), .. }
Expand All @@ -613,7 +607,6 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
}
}
}
terminator.edges()
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/discriminant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
variant_index: VariantIdx,
) {
let layout = place.layout();
if layout.for_variant(fx, variant_index).is_uninhabited() {
if layout.is_variant_uninhabited(variant_index) {
return;
}
match layout.variants {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/mir/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ pub(super) fn codegen_tag_value<'tcx, V>(
) -> Result<Option<(FieldIdx, V)>, UninhabitedVariantError> {
// By checking uninhabited-ness first we don't need to worry about types
// like `(u32, !)` which are single-variant but weird.
if layout.for_variant(cx, variant_index).is_uninhabited() {
if layout.is_variant_uninhabited(variant_index) {
return Err(UninhabitedVariantError);
}

Expand Down
9 changes: 4 additions & 5 deletions compiler/rustc_const_eval/src/check_consts/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::marker::PhantomData;
use rustc_index::bit_set::MixedBitSet;
use rustc_middle::mir::visit::Visitor;
use rustc_middle::mir::{
self, BasicBlock, CallReturnPlaces, Local, Location, Statement, StatementKind, TerminatorEdges,
self, BasicBlock, CallReturnPlaces, Local, Location, Statement, StatementKind,
};
use rustc_mir_dataflow::fmt::DebugWithContext;
use rustc_mir_dataflow::{Analysis, JoinSemiLattice};
Expand Down Expand Up @@ -351,14 +351,13 @@ where
self.transfer_function(state).visit_statement(statement, location);
}

fn apply_primary_terminator_effect<'mir>(
fn apply_primary_terminator_effect(
&self,
state: &mut Self::Domain,
terminator: &'mir mir::Terminator<'tcx>,
terminator: &mir::Terminator<'tcx>,
location: Location,
) -> TerminatorEdges<'mir, 'tcx> {
) {
self.transfer_function(state).visit_terminator(terminator, location);
terminator.edges()
}

fn apply_call_return_effect(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/interpret/discriminant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
// Reading the discriminant of an uninhabited variant is UB. This is the basis for the
// `uninhabited_enum_branching` MIR pass. It also ensures consistency with
// `write_discriminant`.
if op.layout().for_variant(self, index).is_uninhabited() {
if op.layout().is_variant_uninhabited(index) {
throw_ub!(UninhabitedEnumVariantRead(Some(index)))
}
interp_ok(index)
Expand Down Expand Up @@ -252,7 +252,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
// Therefore, there's no way to represent those variants in the given layout.
// Essentially, uninhabited variants do not have a tag that corresponds to their
// discriminant, so we have to bail out here.
if layout.for_variant(self, variant_index).is_uninhabited() {
if layout.is_variant_uninhabited(variant_index) {
throw_ub!(UninhabitedEnumVariantWritten(variant_index))
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
Err(guar) => return ExpandResult::Ready(fragment_kind.dummy(span, guar)),
}
} else if let SyntaxExtensionKind::LegacyAttr(expander) = ext {
self.gate_proc_macro_attr_item(span, &item);
// `LegacyAttr` is only used for builtin attribute macros, which have their
// safety checked by `check_builtin_meta_item`, so we don't need to check
// `unsafety` here.
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,12 @@ pub static BUILTIN_ATTRIBUTES: &[Symbol] = &[
// - https://github.com/rust-lang/rust/issues/153629
sym::rustc_splat,

// The `#[unroll]` attribute.
// The `#[rustc_unroll]` attribute.
//
// - https://github.com/rust-lang/rust/pull/156816
sym::unroll,
//
// FIXME(#159429): temporarily renamed to mitigate `#[unroll]` nameres ambiguity
sym::rustc_unroll,

// `#[instrument_fn = "on|off"]` to insert or inhibit instrumentation function
// calls inside a function, usually around the prologue.
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,8 @@ pub enum AttributeKind {
limit: Limit,
},

/// Represents `#[unroll]`
/// Represents `#[rustc_unroll]`
// FIXME(#159429): temporarily renamed from `#[unroll]` to mitigate nameres ambiguity
Unroll(UnrollAttr),

/// Represents `#[unstable_feature_bound]`.
Expand Down
30 changes: 21 additions & 9 deletions compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::any::Any;
use std::mem;
use std::sync::Arc;

use rustc_data_structures::unord::ExtendUnord;
use rustc_hir::attrs::Deprecation;
use rustc_hir::def::{CtorKind, DefKind};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE};
Expand Down Expand Up @@ -472,7 +473,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
// the former.
// This is a rudimentary check that does not catch all cases,
// just the easiest.
let mut fallback_map: Vec<(DefId, DefId)> = Default::default();
let mut fallback_map: DefIdMap<DefId> = Default::default();

// Issue 46112: We want the map to prefer the shortest
// paths when reporting the path to an item. Therefore we
Expand Down Expand Up @@ -533,14 +534,24 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
}
}
Entry::Vacant(entry) => {
if !fallback {
entry.insert(parent);
}

// Make sure that we have not already explored this child
// through a previous fallback entry further up the BFS,
// in which case we do not want to put it back into the BFS queue,
// nor record a new fallback parent.
if fallback_map.contains_key(&def_id) {
return;
}

if fallback {
// We do all of the same steps to fallback entries as to
// preferred entries, except for recording them in a separate map.
// It is important to not return early in the fallback cases to
// ensure that we extend the BFS to the children of fallback items.
fallback_map.push((def_id, parent));
} else {
entry.insert(parent);
fallback_map.insert(def_id, parent);
}

if child.res.module_like_def_id().is_some() {
Expand All @@ -560,12 +571,13 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
// Fill in any missing entries with the less preferable path.
// If this path re-exports the child as `_`, we still use this
// path in a diagnostic that suggests importing `::*`.
// We must extend the fallback map with items from the visible parent map
// as the extend call overrides existing entries from the latter map,
// which we prefer over fallback entries.
let mut merged_visible_parent_map = fallback_map;
merged_visible_parent_map.extend_unord(visible_parent_map.into_items());

for (child, parent) in fallback_map {
visible_parent_map.entry(child).or_insert(parent);
}

visible_parent_map
merged_visible_parent_map
},

dependency_formats: |tcx, ()| Arc::new(crate::dependency_format::calculate(tcx)),
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_middle/src/ty/context/impl_interner.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Implementation of [`rustc_type_ir::Interner`] for [`TyCtxt`].

use std::ops::ControlFlow;
use std::{debug_assert_matches, fmt};

use rustc_data_structures::Limit;
Expand All @@ -14,7 +13,7 @@ use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_type_ir::lang_items::{SolverAdtLangItem, SolverProjectionLangItem, SolverTraitLangItem};
use rustc_type_ir::{
BoundVar, CollectAndApply, DebruijnIndex, Interner, TypeFoldable, Unnormalized, VisitorResult,
search_graph,
search_graph, try_visit,
};

use crate::dep_graph::{DepKind, DepNodeIndex};
Expand Down Expand Up @@ -560,10 +559,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
) -> R {
let trait_impls = self.trait_impls_of(trait_def_id);
for &impl_def_id in trait_impls.blanket_impls() {
match f(impl_def_id).branch() {
ControlFlow::Break(b) => return R::from_residual(b),
ControlFlow::Continue(()) => {}
}
try_visit!(f(impl_def_id));
}

R::output()
Expand Down
24 changes: 7 additions & 17 deletions compiler/rustc_middle/src/ty/trait_def.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::iter;
use std::ops::ControlFlow;

use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::ErrorGuaranteed;
Expand All @@ -13,7 +12,7 @@ use tracing::debug;
use crate::query::LocalCrate;
use crate::traits::specialization_graph;
use crate::ty::fast_reject::{self, SimplifiedType, TreatParams};
use crate::ty::{self, Ident, Interner, RestrictionKind, Ty, TyCtxt, VisitorResult};
use crate::ty::{self, Ident, Interner, RestrictionKind, Ty, TyCtxt, VisitorResult, try_visit};

/// A trait's definition with type information.
#[derive(StableHash, Encodable, Decodable)]
Expand Down Expand Up @@ -142,21 +141,12 @@ impl<'tcx> TyCtxt<'tcx> {
self_ty: Ty<'tcx>,
mut f: impl FnMut(DefId) -> R,
) -> R {
macro_rules! ret {
($e: expr) => {
match $e.branch() {
ControlFlow::Break(b) => return R::from_residual(b),
ControlFlow::Continue(()) => {}
}
};
}

let tcx = self;
let trait_impls = tcx.trait_impls_of(trait_def_id);
let mut consider_impls_for_simplified_type = |simp| {
if let Some(impls_for_type) = trait_impls.non_blanket_impls().get(&simp) {
for &impl_def_id in impls_for_type {
ret!(f(impl_def_id))
try_visit!(f(impl_def_id))
}
}

Expand Down Expand Up @@ -191,7 +181,7 @@ impl<'tcx> TyCtxt<'tcx> {
ty::fast_reject::TreatParams::AsRigid,
)
.unwrap();
ret!(consider_impls_for_simplified_type(simp));
try_visit!(consider_impls_for_simplified_type(simp));
}

// HACK: For integer and float variables we have to manually look at all impls
Expand Down Expand Up @@ -219,7 +209,7 @@ impl<'tcx> TyCtxt<'tcx> {
ty::SimplifiedType::Uint(Usize),
];
for simp in possible_integers {
ret!(consider_impls_for_simplified_type(simp));
try_visit!(consider_impls_for_simplified_type(simp));
}
}

Expand All @@ -234,7 +224,7 @@ impl<'tcx> TyCtxt<'tcx> {
];

for simp in possible_floats {
ret!(consider_impls_for_simplified_type(simp));
try_visit!(consider_impls_for_simplified_type(simp));
}
}

Expand All @@ -245,14 +235,14 @@ impl<'tcx> TyCtxt<'tcx> {
self_ty,
ty::fast_reject::TreatParams::AsRigid,
) {
ret!(consider_impls_for_simplified_type(simp));
try_visit!(consider_impls_for_simplified_type(simp));
}
}

// This is only for diagnostics and normally ty vars should be handled by the callers.
ty::Infer(ty::TyVar(_)) => {
for &impl_def_id in trait_impls.non_blanket_impls().values().flatten() {
ret!(f(impl_def_id));
try_visit!(f(impl_def_id));
}
}

Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_mir_dataflow/src/framework/direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ impl Direction for Forward {
let terminator = block_data.terminator();
let location = Location { block, statement_index: block_data.statements.len() };
analysis.apply_early_terminator_effect(state, terminator, location);
let edges = analysis.apply_primary_terminator_effect(state, terminator, location);
// Edges are obtained *before* calling `apply_primary_terminator_effect`.
let edges = analysis.get_terminator_edges(state, terminator, location);
analysis.apply_primary_terminator_effect(state, terminator, location);

let exit_state = state;
match edges {
Expand Down
Loading
Loading