Skip to content

Conversation

@InvalidPathException
Copy link
Contributor

Fixes #148838

Root cause:
generics_of currently does not handle hir::Node::ConstArg so defaulted const args nested inside const paths try to inherit generics from the wrong place and trigger ICE.

Symptom:
#148838 ICE

Fix

Handle Node::ConstArg, in fact, similar logic already exists although it is in another branch and slightly more complex, not sure if there is a more elegant way:

// FIXME(#43408) always enable this once `lazy_normalization` is
// stable enough and does not need a feature gate anymore.
Node::AnonConst(_) => {
let parent_did = tcx.parent(def_id.to_def_id());
debug!(?parent_did);
let mut in_param_ty = false;
for (_parent, node) in tcx.hir_parent_iter(hir_id) {
if let Some(generics) = node.generics() {
let mut visitor = AnonConstInParamTyDetector { in_param_ty: false, ct: hir_id };
in_param_ty = visitor.visit_generics(generics).is_break();
break;
}
}

Testing:
1 more test case const-arg-unresolved.rs

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 11, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: generics_of: unexpected node kind ConstArg(ConstArg

3 participants