Skip to content

Add expansion info to implied bounds#157702

Merged
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
oli-obk:having-fun-with-expansion-info
Jun 16, 2026
Merged

Add expansion info to implied bounds#157702
rust-bors[bot] merged 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`)
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 13 pull requests

Successful merges:

 - #156538 (Refactor `AliasTy`. `AliasTerm` & `UnevaluatedConst` to use `Alias`)
 - #156807 (Add `T: PartialEq` bounds to derived `StructuralPartialEq` impls.)
 - #156950 (Staticlib rename internal symbols)
 - #156983 (Add `io::Read::read_le` and `io::Read::read_be`)
 - #157306 (tests: codegen-llvm: Expect the new mangling scheme in bpf-abi-indirect-return)
 - #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)
 - #157870 (std: sys: solid: clamp connect_timeout tv_sec instead of truncating)
 - #157952 (Configure Renovate for GitHub Actions)
 - #157953 (fix(rustc_codegen_ssa): Use cg_operand for Freeze check)
 - #157958 (doc: Document `-Zlint-rust-version`)
 - #157974 (Rename `errors.rs` file to `diagnostics.rs` (11/N))
@rust-bors rust-bors Bot merged commit 18509d2 into rust-lang:main Jun 16, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 16, 2026
rust-bors Bot pushed a commit that referenced this pull request Jun 19, 2026
…nfo, r=davidtwco,estebank"

This reverts commit 18509d2, reversing
changes made to bf0dfb6.
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

This PR caused a significant perf regression in this rollup #157991
Because of the perf infastructure borking this was a bit hard to diagnose, had to locally bisect. Will verify in a revert PR that I correctly bisected: #158122
Any ideas what caused this? Can we fix this?

@JonathanBrouwer

JonathanBrouwer commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Also caused an ICE #158093
Let's revert this PR for now, as per https://forge.rust-lang.org/compiler/reviews.html#reverts

If a merged PR is found to have caused a meaningful unanticipated regression, the best policy is to revert it quickly and re-land it later once a fix and regression test are added.

rust-bors Bot pushed a commit that referenced this pull request Jun 19, 2026
…thanBrouwer

Revert "Add expansion info to implied bounds"

This reverts PR #157702 because it causes an ICE and a significant perf regression. This PR also adds a regression test for the ICE.

r? ghost
cc @oli-obk @estebank @davidtwco 

Fixes #158093
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.

6 participants