Skip to content

Conversation

@lapla-cogito
Copy link
Contributor

@lapla-cogito lapla-cogito commented Nov 25, 2025

close #149285

The AST validation now detects and rejects const auto traits. Additionally, I updated an existing test that was using const unsafe auto trait.

r? 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 Nov 25, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 25, 2025

fmease is currently at their maximum review capacity.
They may take a while to respond.

LL | const auto trait Marker {}
| ^^^^^
|
= help: remove the `const` keyword
Copy link
Member

Choose a reason for hiding this comment

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

We could provide a structured suggestion but yeah, it's not really worth the effort.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially thought about that, but decided not to, mainly because not every suggestion can be fixed automatically with rustfix, for example the code sample in the original issue that triggers a panic in next-gen solvers, and because we don't really have anything meaningful to add beyond what the current message already communicates.

Copy link
Member

@fmease fmease Nov 25, 2025

Choose a reason for hiding this comment

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

Ah, the next-gen solver still crashes despite this change? Right, of course.

I guess we should replace the unreachable!(…) in consider_auto_trait_candidate of HostEffectPredicate with a cx.delay_bug. Sorry, I forgot about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that’s a bit different from what I was aiming to accomplish in this PR, so I had planned to handle it in a follow-up PR instead (though I should have mentioned that). But since integrating the tests is straightforward, I’ve decided to include it in this PR as well: c80ab42

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 25, 2025
@fmease
Copy link
Member

fmease commented Nov 25, 2025

Thanks! Two small nitpicks

@lapla-cogito lapla-cogito force-pushed the deny_const_auto_trait branch 2 times, most recently from 44f4a9b to 0f63688 Compare November 25, 2025 12:06
@lapla-cogito
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 25, 2025
@fmease
Copy link
Member

fmease commented Nov 25, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Nov 25, 2025

📌 Commit 3326fbd has been approved by fmease

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 Nov 25, 2025
@fmease fmease added the PG-const-traits Project group: Const traits label Nov 25, 2025
@fmease
Copy link
Member

fmease commented Nov 25, 2025

Ah, we also need to replace the unreachable!() with a cx.delay_bug() in consider_auto_trait_candidate, so it no longer crashes under -Znext-solver. #149307 (comment).

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 25, 2025
@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Nov 25, 2025
@lapla-cogito
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 25, 2025
@fmease
Copy link
Member

fmease commented Nov 25, 2025

Thanks again @bors r+

@bors
Copy link
Collaborator

bors commented Nov 25, 2025

📌 Commit ae699c8 has been approved by fmease

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 Nov 25, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Nov 26, 2025
…, r=fmease

Deny const auto traits

close rust-lang#149285

The AST validation now detects and rejects const auto traits. Additionally, I updated an existing test that was using `const unsafe auto trait`.

r? fmease
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PG-const-traits Project group: Const traits 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

We don't reject const auto traits

4 participants