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

Comment thread compiler/rustc_span/src/hygiene.rs Outdated

@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.

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.

Considering N has an explicit ?Sized bound, it makes sense not to suggest turning it into a const. This is another improvement from this PR's change.

The change was intentional, that logic was checking whether there were any bounds that aren't implicit default bounds.

@oli-obk oli-obk force-pushed the having-fun-with-expansion-info branch from 44d45cf to 16c1bf4 Compare June 16, 2026 13:57
@rustbot

rustbot commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

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.

@oli-obk

oli-obk commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@bors r=davidtwco,estebank

@rust-bors

rust-bors Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 16c1bf4 has been approved by davidtwco,estebank

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 Jun 16, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 16, 2026
…info, r=davidtwco,estebank

Add expansion info to implied bounds

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
rust-bors Bot pushed a commit that referenced this pull request Jun 16, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #155535 (export symbols: support macos/windows(32/64))
 - #156538 (Refactor `AliasTy`. `AliasTerm` & `UnevaluatedConst` to use `Alias`)
 - #156807 (Add `T: PartialEq` bounds to derived `StructuralPartialEq` impls.)
 - #156950 (Staticlib rename internal symbols)
 - #157702 (Add expansion info to implied bounds)
 - #155616 (constify `TryFrom<Vec>` for array)
 - #156226 (diagnostics: point to coroutine body on higher-ranked auto trait errors)
 - #157873 (mips: set llvm_args -mno-check-zero-division for all mips targets)
 - #157953 (fix(rustc_codegen_ssa): Use cg_operand for Freeze check)
 - #157958 (doc: Document `-Zlint-rust-version`)
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants