Skip to content

FindParamInClause handle edge-cases#153614

Open
lcnr wants to merge 2 commits intorust-lang:mainfrom
lcnr:find-param-in-clause-ambig
Open

FindParamInClause handle edge-cases#153614
lcnr wants to merge 2 commits intorust-lang:mainfrom
lcnr:find-param-in-clause-ambig

Conversation

@lcnr
Copy link
Copy Markdown
Contributor

@lcnr lcnr commented Mar 9, 2026

If normalization is ambiguous, we want to treat the where-bound as non-global. The affected code should pretty much always have other errors in that case. It does make reasoning about trait solver cycles and rerunning more confusing and just feels wrong ™️ I encountered this while looking into ml-kem (rust-lang/trait-system-refactor-initiative#246). I don't know whether this matters in practice and don't care to look into it too deeply.

We also want to properly handle concrete aliases which mention to something mentioning a generic parameter due to another where-bound.

r? @BoxyUwU

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Mar 9, 2026
@rust-bors

This comment has been minimized.

@lcnr lcnr force-pushed the find-param-in-clause-ambig branch from 3564a3f to 755953f Compare March 20, 2026 14:56
@rust-log-analyzer

This comment has been minimized.

@lcnr lcnr force-pushed the find-param-in-clause-ambig branch from 755953f to a4564e7 Compare March 20, 2026 15:31
@lcnr lcnr changed the title FindParamInClause global on overflow FindParamInClause handle edge-cases Mar 20, 2026
@lcnr lcnr marked this pull request as ready for review March 20, 2026 15:37
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 20, 2026

BoxyUwU is currently at their maximum review capacity.
They may take a while to respond.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 20, 2026
@lcnr
Copy link
Copy Markdown
Contributor Author

lcnr commented Mar 20, 2026

r? BoxyUwU

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 20, 2026

Requested reviewer is already assigned to this pull request.

Please choose another assignee.

TypeFlags::HAS_PLACEHOLDER | TypeFlags::HAS_INFER | TypeFlags::HAS_ALIAS,
) =>
{
ct.super_visit_with(self)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the not doing recursion depth stuff here 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

existing xd :3 because the only way constants recurse is through types atm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this has to change with mgca

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up to u if u want to handle it in this PR, it'd be a fairly reasonable FIXME(mgca) to get some new-ish contributor to work on as onboarding

}));
ty::Infer(_) => ControlFlow::Break(Ok(Certainty::AMBIGUOUS)),
_ if ty.has_type_flags(
TypeFlags::HAS_PLACEHOLDER | TypeFlags::HAS_INFER | TypeFlags::HAS_ALIAS,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so there are two meaningful changes here:

  1. we now recurse if there are aliases
  2. we now recurse if there are non-region-infers

recursing if there are aliases makes sense (that's certainly the point of this PR) but I don't fully understand why we care about infer vars or not.

Copy link
Copy Markdown
Contributor Author

@lcnr lcnr Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to treat ambiguous normalization as Global. You could imagine normalizing T::Assoc to Vec<T::AmbiguousAlias> which ends up as Vec<?infer>

I guess we could always force GLobal if there are infer vars instead of recursing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have a test with ambiguous aliases? I guess you could only really get ambiguity here via overflow (are opaque types relevant?)?

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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants