about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2024-11-20 17:04:05 +0800
committerDeadbeef <ent3rm4n@gmail.com>2024-11-20 17:04:05 +0800
commit030ddeecabb73b4e3d93735ee719c566baa2f388 (patch)
tree4f071a7bbddf2872f0ffeac0bd7a73bcc30c0bf6
parentbcfea1f8d253fd43eab36832fa601d192ac603d5 (diff)
downloadrust-030ddeecabb73b4e3d93735ee719c566baa2f388.tar.gz
rust-030ddeecabb73b4e3d93735ee719c566baa2f388.zip
don't require const stability for const impls
-rw-r--r--compiler/rustc_passes/src/stability.rs11
-rw-r--r--tests/ui/stability-attribute/missing-const-stability.rs2
-rw-r--r--tests/ui/stability-attribute/missing-const-stability.stderr11
3 files changed, 3 insertions, 21 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
diff --git a/tests/ui/stability-attribute/missing-const-stability.rs b/tests/ui/stability-attribute/missing-const-stability.rs
index 10c31d79438..19820730736 100644
--- a/tests/ui/stability-attribute/missing-const-stability.rs
+++ b/tests/ui/stability-attribute/missing-const-stability.rs
@@ -27,7 +27,7 @@ pub trait Bar {
 }
 #[stable(feature = "stable", since = "1.0.0")]
 impl const Bar for Foo {
-    //~^ ERROR implementation has missing const stability attribute
+    // ok because all users must enable `const_trait_impl`
     fn fun() {}
 }
 
diff --git a/tests/ui/stability-attribute/missing-const-stability.stderr b/tests/ui/stability-attribute/missing-const-stability.stderr
index ad8a1fa9d36..baa4c34af06 100644
--- a/tests/ui/stability-attribute/missing-const-stability.stderr
+++ b/tests/ui/stability-attribute/missing-const-stability.stderr
@@ -4,15 +4,6 @@ error: function has missing const stability attribute
 LL | pub const fn foo() {}
    | ^^^^^^^^^^^^^^^^^^^^^
 
-error: implementation has missing const stability attribute
-  --> $DIR/missing-const-stability.rs:29:1
-   |
-LL | / impl const Bar for Foo {
-LL | |
-LL | |     fn fun() {}
-LL | | }
-   | |_^
-
 error: function has missing const stability attribute
   --> $DIR/missing-const-stability.rs:36:1
    |
@@ -25,5 +16,5 @@ error: associated function has missing const stability attribute
 LL |     pub const fn foo() {}
    |     ^^^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors