diff options
| author | Sunjay Varma <varma.sunjay@gmail.com> | 2017-11-09 21:40:14 -0500 |
|---|---|---|
| committer | Sunjay Varma <varma.sunjay@gmail.com> | 2017-12-01 01:26:29 -0500 |
| commit | f29613437fb1925ead92f81cd2495d7b92a5fd2a (patch) | |
| tree | 1d42c8b6e500c9b20d5414ef624897a6668dc7b1 | |
| parent | 6bd8ea1a6b88545e59442a3603f1b235cf57e3ba (diff) | |
| download | rust-f29613437fb1925ead92f81cd2495d7b92a5fd2a.tar.gz rust-f29613437fb1925ead92f81cd2495d7b92a5fd2a.zip | |
Adding feature gate
7 files changed, 36 insertions, 0 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index c1223efb27b..9b5be298fd5 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -431,6 +431,9 @@ declare_features! ( // Nested groups in `use` (RFC 2128) (active, use_nested_groups, "1.23.0", Some(44494)), + + // generic associated types (RFC 1598) + (active, generic_associated_types, "1.23.0", Some(44265)), ); declare_features! ( @@ -1618,6 +1621,9 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { gate_feature_post!(&self, associated_type_defaults, ti.span, "associated type defaults are unstable"); } + _ if ti.generics.is_parameterized() => { + gate_feature_post!(&self, generic_associated_types, ti.span, "generic associated types are unstable"); + } _ => {} } visit::walk_trait_item(self, ti); @@ -1636,6 +1642,9 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { gate_feature_post!(&self, const_fn, ii.span, "const fn is unstable"); } } + _ if ii.generics.is_parameterized() => { + gate_feature_post!(&self, generic_associated_types, ii.span, "generic associated types are unstable"); + } _ => {} } visit::walk_impl_item(self, ii); diff --git a/src/test/compile-fail/generic-associated-types.rs b/src/test/compile-fail/generic-associated-types.rs new file mode 100644 index 00000000000..a8fc8226f31 --- /dev/null +++ b/src/test/compile-fail/generic-associated-types.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::Deref; + +trait PointerFamily { + type Pointer<T>: Deref<Target = T>; +} + +fn main() {} diff --git a/src/test/run-pass/rfc1598-generic-associated-types/construct_with_other_type.rs b/src/test/run-pass/rfc1598-generic-associated-types/construct_with_other_type.rs index d3102360532..81475c6888d 100644 --- a/src/test/run-pass/rfc1598-generic-associated-types/construct_with_other_type.rs +++ b/src/test/run-pass/rfc1598-generic-associated-types/construct_with_other_type.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(generic_associated_types)] + trait Foo { type Bar<'a, 'b>; } diff --git a/src/test/run-pass/rfc1598-generic-associated-types/iterable.rs b/src/test/run-pass/rfc1598-generic-associated-types/iterable.rs index f52a77fb258..40b1d131292 100644 --- a/src/test/run-pass/rfc1598-generic-associated-types/iterable.rs +++ b/src/test/run-pass/rfc1598-generic-associated-types/iterable.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(generic_associated_types)] + trait Iterable { type Item<'a>; type Iter<'a>: Iterator<Item = Self::Item<'a>>; diff --git a/src/test/run-pass/rfc1598-generic-associated-types/pointer_family.rs b/src/test/run-pass/rfc1598-generic-associated-types/pointer_family.rs index 4ec6b418c05..0d0f1396969 100644 --- a/src/test/run-pass/rfc1598-generic-associated-types/pointer_family.rs +++ b/src/test/run-pass/rfc1598-generic-associated-types/pointer_family.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(generic_associated_types)] + use std::rc::Rc; use std::sync::Arc; use std::ops::Deref; diff --git a/src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs b/src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs index 33be5c1cc63..fd476e2592d 100644 --- a/src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs +++ b/src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(generic_associated_types)] + use std::fmt::Display; trait StreamingIterator { diff --git a/src/test/run-pass/rfc1598-generic-associated-types/where.rs b/src/test/run-pass/rfc1598-generic-associated-types/where.rs index 8fe7ebc1309..269e5dc26fc 100644 --- a/src/test/run-pass/rfc1598-generic-associated-types/where.rs +++ b/src/test/run-pass/rfc1598-generic-associated-types/where.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(generic_associated_types)] + // Checking the interaction with this other feature #![feature(associated_type_defaults)] |
