about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-11-23 20:50:15 +0800
committerGitHub <noreply@github.com>2024-11-23 20:50:15 +0800
commit75b8f433e38dfed6aa16a42137bf048d8e668d27 (patch)
treec99066c6f99b6df10b438a81575603a3a75ba6cd /compiler/rustc_passes/src
parent92f5144c9c30804384be66b3fc54e61d358d0114 (diff)
parent514ef180fd631b01c0f119991baaf217735ca849 (diff)
downloadrust-75b8f433e38dfed6aa16a42137bf048d8e668d27.tar.gz
rust-75b8f433e38dfed6aa16a42137bf048d8e668d27.zip
Rollup merge of #133237 - fee1-dead-contrib:constadd, r=compiler-errors
Minimally constify `Add`

* This PR removes the requirement for `impl const` to have a const stability attribute. cc ``@RalfJung`` I believe you mentioned that it would make much more sense to require `const_trait`s to have const stability instead. I agree with that sentiment but I don't think that is _required_ for a small scale experimentation like this PR. https://github.com/rust-lang/project-const-traits/issues/16 should definitely be prioritized in the future, but removing the impl check should be good for now as all callers need `const_trait_impl` enabled for any const impl to work.
* This PR is intentionally minimal as constifying other traits can become more complicated (`PartialEq`, for example, would run into requiring implementing it for `str` as that is used in matches, which runs into the implementation for slice equality which uses specialization)

Per the reasons above, anyone who is interested in making traits `const` in the standard library are **strongly encouraged** to reach out to us on the [Zulip channel](https://rust-lang.zulipchat.com/#narrow/channel/419616-t-compiler.2Fproject-const-traits) before proceeding with the work.

cc ``@rust-lang/project-const-traits``

I believe there is prior approval from libs that we can experiment, so

r? project-const-traits
Diffstat (limited to 'compiler/rustc_passes/src')
-rw-r--r--compiler/rustc_passes/src/stability.rs11
1 files changed, 1 insertions, 10 deletions
diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs
index 4a793f1875e..2809ad453ff 100644
--- a/compiler/rustc_passes/src/stability.rs
+++ b/compiler/rustc_passes/src/stability.rs
@@ -590,16 +590,7 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
     }
 
     fn check_missing_const_stability(&self, def_id: LocalDefId, span: Span) {
-        // if the const impl is derived using the `derive_const` attribute,
-        // then it would be "stable" at least for the impl.
-        // We gate usages of it using `feature(const_trait_impl)` anyways
-        // so there is no unstable leakage
-        if self.tcx.is_automatically_derived(def_id.to_def_id()) {
-            return;
-        }
-
-        let is_const = self.tcx.is_const_fn(def_id.to_def_id())
-            || self.tcx.is_const_trait_impl(def_id.to_def_id());
+        let is_const = self.tcx.is_const_fn(def_id.to_def_id());
 
         // Reachable const fn must have a stability attribute.
         if is_const