Skip to content

More robustly deal with relaxed bounds and improve their diagnostics #142693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

fmease
Copy link
Member

@fmease fmease commented Jun 18, 2025

Scaffolding for #135229 (CC #135331)

Fixes #136944 (6th commit).
Fixes #142718 (8th commit).

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 18, 2025
@fmease fmease force-pushed the unbound-bettering branch from 8d31700 to 4634541 Compare June 18, 2025 20:27
@fmease fmease changed the title [WIP] unbound bettering (refactoring) [WIP] unbound bettering Jun 18, 2025
@fmease fmease force-pushed the unbound-bettering branch 2 times, most recently from 69e237d to 03d01fa Compare June 19, 2025 02:46
@fmease fmease added the rla-silenced Silences rust-log-analyzer postings to the PR it's added on. label Jun 19, 2025
@rust-lang rust-lang deleted a comment from rust-log-analyzer Jun 19, 2025
@rust-lang rust-lang deleted a comment from rust-log-analyzer Jun 19, 2025
@rust-lang rust-lang deleted a comment from rust-log-analyzer Jun 19, 2025
@fmease fmease force-pushed the unbound-bettering branch 3 times, most recently from 8a6f65d to 04dad4e Compare June 20, 2025 21:17
@fmease fmease changed the title [WIP] unbound bettering More robustly deal with relaxed bounds and improve their diagnostics Jun 20, 2025
@rust-lang rust-lang deleted a comment from rust-bors bot Jun 20, 2025
@fmease
Copy link
Member Author

fmease commented Jun 20, 2025

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 20, 2025

⌛ Trying commit 04dad4e with merge bfa10de

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 20, 2025
More robustly deal with relaxed bounds and improve their diagnostics

Scaffolding for #135229 (CC #135331)

Fixes #136944.
Fixes #142718.
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 20, 2025
@rust-bors
Copy link

rust-bors bot commented Jun 20, 2025

☀️ Try build successful (CI)
Build commit: bfa10de (bfa10de6407128926b18c60d51c9f19df73e336c, parent: 9c4ff566babe632af5e30281a822d1ae9972873b)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bfa10de): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
3.0% [3.0%, 3.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.0% [3.0%, 3.0%] 1

Max RSS (memory usage)

Results (secondary -2.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [2.4%, 2.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.5% [-5.8%, -1.8%] 6
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.9%, secondary 4.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.9% [2.9%, 2.9%] 1
Regressions ❌
(secondary)
4.4% [2.8%, 7.6%] 10
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.9% [2.9%, 2.9%] 1

Binary size

Results (primary 1.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.1% [1.1%, 1.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.1% [1.1%, 1.1%] 1

Bootstrap: 692.606s -> 692.191s (-0.06%)
Artifact size: 372.01 MiB -> 371.99 MiB (-0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 21, 2025
@bors
Copy link
Collaborator

bors commented Jun 27, 2025

☔ The latest upstream changes (presumably #143091) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 27, 2025
@fmease
Copy link
Member Author

fmease commented Jun 27, 2025

#142693 (comment)

Looks spurious?

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 16, 2025
@fmease fmease force-pushed the unbound-bettering branch from 38ac3ca to d39def2 Compare July 17, 2025 23:51
@fmease fmease added the rla-silenced Silences rust-log-analyzer postings to the PR it's added on. label Jul 17, 2025
@fmease fmease force-pushed the unbound-bettering branch from d39def2 to 505e8c1 Compare July 18, 2025 00:19
fmease added 4 commits July 18, 2025 03:13
Only relevant to the internal feature `more_maybe_bounds`.
We no longer move trait predicates where the self ty is a ty param to
"the bounds of a ty param".
@fmease fmease force-pushed the unbound-bettering branch 3 times, most recently from eb7b67e to 94a6965 Compare July 18, 2025 03:07
fmease added 4 commits July 18, 2025 12:13
* The phrasing "only does something for" made sense back when this
  diagnostic was a (hard) warning. Now however, it's simply a hard
  error and thus completely rules out "doing something".
* The primary message was way too long
* The new wording more closely mirrors the wording we use for applying
  other bound modifiers (like `const` and `async`) to incompatible
  traits.
* "all other traits are not bound by default" is no longer accurate
  under Sized Hierarchy. E.g., traits and assoc tys are (currently)
  bounded by `MetaSized` by default but can't be relaxed using
  `?MetaSized` (instead, you relax it by adding `PointeeSized`).
* I've decided against adding any diagnositic notes or suggestions
  for now like "trait `Trait` can't be relaxed as it's not bound by
  default" which would be incorrect for `MetaSized` and assoc tys
  as mentioned above) or "consider changing `?MetaSized` to
  `PointeeSized`" as the Sized Hierarchy impl is still WIP)
Having multiple relaxed bounds like `?Sized + ?Iterator` is actually *fine*.
We actually want to reject *duplicate* relaxed bounds like `?Sized + ?Sized`
because these most certainly represent a user error.

Note that this doesn't mean that we accept more code because a bound like
`?Iterator` is still invalid as it's not relaxing a *default* trait and
the only way to define / use more default bounds is under the experimental
and internal feature `more_maybe_bounds` plus `lang_items` plus unstable
flag `-Zexperimental-default-bounds` (historical context: for the longest
time, bounds like `?Iterator` were actually allowed and lead to a hard
warning).

Ultimately, this simply *reframes* the diagnostic. The scope of
`more_maybe_bounds` / `-Zexperimental-default-bounds` remains unchanged
as well.
@fmease fmease force-pushed the unbound-bettering branch from 94a6965 to 82a02ae Compare July 18, 2025 10:25
@fmease
Copy link
Member Author

fmease commented Jul 18, 2025

(lol I should've just built the compiler for the rebase instead of doing a CI-directed one, that was painful, thanks tired me doing a night shift)

Rebased, added some more (doc) comments and got rid of the more_maybe_bounds advertisement (didn't do it as a follow-up so I can already use this as a good base branch for #135331.

@bors r=compiler-errors

@bors
Copy link
Collaborator

bors commented Jul 18, 2025

📌 Commit 82a02ae has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 18, 2025
@fmease
Copy link
Member Author

fmease commented Jul 18, 2025

@bors rollup- alleviate pressure

@fmease fmease removed the rla-silenced Silences rust-log-analyzer postings to the PR it's added on. label Jul 18, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 18, 2025
…er-errors

More robustly deal with relaxed bounds and improve their diagnostics

Scaffolding for rust-lang#135229 (CC rust-lang#135331)

Fixes rust-lang#136944 (6th commit).
Fixes rust-lang#142718 (8th commit).
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 18, 2025
…er-errors

More robustly deal with relaxed bounds and improve their diagnostics

Scaffolding for rust-lang#135229 (CC rust-lang#135331)

Fixes rust-lang#136944 (6th commit).
Fixes rust-lang#142718 (8th commit).
bors added a commit that referenced this pull request Jul 18, 2025
Rollup of 9 pull requests

Successful merges:

 - #138554 (Distinguish delim kind to decide whether to emit unexpected closing delimiter)
 - #142673 (Show the offset, length and memory of uninit read errors)
 - #142693 (More robustly deal with relaxed bounds and improve their diagnostics)
 - #143382 (stabilize `const_slice_reverse`)
 - #143928 (opt-dist: make llvm builds optional)
 - #143961 (Correct which exploit mitigations are enabled by default)
 - #144050 (Fix encoding of link_section and no_mangle cross crate)
 - #144059 (Refactor `CrateLoader` into the `CStore`)
 - #144123 (Generalize `unsize` and `unsize_into` destinations)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 19, 2025
Rollup of 9 pull requests

Successful merges:

 - #138554 (Distinguish delim kind to decide whether to emit unexpected closing delimiter)
 - #142673 (Show the offset, length and memory of uninit read errors)
 - #142693 (More robustly deal with relaxed bounds and improve their diagnostics)
 - #143382 (stabilize `const_slice_reverse`)
 - #143928 (opt-dist: make llvm builds optional)
 - #143961 (Correct which exploit mitigations are enabled by default)
 - #144050 (Fix encoding of link_section and no_mangle cross crate)
 - #144059 (Refactor `CrateLoader` into the `CStore`)
 - #144123 (Generalize `unsize` and `unsize_into` destinations)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 19, 2025
Rollup of 9 pull requests

Successful merges:

 - #138554 (Distinguish delim kind to decide whether to emit unexpected closing delimiter)
 - #142673 (Show the offset, length and memory of uninit read errors)
 - #142693 (More robustly deal with relaxed bounds and improve their diagnostics)
 - #143382 (stabilize `const_slice_reverse`)
 - #143928 (opt-dist: make llvm builds optional)
 - #143961 (Correct which exploit mitigations are enabled by default)
 - #144050 (Fix encoding of link_section and no_mangle cross crate)
 - #144059 (Refactor `CrateLoader` into the `CStore`)
 - #144123 (Generalize `unsize` and `unsize_into` destinations)

r? `@ghost`
`@rustbot` modify labels: rollup
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.

Sized hierarchy: PointeeSized bounds aren't fully validated during HIR ty lowering Reword ?Trait bound diagnostic
6 participants