Adding feature gate

This commit is contained in:
Sunjay Varma 2017-11-09 21:40:14 -05:00
parent 6bd8ea1a6b
commit f29613437f
7 changed files with 36 additions and 0 deletions

View File

@ -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);

View File

@ -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() {}

View File

@ -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>;
}

View File

@ -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>>;

View File

@ -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;

View File

@ -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 {

View File

@ -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)]