Skip to content

Conversation

@fmease
Copy link
Member

@fmease fmease commented Nov 8, 2025

Remove #[const_trait] since we now have const trait. Update all structured diagnostics that still suggested the attribute.

r? @rust-lang/project-const-traits

@fmease fmease added F-const_trait_impl `#![feature(const_trait_impl)]` PG-const-traits Project group: Const traits labels Nov 8, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 8, 2025

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann

Some changes occurred to constck

cc @fee1-dead

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-run-make Area: port run-make Makefiles to rmake.rs 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. T-libs Relevant to the library 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-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Nov 8, 2025
//[nyy,nyn,nny,nnn]~^ ERROR: const trait impls are experimental
#[cfg(any(yny, ynn, nny, nnn))] trait Foo { fn a(&self); }

#[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)]
Copy link
Member Author

@fmease fmease Nov 8, 2025

Choose a reason for hiding this comment

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

The nyn was incorrect in that it didn't follow the pattern that's explicitly established at the top of the file (where 0 |-> const_trait_impl enabled?, 1 |-> Foo const?, 2 |-> Bar const?) since the last n incorrectly claimed that under this revision Bar was not const despite literally enabling #[const_trait] when active.

Replaced with nny, hence some of the error annotation changes.

&& let &TraitOrTraitImpl::Trait { vis, constness: ast::Const::No } = parent
{
Some(span.shrink_to_lo())
Some(map.span_extend_while_whitespace(vis).shrink_to_hi())
Copy link
Member Author

@fmease fmease Nov 8, 2025

Choose a reason for hiding this comment

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

This pattern occurs in three more places (tho you can't really abstract over it). It yields a syntactically correct suggestion with any(*) combination of trait modifiers/qualifiers present and can deal with inherited visibility, pub , pub(…) and pub(…) (i.e., no trailing space).

(*): It does not account for specialization's default which theoretically comes before const (like visibility), however that's actually syntactically invalid but the parser does recover from it. Still, it's really not worth accounting for.

@rust-log-analyzer

This comment has been minimized.

@fmease fmease force-pushed the rm-const_trait-attr branch from 1009c65 to c262920 Compare November 8, 2025 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-run-make Area: port run-make Makefiles to rmake.rs F-const_trait_impl `#![feature(const_trait_impl)]` PG-const-traits Project group: Const traits 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. T-libs Relevant to the library 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-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. 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.

4 participants