Skip to content

Commit 9a02e6d

Browse files
authored
Unrolled build for #144956
Rollup merge of #144956 - fmease:gate-const-trait-syntax, r=BoxyUwU Gate const trait syntax Missed this during my review of #143879, huge apologies! Fixes [after beta backport] #144958. cc ``@fee1-dead`` r? ``@BoxyUwU`` or anyone
2 parents 7d82b83 + 092c6f3 commit 9a02e6d

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

compiler/rustc_parse/src/parser/item.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,9 @@ impl<'a> Parser<'a> {
885885
/// Parses `unsafe? auto? trait Foo { ... }` or `trait Foo = Bar;`.
886886
fn parse_item_trait(&mut self, attrs: &mut AttrVec, lo: Span) -> PResult<'a, ItemKind> {
887887
let constness = self.parse_constness(Case::Sensitive);
888+
if let Const::Yes(span) = constness {
889+
self.psess.gated_spans.gate(sym::const_trait_impl, span);
890+
}
888891
let safety = self.parse_safety(Case::Sensitive);
889892
// Parse optional `auto` prefix.
890893
let is_auto = if self.eat_keyword(exp!(Auto)) {

tests/ui/traits/const-traits/feature-gate.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ impl const T for S {}
1313
const fn f<A: [const] T>() {} //[stock]~ ERROR const trait impls are experimental
1414
fn g<A: const T>() {} //[stock]~ ERROR const trait impls are experimental
1515

16+
const trait Trait {} //[stock]~ ERROR const trait impls are experimental
17+
#[cfg(false)] const trait Trait {} //[stock]~ ERROR const trait impls are experimental
18+
1619
macro_rules! discard { ($ty:ty) => {} }
1720

1821
discard! { impl [const] T } //[stock]~ ERROR const trait impls are experimental

tests/ui/traits/const-traits/feature-gate.stock.stderr

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,27 @@ LL | fn g<A: const T>() {}
2929
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
3030

3131
error[E0658]: const trait impls are experimental
32-
--> $DIR/feature-gate.rs:18:17
32+
--> $DIR/feature-gate.rs:16:1
33+
|
34+
LL | const trait Trait {}
35+
| ^^^^^
36+
|
37+
= note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information
38+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
39+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
40+
41+
error[E0658]: const trait impls are experimental
42+
--> $DIR/feature-gate.rs:17:15
43+
|
44+
LL | #[cfg(false)] const trait Trait {}
45+
| ^^^^^
46+
|
47+
= note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information
48+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
49+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
50+
51+
error[E0658]: const trait impls are experimental
52+
--> $DIR/feature-gate.rs:21:17
3353
|
3454
LL | discard! { impl [const] T }
3555
| ^^^^^^^
@@ -39,7 +59,7 @@ LL | discard! { impl [const] T }
3959
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
4060

4161
error[E0658]: const trait impls are experimental
42-
--> $DIR/feature-gate.rs:19:17
62+
--> $DIR/feature-gate.rs:22:17
4363
|
4464
LL | discard! { impl const T }
4565
| ^^^^^
@@ -58,6 +78,6 @@ LL | #[const_trait]
5878
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
5979
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
6080

61-
error: aborting due to 6 previous errors
81+
error: aborting due to 8 previous errors
6282

6383
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)