Skip to content

Support type-relative assoc item paths in generic param defaults & const param types - #161998

Open
fmease wants to merge 2 commits into
rust-lang:mainfrom
fmease:tyrel-in-gen-param-cx
Open

Support type-relative assoc item paths in generic param defaults & const param types#161998
fmease wants to merge 2 commits into
rust-lang:mainfrom
fmease:tyrel-in-gen-param-cx

Conversation

@fmease

@fmease fmease commented Aug 30, 2026

Copy link
Copy Markdown
Member

Background info: For resolving type-relative associated item paths, we only support a tiny set of self types (cc #22519). If it's a non-Self type parameter we look at the "type param bounds" of the overarching item.

However, in the case of generic parameter defaults and const parameter types this overarching "item" was set to the generic parameter. This meant that in these places we didn't look at the bounds of the overarching item when trying to resolve such type-relative associated item paths and thus failed unconditionally.

Fixes #87682.

For the types FCP: This PR makes us accept the following code (stably):

trait Trait { type Type; }

struct Owner<T: Trait, U = T::Type>(T, U);
//                         ~~~~~~~ now successfully resolves to <T as Trait>::Type

As alluded to, this PR also affects the resolution in const param defaults+types (intentionally, of course). However, I don't think this can be observed without the use of unstable features (like min_generic_const_args and generic_const_parameter_types). Nonetheless if you're interested in that, too, please check out the added UI tests.

To the best of my knowledge this change doesn't make us reject more code (via new ambiguities or query cycles for example).

(No LLM was or will be used by me during the entire creation process of this PR)

@fmease fmease added needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. T-types Relevant to the types team, which will review and decide on the PR/issue. labels Aug 30, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 30, 2026
@rustbot

This comment was marked as outdated.

@fmease

fmease commented Aug 30, 2026

Copy link
Copy Markdown
Member Author

r? types

@rustbot rustbot assigned jackh726 and unassigned TaKO8Ki Aug 30, 2026
@fmease

fmease commented Aug 30, 2026

Copy link
Copy Markdown
Member Author

@rfcbot merge types

@rust-rfcbot

rust-rfcbot commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

@fmease has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. and removed needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. labels Aug 30, 2026
@fmease

fmease commented Aug 30, 2026

Copy link
Copy Markdown
Member Author

Not sure if this needs an FCP but it felt "significant" enough. Since there's no breakage AFAIK & it's a bit niche, this might also be considered a trivial bugfix in which case I'm sorry for the team ping ^^'

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

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type-relative assoc ty paths fail to resolve inside type param defaults

5 participants