Skip to content

Commit 030ddee

Browse files
committed
don't require const stability for const impls
1 parent bcfea1f commit 030ddee

File tree

3 files changed

+3
-21
lines changed

3 files changed

+3
-21
lines changed

compiler/rustc_passes/src/stability.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -590,16 +590,7 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
590590
}
591591

592592
fn check_missing_const_stability(&self, def_id: LocalDefId, span: Span) {
593-
// if the const impl is derived using the `derive_const` attribute,
594-
// then it would be "stable" at least for the impl.
595-
// We gate usages of it using `feature(const_trait_impl)` anyways
596-
// so there is no unstable leakage
597-
if self.tcx.is_automatically_derived(def_id.to_def_id()) {
598-
return;
599-
}
600-
601-
let is_const = self.tcx.is_const_fn(def_id.to_def_id())
602-
|| self.tcx.is_const_trait_impl(def_id.to_def_id());
593+
let is_const = self.tcx.is_const_fn(def_id.to_def_id());
603594

604595
// Reachable const fn must have a stability attribute.
605596
if is_const

tests/ui/stability-attribute/missing-const-stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub trait Bar {
2727
}
2828
#[stable(feature = "stable", since = "1.0.0")]
2929
impl const Bar for Foo {
30-
//~^ ERROR implementation has missing const stability attribute
30+
// ok because all users must enable `const_trait_impl`
3131
fn fun() {}
3232
}
3333

tests/ui/stability-attribute/missing-const-stability.stderr

+1-10
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ error: function has missing const stability attribute
44
LL | pub const fn foo() {}
55
| ^^^^^^^^^^^^^^^^^^^^^
66

7-
error: implementation has missing const stability attribute
8-
--> $DIR/missing-const-stability.rs:29:1
9-
|
10-
LL | / impl const Bar for Foo {
11-
LL | |
12-
LL | | fn fun() {}
13-
LL | | }
14-
| |_^
15-
167
error: function has missing const stability attribute
178
--> $DIR/missing-const-stability.rs:36:1
189
|
@@ -25,5 +16,5 @@ error: associated function has missing const stability attribute
2516
LL | pub const fn foo() {}
2617
| ^^^^^^^^^^^^^^^^^^^^^
2718

28-
error: aborting due to 4 previous errors
19+
error: aborting due to 3 previous errors
2920

0 commit comments

Comments
 (0)