Skip to content

Conversation

fmease
Copy link
Member

@fmease fmease commented Oct 15, 2025

Follow-up to #142693, #135331 and #135841.
Fixes #143122.

  • Reject relaxed bounds ?Trait in the bounds of trait aliases.
    Just like trait Trait {} doesn't mean trait Trait: Sized {} and we therefore reject trait Trait: ?Sized {}, trait Trait =; (sic!) doesn't mean trait Trait = Sized; (never did!) and as a logical consequence trait Trait = ?Sized; is meaningless and should be forbidden.
  • Don't permit ?Sized in more places (e.g., supertrait bounds, trait object types) if feature more_maybe_bounds is enabled.
    That internal feature is only meant to allow the user to define & use new default traits (that have fewer rules to follow for now to ease experimentation).
  • Unconditionally check that the Trait in ?Trait is a default trait.
    Previously, we would only perform this check in selected places which was very brittle and led to bugs slipping through.
  • Slightly improve diagnostics.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 15, 2025
@fmease
Copy link
Member Author

fmease commented Oct 15, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 15, 2025
Further tighten up relaxed bounds
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 15, 2025
@rust-log-analyzer

This comment was marked as resolved.

@rust-bors
Copy link

rust-bors bot commented Oct 15, 2025

☀️ Try build successful (CI)
Build commit: 9ed9a73 (9ed9a7337cbbb431708bcd7085fadfe1719c28c3, parent: 28d0a4a205f9e511ad2f51ee79a4aa19a704a455)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9ed9a73): comparison URL.

Overall result: no relevant changes - no action needed

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.

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

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary -3.8%)

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)
- - 0
Improvements ✅
(primary)
-3.8% [-6.7%, -1.0%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.8% [-6.7%, -1.0%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 474.854s -> 475.36s (0.11%)
Artifact size: 388.09 MiB -> 388.06 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 15, 2025
@fmease fmease force-pushed the tighten-relaxed branch 2 times, most recently from 2453034 to 5fab794 Compare October 16, 2025 14:19
@fmease fmease added the rla-silenced Silences rust-log-analyzer postings to the PR it's added on. label Oct 16, 2025
@fmease
Copy link
Member Author

fmease commented Oct 16, 2025

@bors rollup-

@fmease fmease removed the rla-silenced Silences rust-log-analyzer postings to the PR it's added on. label Oct 16, 2025
@fmease fmease force-pushed the tighten-relaxed branch 2 times, most recently from 79993ba to 86cd4b0 Compare October 16, 2025 17:20
Copy link
Member Author

@fmease fmease Oct 16, 2025

Choose a reason for hiding this comment

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

"Completely" unrelated to feature sized_hierarchy. Well, it must've once ICE'd during the development of sized_hierarchy and the PR that introduced it did affect stable behavior.

In any case, since ?Sized is now illegal inside trait alias bounds, this is now covered by test tests/ui/traits/alias/relaxed-bounds.rs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, we did not have any UI test for trait Empty =; prior.

Copy link
Member Author

Choose a reason for hiding this comment

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

Superseded by tests/ui/traits/alias/effectively-empty-trait-object-type.rs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved into tests/ui/unsized/relaxed-bounds-invalid-places.rs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Superseded by tests/ui/traits/alias/relaxed-bounds.rs.

Comment on lines +8 to +10
//~| ERROR bound modifier `?` can only be applied to `Sized`
//~| ERROR bound modifier `?` can only be applied to `Sized`
//~| ERROR bound modifier `?` can only be applied to `Sized`
Copy link
Member Author

Choose a reason for hiding this comment

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

Duplicate diagnostics (under -Zdeduplicate-diagnostics=no) because we lower the supertraits multiple times during HIR ty lowering likely under different predicate filters (HIR ty lowering needs to do this sort of thing in a bunch of situations to avoid query cycles).

Copy link
Member Author

@fmease fmease Oct 16, 2025

Choose a reason for hiding this comment

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

(This test is just a mixed bag, always has been, and that's fine, the feature is internal and still evolving)

trait_ref.path.segments.split_last().unwrap().1.iter(),
GenericsArgsErrExtend::None,
);
let [leading_segments @ .., segment] = trait_ref.path.segments else { bug!() };
Copy link
Member Author

Choose a reason for hiding this comment

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

Drive-by refactoring

@fmease fmease marked this pull request as ready for review October 16, 2025 17:54
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 16, 2025
@fmease
Copy link
Member Author

fmease commented Oct 16, 2025

r? compiler

@rustbot rustbot assigned petrochenkov and unassigned SparrowLii Oct 16, 2025
@petrochenkov
Copy link
Contributor

r? types

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Oct 17, 2025
@rustbot rustbot assigned spastorino and unassigned petrochenkov Oct 17, 2025
@fmease
Copy link
Member Author

fmease commented Oct 17, 2025

r? types

@rustbot rustbot assigned lcnr and unassigned spastorino Oct 17, 2025
@lcnr
Copy link
Contributor

lcnr commented Oct 20, 2025

gamer!

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 20, 2025

📌 Commit 65814c8 has been approved by lcnr

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-review Status: Awaiting review from the assignee but also interested parties. labels Oct 20, 2025
@bors
Copy link
Collaborator

bors commented Oct 20, 2025

⌛ Testing commit 65814c8 with merge 5da91e4...

bors added a commit that referenced this pull request Oct 20, 2025
Further tighten up relaxed bounds

Follow-up to #142693, #135331 and #135841.
Fixes #143122.

* Reject relaxed bounds `?Trait` in the bounds of trait aliases.
  Just like `trait Trait {}` doesn't mean `trait Trait: Sized {}` and we therefore reject `trait Trait: ?Sized {}`, `trait Trait =;` (sic!) doesn't mean `trait Trait = Sized;` (never did!) and as a logical consequence `trait Trait = ?Sized;` is meaningless and should be forbidden.
* Don't permit `?Sized` in more places (e.g., supertrait bounds, trait object types) if feature `more_maybe_bounds` is enabled.
  That internal feature is only meant to allow the user to define & use *new* default traits (that have fewer rules to follow for now to ease experimentation).
* Unconditionally check that the `Trait` in `?Trait` is a default trait.
  Previously, we would only perform this check in selected places which was very brittle and led to bugs slipping through.
* Slightly improve diagnostics.
@bors
Copy link
Collaborator

bors commented Oct 20, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 20, 2025
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#3 [auth] library/centos:pull token for registry-1.docker.io
#3 DONE 0.0s

#4 [internal] load metadata for docker.io/library/centos:7
#4 ERROR: failed to authorize: failed to fetch oauth token: unexpected status from POST request to https://auth.docker.io/token: 503 Service Unavailable: <html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>


------
---
   5 | >>> FROM centos:7
   6 |     
   7 |     WORKDIR /build
--------------------
ERROR: failed to build: failed to solve: failed to fetch oauth token: unexpected status from POST request to https://auth.docker.io/token: 503 Service Unavailable: <html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>


Command failed. Attempt 2/5:
---
#2 [auth] library/centos:pull token for registry-1.docker.io
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/centos:7
#3 ERROR: failed to authorize: failed to fetch oauth token: unexpected status from POST request to https://auth.docker.io/token: 503 Service Unavailable: <html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>


------
---
   5 | >>> FROM centos:7
   6 |     
   7 |     WORKDIR /build
--------------------
ERROR: failed to build: failed to solve: failed to fetch oauth token: unexpected status from POST request to https://auth.docker.io/token: 503 Service Unavailable: <html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>


Command failed. Attempt 3/5:
---
#2 [auth] library/centos:pull token for registry-1.docker.io
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/centos:7
#3 ERROR: failed to authorize: failed to fetch oauth token: unexpected status from POST request to https://auth.docker.io/token: 503 Service Unavailable: <html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>


------
---
   5 | >>> FROM centos:7
   6 |     
   7 |     WORKDIR /build
--------------------
ERROR: failed to build: failed to solve: failed to fetch oauth token: unexpected status from POST request to https://auth.docker.io/token: 503 Service Unavailable: <html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>


Command failed. Attempt 4/5:
---
#2 [auth] library/centos:pull token for registry-1.docker.io
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/centos:7
#3 ERROR: failed to authorize: failed to fetch oauth token: unexpected status from POST request to https://auth.docker.io/token: 503 Service Unavailable: <html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>


------
---
   5 | >>> FROM centos:7
   6 |     
   7 |     WORKDIR /build
--------------------
ERROR: failed to build: failed to solve: failed to fetch oauth token: unexpected status from POST request to https://auth.docker.io/token: 503 Service Unavailable: <html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>


Command failed. Attempt 5/5:
---
#2 [auth] library/centos:pull token for registry-1.docker.io
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/centos:7
#3 ERROR: failed to authorize: failed to fetch oauth token: unexpected status from POST request to https://auth.docker.io/token: 503 Service Unavailable: <html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>


------
---
   5 | >>> FROM centos:7
   6 |     
   7 |     WORKDIR /build
--------------------
ERROR: failed to build: failed to solve: failed to fetch oauth token: unexpected status from POST request to https://auth.docker.io/token: 503 Service Unavailable: <html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>


The command has failed after 5 attempts.

@Zalathar
Copy link
Contributor

Docker appears to be working again.

@bors retry

@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-review Status: Awaiting review from the assignee but also interested parties. labels Oct 20, 2025
bors added a commit that referenced this pull request Oct 20, 2025
Rollup of 4 pull requests

Successful merges:

 - #147734 (Further tighten up relaxed bounds)
 - #147888 (enzyme/autodiff is compatible with download-ci=true)
 - #147898 (compiletest: Move `AuxProps` out of `EarlyProps`)
 - #147903 (compiletest: Store the selected edition in `TestProps`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f87f9a4 into rust-lang:master Oct 20, 2025
11 of 12 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 20, 2025
rust-timer added a commit that referenced this pull request Oct 20, 2025
Rollup merge of #147734 - fmease:tighten-relaxed, r=lcnr

Further tighten up relaxed bounds

Follow-up to #142693, #135331 and #135841.
Fixes #143122.

* Reject relaxed bounds `?Trait` in the bounds of trait aliases.
  Just like `trait Trait {}` doesn't mean `trait Trait: Sized {}` and we therefore reject `trait Trait: ?Sized {}`, `trait Trait =;` (sic!) doesn't mean `trait Trait = Sized;` (never did!) and as a logical consequence `trait Trait = ?Sized;` is meaningless and should be forbidden.
* Don't permit `?Sized` in more places (e.g., supertrait bounds, trait object types) if feature `more_maybe_bounds` is enabled.
  That internal feature is only meant to allow the user to define & use *new* default traits (that have fewer rules to follow for now to ease experimentation).
* Unconditionally check that the `Trait` in `?Trait` is a default trait.
  Previously, we would only perform this check in selected places which was very brittle and led to bugs slipping through.
* Slightly improve diagnostics.
@fmease fmease deleted the tighten-relaxed branch October 20, 2025 16:41
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Oct 20, 2025
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#147734 (Further tighten up relaxed bounds)
 - rust-lang/rust#147888 (enzyme/autodiff is compatible with download-ci=true)
 - rust-lang/rust#147898 (compiletest: Move `AuxProps` out of `EarlyProps`)
 - rust-lang/rust#147903 (compiletest: Store the selected edition in `TestProps`)

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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. 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.

We don't fully validate relaxed trait bounds on the RHS of trait aliases (should we actually reject them outright?)

10 participants