Repository navigation
Description
This is a tracking issue for the RFC "3762" (rust-lang/rfcs#3762).
The feature gate for the issue is #![feature(const_trait_impl)].
Note
Questions about the usage of this feature should be directed to the t-compiler/project-const-traits Zulip channel. Use t-lang/effects and the RFC (until it gets accepted) to discuss the language feature and future extensions.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
Components
Removed for good#[const_trait]attributeimpl const TraitT: [const] Traitremoved in Remove rustc_on_unimplemented's append_const_msg #154653append_const_msgonrustc_on_unimplemented#[derive_const]trait Destruct
Steps
- Implement the RFC
- Add
const trait Traitand migrate away from#[const_trait]parseconst trait Trait#143879 - Split
derive_const,-> impl [const] Traitinto separate feature[s] to make initial stabilization minimal - add a perf stress test for const trait impls and complex bounds that need solving
- Adjust documentation (see instructions on rustc-dev-guide)
- Style updates for any new syntax (nightly-style-procedure)
- Style team decision on new formatting
- Formatting for new syntax has been added to the Style Guide
- (non-blocking) Formatting has been implemented in
rustfmt
- Stabilization PR (see instructions on rustc-dev-guide)
- Error against putting
rustc_const_unstableattribute onconstimpls as they are now insta-stable. - Treat
consttraitdefault method bodies andconstimplbodies asstableconst fnbodies. We need to prevent accidentally stabilizing an implementation that uses unstable lang/libconst fnfeatures. - Change Rustdoc to display
[const]bounds or what syntax we decided it to be.
- Error against putting
Unresolved Questions
-
#[derive_const]for custom derives (proc macros) Provide a way for derives to know if they were invoked with#[derive_const]#118304
Implementation history
- See Tracking issue for closed RFC 2632,
impl const Trait for Tyand[const](conditionally const) syntax (const_trait_impl) #67792 for previous tracking issue and its history - Incomplete list of PRs implementing/refining the feature: https://github.com/rust-lang/rust/pulls?q=is%3Apr+label%3AF-const_trait_impl+is%3Aclosed+
- Add a diagnostic attribute for special casing const bound errors for non-const impls #148641
Activity
impl const Trait for Tyand[const](conditionally const) syntax (const_trait_impl) #67792 as a duplicate of this issuecarlocorradini commentedon Jul 13, 2025
clarfonthey commentedon Jul 13, 2025
Should this tracking issue also be used for constifying libstd traits or should that get a separate issue? Since that was the trend before the current RFC, but there's been a lot of lapsing since, and it probably would require opening a lot of new issues to fix it.
I think that at least some traits that are kind of fundamental and require extra compiler support (like
Fn*) should be tracked here but mostly just want to clarify.Edit: also to clarify, since I'm particularly interested in constifying a bunch of traits to make SIMD operations const-usable, I'd be more than happy to spearhead the effort to separate out the const traits into their own tracking issues. Just want to make sure this is the desired approach before I do anything.
fee1-dead commentedon Jul 13, 2025
I think we're okay with separate tracking issues but please make sure that those tracking issues link back to this one. As when we do stabilize const traits most of those have to be stabilized in tandem (since you can't really keep const impls unstable).
clarfonthey commentedon Jul 13, 2025
Wouldn't #140399 help with that, presuming that this PR + some form of it that works for const-stability also apply before const traits are stable?
(I agree with you on linking back here, though.)
compiler-errors commentedon Jul 13, 2025
I'm not really sure if I understand the point made here about stabilizing things at the same time of stabilizing const traits in general.
Isn't that the the whole point of the feature checking in #135423 + #136055?
We definitely should be able to constify traits piecewise without them being insta-stable when we stabilize the
const_trait_implfeature gate. Of course impls can't be constified individually, but traits should be at least.fee1-dead commentedon Jul 13, 2025
sorry, I misspoke in my earlier comment. because we have const stability enforced on traits now we can of course keep traits const_unstable in libstd when we stabilize const_trait_impl, so yeah they should all be split
43 remaining items
chore: add TODO checker (#2044)
refactor(pg-proto): DEF-115/116/117 — round-3 tier escalations
refactor(pg-proto): DEF-116 closed via declarative macro — auto-scali…
docs(deferred): add §22 Rust-unstable watchlist
fix(rust): bỏ const fn cho role methods — Rust 1.97 chưa ổn định Part…
layout, gemm: a pin that catches a swap, and the blind spot named pro…
feat: const-fn FigmentSourceTag is_file/is_code/is_custom + kind and …
feat: const-fn FigmentNameTag is_format/is_env + kind and FigmentName…
feat: const-fn EnvMetadataTag is_prefixed/is_bare + kind and EnvMetad…
feat: const-fn AttributionRule confidence + is_exact/is_fallback — cl…
perf: make ReloadFailure::attribution_confidence const fn
perf: close ReloadFailure Some-iff-attribution forwarder quartet cons…
feat: add EnvMetadataTag::ordinal and as_str tag-side sibling pair
feat: lift axis_at<A: ClosedAxis>() to `const fn`, closing the trait-…
docs: write down the commentary rule, and check the part a machine can (