From 8f1eb345eacae619cf3fdeb17ef7bc6ec581fa2e Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 31 Oct 2019 18:46:29 +0200 Subject: [PATCH] Revert "pre-expansion gate const_generics" This reverts commit 49cbfa1a6f6469ddbc0e88161e52104cc87aea9b. --- src/libsyntax/feature_gate/check.rs | 12 +++++++++++- .../const-param-in-trait-ungated.stderr | 4 ++-- ...-type-depends-on-type-param-ungated.stderr | 4 ++-- .../const-generics/issues/issue-60263.stderr | 4 ++-- .../feature-gate-const_generics-ptr.stderr | 8 ++++---- .../feature-gate-const_generics.rs | 5 ----- .../feature-gate-const_generics.stderr | 19 +++++-------------- 7 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs index bcafb9e03ff0..3a32f12b255c 100644 --- a/src/libsyntax/feature_gate/check.rs +++ b/src/libsyntax/feature_gate/check.rs @@ -3,7 +3,7 @@ use super::accepted::ACCEPTED_FEATURES; use super::removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES}; use super::builtin_attrs::{AttributeGate, BUILTIN_ATTRIBUTE_MAP}; -use crate::ast::{self, NodeId, PatKind, RangeEnd, VariantData}; +use crate::ast::{self, NodeId, GenericParam, GenericParamKind, PatKind, RangeEnd, VariantData}; use crate::attr::{self, check_builtin_attribute}; use crate::source_map::Spanned; use crate::edition::{ALL_EDITIONS, Edition}; @@ -594,6 +594,16 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { visit::walk_fn(self, fn_kind, fn_decl, span) } + fn visit_generic_param(&mut self, param: &'a GenericParam) { + match param.kind { + GenericParamKind::Const { .. } => + gate_feature_post!(&self, const_generics, param.ident.span, + "const generics are unstable"), + _ => {} + } + visit::walk_generic_param(self, param) + } + fn visit_trait_item(&mut self, ti: &'a ast::TraitItem) { match ti.kind { ast::TraitItemKind::Method(ref sig, ref block) => { diff --git a/src/test/ui/const-generics/const-param-in-trait-ungated.stderr b/src/test/ui/const-generics/const-param-in-trait-ungated.stderr index 330c93e83b5e..cfb1f8b581c8 100644 --- a/src/test/ui/const-generics/const-param-in-trait-ungated.stderr +++ b/src/test/ui/const-generics/const-param-in-trait-ungated.stderr @@ -1,8 +1,8 @@ error[E0658]: const generics are unstable - --> $DIR/const-param-in-trait-ungated.rs:1:13 + --> $DIR/const-param-in-trait-ungated.rs:1:19 | LL | trait Trait {} - | ^^^^^^^^^^^ + | ^ | = note: for more information, see https://github.com/rust-lang/rust/issues/44580 = help: add `#![feature(const_generics)]` to the crate attributes to enable diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr b/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr index e34a2da24cec..a2872ab982da 100644 --- a/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr @@ -1,8 +1,8 @@ error[E0658]: const generics are unstable - --> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:13 + --> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:19 | LL | struct B(PhantomData<[T; N]>); - | ^^^^^^^^^^ + | ^ | = note: for more information, see https://github.com/rust-lang/rust/issues/44580 = help: add `#![feature(const_generics)]` to the crate attributes to enable diff --git a/src/test/ui/const-generics/issues/issue-60263.stderr b/src/test/ui/const-generics/issues/issue-60263.stderr index 5223c8c5137a..fe7b6fdb1904 100644 --- a/src/test/ui/const-generics/issues/issue-60263.stderr +++ b/src/test/ui/const-generics/issues/issue-60263.stderr @@ -1,8 +1,8 @@ error[E0658]: const generics are unstable - --> $DIR/issue-60263.rs:1:10 + --> $DIR/issue-60263.rs:1:16 | LL | struct B; - | ^^^^^^^^^^^ + | ^ | = note: for more information, see https://github.com/rust-lang/rust/issues/44580 = help: add `#![feature(const_generics)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-const_generics-ptr.stderr b/src/test/ui/feature-gates/feature-gate-const_generics-ptr.stderr index 790bc33e2683..935f84b9163d 100644 --- a/src/test/ui/feature-gates/feature-gate-const_generics-ptr.stderr +++ b/src/test/ui/feature-gates/feature-gate-const_generics-ptr.stderr @@ -1,17 +1,17 @@ error[E0658]: const generics are unstable - --> $DIR/feature-gate-const_generics-ptr.rs:1:16 + --> $DIR/feature-gate-const_generics-ptr.rs:1:22 | LL | struct ConstFn; - | ^^^^^^^^^^^^^ + | ^ | = note: for more information, see https://github.com/rust-lang/rust/issues/44580 = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: const generics are unstable - --> $DIR/feature-gate-const_generics-ptr.rs:5:17 + --> $DIR/feature-gate-const_generics-ptr.rs:5:23 | LL | struct ConstPtr; - | ^^^^^^^^^^^^^^^^^^^ + | ^ | = note: for more information, see https://github.com/rust-lang/rust/issues/44580 = help: add `#![feature(const_generics)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-const_generics.rs b/src/test/ui/feature-gates/feature-gate-const_generics.rs index 0adc9902a693..fe1ded1c4bbc 100644 --- a/src/test/ui/feature-gates/feature-gate-const_generics.rs +++ b/src/test/ui/feature-gates/feature-gate-const_generics.rs @@ -2,9 +2,4 @@ fn foo() {} //~ ERROR const generics are unstable struct Foo([(); X]); //~ ERROR const generics are unstable -macro_rules! accept_item { ($i:item) => {} } -accept_item! { - impl A {} //~ ERROR const generics are unstable -} - fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-const_generics.stderr b/src/test/ui/feature-gates/feature-gate-const_generics.stderr index f0154ed289f1..468e9c31d37e 100644 --- a/src/test/ui/feature-gates/feature-gate-const_generics.stderr +++ b/src/test/ui/feature-gates/feature-gate-const_generics.stderr @@ -1,30 +1,21 @@ error[E0658]: const generics are unstable - --> $DIR/feature-gate-const_generics.rs:1:8 + --> $DIR/feature-gate-const_generics.rs:1:14 | LL | fn foo() {} - | ^^^^^^^^^^^ + | ^ | = note: for more information, see https://github.com/rust-lang/rust/issues/44580 = help: add `#![feature(const_generics)]` to the crate attributes to enable error[E0658]: const generics are unstable - --> $DIR/feature-gate-const_generics.rs:3:12 + --> $DIR/feature-gate-const_generics.rs:3:18 | LL | struct Foo([(); X]); - | ^^^^^^^^^^^^^^ + | ^ | = note: for more information, see https://github.com/rust-lang/rust/issues/44580 = help: add `#![feature(const_generics)]` to the crate attributes to enable -error[E0658]: const generics are unstable - --> $DIR/feature-gate-const_generics.rs:7:10 - | -LL | impl A {} - | ^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/44580 - = help: add `#![feature(const_generics)]` to the crate attributes to enable - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`.