Skip to content

Add expansion info to implied bounds#157702

Open
oli-obk wants to merge 4 commits into
rust-lang:mainfrom
oli-obk:having-fun-with-expansion-info
Open

Add expansion info to implied bounds#157702
oli-obk wants to merge 4 commits into
rust-lang:mainfrom
oli-obk:having-fun-with-expansion-info

Conversation

@oli-obk

@oli-obk oli-obk commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

r? @estebank maybe?

cc @davidtwco for implied bound diagnostics

We used to have various fun ways for testing whether a Sized bound was implicit or not (usually by checking if the span was equal to the span of a generic parameter). That felt a bit hacky, so I checked what happens if we explicitly mark the span as being desugared. Turns out a lot of diagnostics break. You can see in the diff where I changed things to make them work again.

Then it became clear that we were missing out on various other implied bound sites, and we just got all of them basically for free now.

I think there are various other good refactorings we can do (probably not special casing Sized and not special casing implied bound desugarings, but just reporting all desugarings), but for now this PR is in a state where I'd rather merge it than add more to it

@rustbot

rustbot commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

HIR ty lowering was modified

cc @fmease

@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 Jun 10, 2026

@davidtwco davidtwco left a comment

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.

r=me whether you'd like to apply the suggestion or not

View changes since this review

RangeExpr,
/// Implicit `Sized` or `MetaSized` bounds. The actual source location points to just the
/// param or item for which the implicit bound was generated.
ImpliedBound {

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.

I don't know that ImpliedBound is the most intuitive name for this - maybe DefaultBound instead? I think of things like the Sized bound on T: ?Sized + Clone as implied, rather than the default bound, which isn't really implied by anything other than the language rules. I guess we call it ImpliedBound in other places here like with ImpliedBoundsContext. Feel free to ignore this comment if you'd like.

@estebank estebank left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+ r=me on these changes.

View changes since this review

| ^ unused type parameter
|
= help: consider removing `N` or referring to it in the body of the type alias
= help: if you intended `N` to be a const parameter, use `const N: /* Type */` instead

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting to see this go away, didn't really catch which change caused that.

@fmease fmease Jun 12, 2026

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.

It's odd given that check_type_alias_type_params_are_used was indeed updated to no longer use the old "bound.span == param.span" check.

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.

5 participants