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
deb901c
Use closures more consistently in `dep_graph.rs`.
nnethercote Mar 17, 2026
b009e5f
remove try-normalize-use-tree
Shourya742 Apr 9, 2026
df98ac2
Fix rustfmt relative custom command
erfanio Apr 10, 2026
dacfa3c
fix: no complete term expressions on qualified path
A4-Tacks Apr 10, 2026
f1f6d56
fix: no imports on type anchor qualified path
A4-Tacks Apr 10, 2026
65bae63
Use create-github-app-token to get token for gen-lints
lnicola Apr 10, 2026
32c1e17
Merge pull request #22011 from lnicola/gen-lints-token
lnicola Apr 10, 2026
a816b21
Merge pull request #22002 from Shourya742/2026-04-09-remove-try-norma…
ChayimFriedman2 Apr 10, 2026
247651d
Bump create-github-app-token
lnicola Apr 10, 2026
9c7ad1a
Merge pull request #22013 from lnicola/bump-create-github-app-token
lnicola Apr 10, 2026
cdcd9b4
internal: update generated lints
workflows-rust-analyzer[bot] Apr 10, 2026
2629a77
Use last good clippy lints JSON in codegen
lnicola Apr 10, 2026
79758ac
Merge pull request #21998 from rust-lang/ci/gen-lints
lnicola Apr 10, 2026
198e4c4
Merge pull request #22010 from erfanio/rustfmt-fix
Veykril Apr 11, 2026
f9b6718
add regression test for OpenOptionsExt downstream compat
Vastargazing Apr 11, 2026
671b660
Parse `cfg_attr` and `cfg` specially
ChayimFriedman2 Apr 6, 2026
1b81c1d
Merge pull request #21965 from ChayimFriedman2/refactor-cfg-attr
ChayimFriedman2 Apr 11, 2026
8865266
Merge pull request #22012 from A4-Tacks/no-import-on-type-anchor-qual…
Veykril Apr 12, 2026
c0ad604
Merge pull request #22009 from A4-Tacks/no-expr-in-qualified
Veykril Apr 12, 2026
791a3dc
Revert "Fix cycles during delayed lowering"
aerooneqq Apr 13, 2026
d283703
Add tests for ICEs when hir_crate_items executed before delayed lowering
aerooneqq Apr 13, 2026
51888a1
Support proper interaction of user-specified args and impl Traits
aerooneqq Apr 13, 2026
eb11900
add regression test for RTN assoc type restriction ICE
TaKO8Ki Apr 7, 2026
dbf8681
handle RTN projections in assoc type restriction diagnostics
TaKO8Ki Apr 7, 2026
205dd6f
reduce ICE reproducer
TaKO8Ki Apr 8, 2026
9339abb
move tests to associated-type-bounds/return-type-notation
TaKO8Ki Apr 13, 2026
cdf186f
Rollup merge of #155227 - lnicola:sync-from-ra, r=lnicola
JonathanBrouwer Apr 13, 2026
3bbb903
Rollup merge of #154932 - TaKO8Ki:fix-152887-rtn-assoc-type-name, r=j…
JonathanBrouwer Apr 13, 2026
5e3d872
Rollup merge of #155096 - aerooneqq:delegation-user-specified-args-im…
JonathanBrouwer Apr 13, 2026
b4ba990
Rollup merge of #155140 - Vastargazing:open-options-ext-test, r=jdons…
JonathanBrouwer Apr 13, 2026
4110f74
Rollup merge of #155226 - aerooneqq:delegation-hir-crate-items-revert…
JonathanBrouwer Apr 13, 2026
8588ca3
Rollup merge of #153997 - nnethercote:closure-consistency, r=petroche…
JonathanBrouwer Apr 13, 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
1 change: 0 additions & 1 deletion compiler/rustc_ast_lowering/src/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
// also nested delegations may need to access information about this code (#154332),
// so it is better to leave this code as opposed to bodies of extern functions,
// which are completely erased from existence.
// FIXME(fn_delegation): fix `help` in error message (see `inner-attr.stderr`)
if param_count == 0
&& let Some(block) = block
{
Expand Down
116 changes: 58 additions & 58 deletions compiler/rustc_ast_lowering/src/delegation/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,38 @@ use rustc_span::{Ident, Span};

use crate::{LoweringContext, ResolverAstLoweringExt};

pub(super) enum DelegationGenerics<T> {
#[derive(Clone, Copy)]
pub(super) enum DelegationGenericsKind {
/// User-specified args are present: `reuse foo::<String>;`.
UserSpecified,
/// The default case when no user-specified args are present: `reuse Trait::foo;`.
Default(T),
Default,
/// In free-to-trait reuse, when user specified args for trait `reuse Trait::<i32>::foo;`
/// in this case we need to both generate `Self` and process user args.
SelfAndUserSpecified(T),
SelfAndUserSpecified,
/// In delegations from trait impl to other entities like free functions or trait functions,
/// we want to generate a function whose generics matches generics of signature function
/// in trait.
TraitImpl(T, bool /* Has user-specified args */),
TraitImpl(bool /* Has user-specified args */),
}

pub(super) struct DelegationGenerics<T> {
generics: T,
kind: DelegationGenericsKind,
}

impl<'hir> DelegationGenerics<&'hir [ty::GenericParamDef]> {
fn default(generics: &'hir [ty::GenericParamDef]) -> Self {
DelegationGenerics { generics, kind: DelegationGenericsKind::Default }
}

fn user_specified(generics: &'hir [ty::GenericParamDef]) -> Self {
DelegationGenerics { generics, kind: DelegationGenericsKind::UserSpecified }
}

fn trait_impl(generics: &'hir [ty::GenericParamDef], user_specified: bool) -> Self {
DelegationGenerics { generics, kind: DelegationGenericsKind::TraitImpl(user_specified) }
}
}

/// Used for storing either ty generics or their uplifted HIR version. First we obtain
Expand Down Expand Up @@ -54,20 +74,19 @@ pub(super) struct GenericArgsPropagationDetails {
pub(super) use_args_in_sig_inheritance: bool,
}

impl<T> DelegationGenerics<T> {
fn args_propagation_details(&self) -> GenericArgsPropagationDetails {
impl DelegationGenericsKind {
fn args_propagation_details(self) -> GenericArgsPropagationDetails {
match self {
DelegationGenerics::UserSpecified | DelegationGenerics::SelfAndUserSpecified { .. } => {
GenericArgsPropagationDetails {
should_propagate: false,
use_args_in_sig_inheritance: true,
}
}
DelegationGenerics::TraitImpl(_, user_specified) => GenericArgsPropagationDetails {
should_propagate: !*user_specified,
DelegationGenericsKind::UserSpecified
| DelegationGenericsKind::SelfAndUserSpecified => GenericArgsPropagationDetails {
should_propagate: false,
use_args_in_sig_inheritance: true,
},
DelegationGenericsKind::TraitImpl(user_specified) => GenericArgsPropagationDetails {
should_propagate: !user_specified,
use_args_in_sig_inheritance: false,
},
DelegationGenerics::Default(_) => GenericArgsPropagationDetails {
DelegationGenericsKind::Default => GenericArgsPropagationDetails {
should_propagate: true,
use_args_in_sig_inheritance: false,
},
Expand All @@ -81,25 +100,9 @@ impl<'hir> HirOrTyGenerics<'hir> {
ctx: &mut LoweringContext<'_, 'hir, impl ResolverAstLoweringExt<'hir>>,
span: Span,
) -> &mut HirOrTyGenerics<'hir> {
if let HirOrTyGenerics::Ty(params) = self {
let mut uplift_params = |generics: &'hir [ty::GenericParamDef]| {
ctx.uplift_delegation_generic_params(span, generics)
};

let hir_generics = match params {
DelegationGenerics::UserSpecified => DelegationGenerics::UserSpecified,
DelegationGenerics::Default(params) => {
DelegationGenerics::Default(uplift_params(params))
}
DelegationGenerics::SelfAndUserSpecified(params) => {
DelegationGenerics::SelfAndUserSpecified(uplift_params(params))
}
DelegationGenerics::TraitImpl(params, user_specified) => {
DelegationGenerics::TraitImpl(uplift_params(params), *user_specified)
}
};

*self = HirOrTyGenerics::Hir(hir_generics);
if let HirOrTyGenerics::Ty(ty) = self {
let params = ctx.uplift_delegation_generic_params(span, ty.generics);
*self = HirOrTyGenerics::Hir(DelegationGenerics { generics: params, kind: ty.kind });
}

self
Expand All @@ -108,12 +111,7 @@ impl<'hir> HirOrTyGenerics<'hir> {
fn hir_generics_or_empty(&self) -> &'hir hir::Generics<'hir> {
match self {
HirOrTyGenerics::Ty(_) => hir::Generics::empty(),
HirOrTyGenerics::Hir(hir_generics) => match hir_generics {
DelegationGenerics::UserSpecified => hir::Generics::empty(),
DelegationGenerics::Default(generics)
| DelegationGenerics::SelfAndUserSpecified(generics)
| DelegationGenerics::TraitImpl(generics, _) => generics,
},
HirOrTyGenerics::Hir(hir) => hir.generics,
}
}

Expand All @@ -127,21 +125,16 @@ impl<'hir> HirOrTyGenerics<'hir> {
HirOrTyGenerics::Ty(_) => {
bug!("Attempting to get generic args before uplifting to HIR")
}
HirOrTyGenerics::Hir(hir_generics) => match hir_generics {
DelegationGenerics::UserSpecified => hir::GenericArgs::NONE,
DelegationGenerics::Default(generics)
| DelegationGenerics::SelfAndUserSpecified(generics)
| DelegationGenerics::TraitImpl(generics, _) => {
ctx.create_generics_args_from_params(generics.params, add_lifetimes, span)
}
},
HirOrTyGenerics::Hir(hir) => {
ctx.create_generics_args_from_params(hir.generics.params, add_lifetimes, span)
}
}
}

pub(super) fn args_propagation_details(&self) -> GenericArgsPropagationDetails {
match self {
HirOrTyGenerics::Ty(ty_generics) => ty_generics.args_propagation_details(),
HirOrTyGenerics::Hir(hir_generics) => hir_generics.args_propagation_details(),
HirOrTyGenerics::Ty(ty) => ty.kind.args_propagation_details(),
HirOrTyGenerics::Hir(hir) => hir.kind.args_propagation_details(),
}
}
}
Expand Down Expand Up @@ -231,9 +224,10 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
if matches!(delegation_parent_kind, DefKind::Impl { of_trait: true }) {
// Considering parent generics, during signature inheritance
// we will take those args that are in trait impl header trait ref.
let parent = GenericsGenerationResult::new(DelegationGenerics::TraitImpl(&[], true));
let parent = DelegationGenerics::trait_impl(&[], true);
let parent = GenericsGenerationResult::new(parent);

let child = DelegationGenerics::TraitImpl(sig_params, child_user_specified);
let child = DelegationGenerics::trait_impl(sig_params, child_user_specified);
let child = GenericsGenerationResult::new(child);

return GenericsGenerationResults { parent, child };
Expand All @@ -257,22 +251,28 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
if segments[len - 2].args.is_some() {
if generate_self {
// Take only first Self parameter, it is trait so Self must be present.
DelegationGenerics::SelfAndUserSpecified(&sig_parent_params[..1])
DelegationGenerics {
kind: DelegationGenericsKind::SelfAndUserSpecified,
generics: &sig_parent_params[..1],
}
} else {
DelegationGenerics::UserSpecified
DelegationGenerics::user_specified(&[])
}
} else {
let skip_self = usize::from(!generate_self);
DelegationGenerics::Default(&sig_parent_params[skip_self..])
DelegationGenerics::default(&sig_parent_params[skip_self..])
}
} else {
DelegationGenerics::<&'hir [ty::GenericParamDef]>::Default(&[])
DelegationGenerics::default(&[])
};

let child_generics = if child_user_specified {
DelegationGenerics::UserSpecified
let synth_params_index =
sig_params.iter().position(|p| p.kind.is_synthetic()).unwrap_or(sig_params.len());

DelegationGenerics::user_specified(&sig_params[synth_params_index..])
} else {
DelegationGenerics::Default(sig_params)
DelegationGenerics::default(sig_params)
};

GenericsGenerationResults {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub(super) enum Owners<'a, 'hir> {
}

impl<'hir> Owners<'_, 'hir> {
pub(super) fn get_or_insert_mut(&mut self, def_id: LocalDefId) -> &mut hir::MaybeOwner<'hir> {
fn get_or_insert_mut(&mut self, def_id: LocalDefId) -> &mut hir::MaybeOwner<'hir> {
match self {
Owners::IndexVec(index_vec) => {
index_vec.ensure_contains_elem(def_id, || hir::MaybeOwner::Phantom)
Expand Down
27 changes: 5 additions & 22 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use std::mem;
use std::sync::Arc;

use rustc_ast::node_id::NodeMap;
use rustc_ast::visit::AssocCtxt;
use rustc_ast::{self as ast, *};
use rustc_attr_parsing::{AttributeParser, Late, OmitDoc};
use rustc_data_structures::fingerprint::Fingerprint;
Expand Down Expand Up @@ -634,29 +633,13 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> mid_hir::Crate<'_> {
let mut delayed_ids: FxIndexSet<LocalDefId> = Default::default();

for def_id in ast_index.indices() {
let delayed_owner_kind = match &ast_index[def_id] {
AstOwner::Item(Item { kind: ItemKind::Delegation(_), .. }) => {
Some(hir::DelayedOwnerKind::Item)
match &ast_index[def_id] {
AstOwner::Item(Item { kind: ItemKind::Delegation { .. }, .. })
| AstOwner::AssocItem(Item { kind: AssocItemKind::Delegation { .. }, .. }, _) => {
delayed_ids.insert(def_id);
}
AstOwner::AssocItem(Item { kind: AssocItemKind::Delegation(_), .. }, ctx) => {
Some(match ctx {
AssocCtxt::Trait => hir::DelayedOwnerKind::TraitItem,
AssocCtxt::Impl { .. } => hir::DelayedOwnerKind::ImplItem,
})
}
_ => None,
_ => lowerer.lower_node(def_id),
};

if let Some(kind) = delayed_owner_kind {
delayed_ids.insert(def_id);

let owner = lowerer.owners.get_or_insert_mut(def_id);
if let hir::MaybeOwner::Phantom = owner {
*owner = hir::MaybeOwner::Delayed(kind)
}
} else {
lowerer.lower_node(def_id);
}
}

// Don't hash unless necessary, because it's expensive.
Expand Down
18 changes: 11 additions & 7 deletions compiler/rustc_codegen_cranelift/src/driver/aot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,9 @@ fn codegen_cgu_content(

fn module_codegen(
tcx: TyCtxt<'_>,
(global_asm_config, cgu_name, token): (
Arc<GlobalAsmConfig>,
rustc_span::Symbol,
ConcurrencyLimiterToken,
),
global_asm_config: Arc<GlobalAsmConfig>,
cgu_name: rustc_span::Symbol,
token: ConcurrencyLimiterToken,
) -> OngoingModuleCodegen {
let mut module = make_module(tcx.sess, cgu_name.as_str().to_string());

Expand Down Expand Up @@ -513,8 +511,14 @@ pub(crate) fn run_aot(tcx: TyCtxt<'_>) -> Box<OngoingCodegen> {
let (module, _) = tcx.dep_graph.with_task(
dep_node,
tcx,
(global_asm_config.clone(), cgu.name(), concurrency_limiter.acquire(tcx.dcx())),
module_codegen,
|| {
module_codegen(
tcx,
global_asm_config.clone(),
cgu.name(),
concurrency_limiter.acquire(tcx.dcx()),
)
},
Some(rustc_middle::dep_graph::hash_result),
);
IntoDynSyncSend(module)
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_codegen_gcc/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ pub fn compile_codegen_unit(
let (module, _) = tcx.dep_graph.with_task(
dep_node,
tcx,
(cgu_name, target_info, lto_supported),
module_codegen,
|| module_codegen(tcx, cgu_name, target_info, lto_supported),
Some(dep_graph::hash_result),
);
let time_to_codegen = start_time.elapsed();
Expand All @@ -96,7 +95,9 @@ pub fn compile_codegen_unit(

fn module_codegen(
tcx: TyCtxt<'_>,
(cgu_name, target_info, lto_supported): (Symbol, LockedTargetInfo, bool),
cgu_name: Symbol,
target_info: LockedTargetInfo,
lto_supported: bool,
) -> ModuleCodegen<GccContext> {
let cgu = tcx.codegen_unit(cgu_name);
// Instantiate monomorphizations without filling out definitions yet...
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_llvm/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ pub(crate) fn compile_codegen_unit(
let (module, _) = tcx.dep_graph.with_task(
dep_node,
tcx,
cgu_name,
module_codegen,
|| module_codegen(tcx, cgu_name),
Some(dep_graph::hash_result),
);
let time_to_codegen = start_time.elapsed();
Expand Down
19 changes: 2 additions & 17 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1641,18 +1641,10 @@ impl<'tcx> OwnerInfo<'tcx> {
}
}

#[derive(Copy, Clone, Debug, HashStable_Generic)]
pub enum DelayedOwnerKind {
Item,
ImplItem,
TraitItem,
}

#[derive(Copy, Clone, Debug, HashStable_Generic)]
pub enum MaybeOwner<'tcx> {
Owner(&'tcx OwnerInfo<'tcx>),
NonOwner(HirId),
Delayed(DelayedOwnerKind),
/// Used as a placeholder for unused LocalDefId.
Phantom,
}
Expand All @@ -1661,19 +1653,12 @@ impl<'tcx> MaybeOwner<'tcx> {
pub fn as_owner(self) -> Option<&'tcx OwnerInfo<'tcx>> {
match self {
MaybeOwner::Owner(i) => Some(i),
_ => None,
MaybeOwner::NonOwner(_) | MaybeOwner::Phantom => None,
}
}

pub fn unwrap(self) -> &'tcx OwnerInfo<'tcx> {
self.as_owner().unwrap_or_else(|| panic!("not a HIR owner"))
}

pub fn expect_delayed(self) -> DelayedOwnerKind {
match self {
MaybeOwner::Delayed(delayed_owner) => delayed_owner,
_ => panic!("not a delayed owner"),
}
self.as_owner().unwrap_or_else(|| panic!("Not a HIR owner"))
}
}

Expand Down
Loading
Loading