Skip to content

Commit 8f1eb34

Browse files
committed
Revert "pre-expansion gate const_generics"
This reverts commit 49cbfa1.
1 parent ada4a64 commit 8f1eb34

7 files changed

+26
-30
lines changed

src/libsyntax/feature_gate/check.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::accepted::ACCEPTED_FEATURES;
33
use super::removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES};
44
use super::builtin_attrs::{AttributeGate, BUILTIN_ATTRIBUTE_MAP};
55

6-
use crate::ast::{self, NodeId, PatKind, RangeEnd, VariantData};
6+
use crate::ast::{self, NodeId, GenericParam, GenericParamKind, PatKind, RangeEnd, VariantData};
77
use crate::attr::{self, check_builtin_attribute};
88
use crate::source_map::Spanned;
99
use crate::edition::{ALL_EDITIONS, Edition};
@@ -594,6 +594,16 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
594594
visit::walk_fn(self, fn_kind, fn_decl, span)
595595
}
596596

597+
fn visit_generic_param(&mut self, param: &'a GenericParam) {
598+
match param.kind {
599+
GenericParamKind::Const { .. } =>
600+
gate_feature_post!(&self, const_generics, param.ident.span,
601+
"const generics are unstable"),
602+
_ => {}
603+
}
604+
visit::walk_generic_param(self, param)
605+
}
606+
597607
fn visit_trait_item(&mut self, ti: &'a ast::TraitItem) {
598608
match ti.kind {
599609
ast::TraitItemKind::Method(ref sig, ref block) => {

src/test/ui/const-generics/const-param-in-trait-ungated.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0658]: const generics are unstable
2-
--> $DIR/const-param-in-trait-ungated.rs:1:13
2+
--> $DIR/const-param-in-trait-ungated.rs:1:19
33
|
44
LL | trait Trait<const T: ()> {}
5-
| ^^^^^^^^^^^
5+
| ^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/44580
88
= help: add `#![feature(const_generics)]` to the crate attributes to enable

src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0658]: const generics are unstable
2-
--> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:13
2+
--> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:19
33
|
44
LL | struct B<T, const N: T>(PhantomData<[T; N]>);
5-
| ^^^^^^^^^^
5+
| ^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/44580
88
= help: add `#![feature(const_generics)]` to the crate attributes to enable

src/test/ui/const-generics/issues/issue-60263.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0658]: const generics are unstable
2-
--> $DIR/issue-60263.rs:1:10
2+
--> $DIR/issue-60263.rs:1:16
33
|
44
LL | struct B<const I: u8>;
5-
| ^^^^^^^^^^^
5+
| ^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/44580
88
= help: add `#![feature(const_generics)]` to the crate attributes to enable

src/test/ui/feature-gates/feature-gate-const_generics-ptr.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0658]: const generics are unstable
2-
--> $DIR/feature-gate-const_generics-ptr.rs:1:16
2+
--> $DIR/feature-gate-const_generics-ptr.rs:1:22
33
|
44
LL | struct ConstFn<const F: fn()>;
5-
| ^^^^^^^^^^^^^
5+
| ^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/44580
88
= help: add `#![feature(const_generics)]` to the crate attributes to enable
99

1010
error[E0658]: const generics are unstable
11-
--> $DIR/feature-gate-const_generics-ptr.rs:5:17
11+
--> $DIR/feature-gate-const_generics-ptr.rs:5:23
1212
|
1313
LL | struct ConstPtr<const P: *const u32>;
14-
| ^^^^^^^^^^^^^^^^^^^
14+
| ^
1515
|
1616
= note: for more information, see https://github.com/rust-lang/rust/issues/44580
1717
= help: add `#![feature(const_generics)]` to the crate attributes to enable

src/test/ui/feature-gates/feature-gate-const_generics.rs

-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,4 @@ fn foo<const X: ()>() {} //~ ERROR const generics are unstable
22

33
struct Foo<const X: usize>([(); X]); //~ ERROR const generics are unstable
44

5-
macro_rules! accept_item { ($i:item) => {} }
6-
accept_item! {
7-
impl<const X: ()> A {} //~ ERROR const generics are unstable
8-
}
9-
105
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
error[E0658]: const generics are unstable
2-
--> $DIR/feature-gate-const_generics.rs:1:8
2+
--> $DIR/feature-gate-const_generics.rs:1:14
33
|
44
LL | fn foo<const X: ()>() {}
5-
| ^^^^^^^^^^^
5+
| ^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/44580
88
= help: add `#![feature(const_generics)]` to the crate attributes to enable
99

1010
error[E0658]: const generics are unstable
11-
--> $DIR/feature-gate-const_generics.rs:3:12
11+
--> $DIR/feature-gate-const_generics.rs:3:18
1212
|
1313
LL | struct Foo<const X: usize>([(); X]);
14-
| ^^^^^^^^^^^^^^
14+
| ^
1515
|
1616
= note: for more information, see https://github.com/rust-lang/rust/issues/44580
1717
= help: add `#![feature(const_generics)]` to the crate attributes to enable
1818

19-
error[E0658]: const generics are unstable
20-
--> $DIR/feature-gate-const_generics.rs:7:10
21-
|
22-
LL | impl<const X: ()> A {}
23-
| ^^^^^^^^^^^
24-
|
25-
= note: for more information, see https://github.com/rust-lang/rust/issues/44580
26-
= help: add `#![feature(const_generics)]` to the crate attributes to enable
27-
28-
error: aborting due to 3 previous errors
19+
error: aborting due to 2 previous errors
2920

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

0 commit comments

Comments
 (0)