Skip to content

FindParamInClause handle edge-cases#153614

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

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

Conversation

@lcnr
Copy link
Copy Markdown
Contributor

@lcnr lcnr commented Mar 9, 2026

View all comments

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

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.

added a FIXME

}));
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?)?

Copy link
Copy Markdown
Contributor Author

@lcnr lcnr Apr 2, 2026

Choose a reason for hiding this comment

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

no, it's hard to test (and I don't care enough 😅)

@lcnr lcnr force-pushed the find-param-in-clause-ambig branch from a4564e7 to d59709b Compare April 2, 2026 10:33
@lcnr
Copy link
Copy Markdown
Contributor Author

lcnr commented Apr 2, 2026

@rustbot ready

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 2, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@BoxyUwU
Copy link
Copy Markdown
Member

BoxyUwU commented Apr 2, 2026

r=me if CI passes

@rust-log-analyzer

This comment has been minimized.

@lcnr lcnr force-pushed the find-param-in-clause-ambig branch from d59709b to 69148fd Compare April 2, 2026 14:29
@lcnr
Copy link
Copy Markdown
Contributor Author

lcnr commented Apr 2, 2026

@bors r=BoxyUwU rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 2, 2026

📌 Commit 69148fd has been approved by BoxyUwU

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 2, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 2, 2026
…=BoxyUwU

`FindParamInClause` handle edge-cases

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
rust-bors bot pushed a commit that referenced this pull request Apr 2, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #153105 (Compute the result of a projection type with region errors)
 - #153286 (various fixes for scalable vectors)
 - #153532 (Attributes containing rustc)
 - #153960 (Make `layout_of` cycles fatal errors)
 - #154527 (Emit pre-expansion feature gate warnings for negative impls and specialization)
 - #154666 (Remove `StableHashContext` impls)
 - #154669 (Introduce #[diagnostic::on_move] on `Arc`)
 - #154710 (opaque_generic_const_args -> generic_const_args)
 - #154712 (Revert "`-Znext-solver` Remove the forced ambiguity hack from search graph")
 - #153614 (`FindParamInClause` handle edge-cases)
 - #154213 (tidy-alphabetical: fix line number in error message)
 - #154425 (Migrate transmute tests)
 - #154442 (Export `derive` at the crate root: `core::derive` and `std::derive`)
 - #154469 (mGCA: Lower spans for literal const args)
 - #154578 (Rename `probe_ty_var` to `try_resolve_ty_var`)
 - #154615 (Moving issues)
 - #154644 (rustdoc: seperate methods and associated functions in sidebar)
 - #154660 (Avoid creating async return opaques for foreign async fns)
 - #154671 (Add a test for a past ICE when calling a const fn of an unresolved type with the wrong number of args)
 - #154680 ([rustdoc] Replace `DocContext` with `TyCtxt` wherever possible)
 - #154709 (Revert `Ty` type alias in `rustc_type_ir`)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 2, 2026
…=BoxyUwU

`FindParamInClause` handle edge-cases

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
rust-bors bot pushed a commit that referenced this pull request Apr 2, 2026
…uwer

Rollup of 20 pull requests

Successful merges:

 - #153105 (Compute the result of a projection type with region errors)
 - #153532 (Attributes containing rustc)
 - #153960 (Make `layout_of` cycles fatal errors)
 - #154527 (Emit pre-expansion feature gate warnings for negative impls and specialization)
 - #154666 (Remove `StableHashContext` impls)
 - #154669 (Introduce #[diagnostic::on_move] on `Arc`)
 - #154710 (opaque_generic_const_args -> generic_const_args)
 - #154712 (Revert "`-Znext-solver` Remove the forced ambiguity hack from search graph")
 - #153614 (`FindParamInClause` handle edge-cases)
 - #154213 (tidy-alphabetical: fix line number in error message)
 - #154425 (Migrate transmute tests)
 - #154442 (Export `derive` at the crate root: `core::derive` and `std::derive`)
 - #154469 (mGCA: Lower spans for literal const args)
 - #154578 (Rename `probe_ty_var` to `try_resolve_ty_var`)
 - #154615 (Moving issues)
 - #154644 (rustdoc: seperate methods and associated functions in sidebar)
 - #154660 (Avoid creating async return opaques for foreign async fns)
 - #154671 (Add a test for a past ICE when calling a const fn of an unresolved type with the wrong number of args)
 - #154680 ([rustdoc] Replace `DocContext` with `TyCtxt` wherever possible)
 - #154709 (Revert `Ty` type alias in `rustc_type_ir`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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