Skip to content

Ungate associated types, globs and default type parameters #20568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ pub fn phase_2_configure_and_expand(sess: &Session,
}
let cfg = syntax::ext::expand::ExpansionConfig {
crate_name: crate_name.to_string(),
deriving_hash_type_parameter: sess.features.borrow().default_type_params,
enable_quotes: sess.features.borrow().quote,
recursion_limit: sess.recursion_limit.get(),
};
Expand Down
1 change: 1 addition & 0 deletions src/librustc_llvm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#![feature(globs)]
#![feature(link_args)]
#![feature(unboxed_closures)]
#![feature(old_orphan_check)]

extern crate libc;

Expand Down
1 change: 1 addition & 0 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#![feature(globs, phase, slicing_syntax)]
#![feature(rustc_diagnostic_macros)]
#![feature(associated_types)]
#![feature(old_orphan_check)]

#[phase(plugin, link)] extern crate log;
#[phase(plugin, link)] extern crate syntax;
Expand Down
8 changes: 0 additions & 8 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,6 @@ fn create_substs_for_ast_path<'tcx,AC,RS>(
supplied_ty_param_count)[]);
}

if supplied_ty_param_count > required_ty_param_count
&& !this.tcx().sess.features.borrow().default_type_params {
span_err!(this.tcx().sess, span, E0108,
"default type parameters are experimental and possibly buggy");
span_help!(this.tcx().sess, span,
"add #![feature(default_type_params)] to the crate attributes to enable");
}

let mut substs = Substs::new_type(types, regions);

match self_ty {
Expand Down
20 changes: 7 additions & 13 deletions src/libsyntax/ext/deriving/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,14 @@ pub fn expand_deriving_hash<F>(cx: &mut ExtCtxt,
F: FnOnce(P<Item>),
{

let (path, generics, args) = if cx.ecfg.deriving_hash_type_parameter {
(Path::new_(vec!("std", "hash", "Hash"), None,
vec!(box Literal(Path::new_local("__S"))), true),
LifetimeBounds {
lifetimes: Vec::new(),
bounds: vec!(("__S",
vec!(Path::new(vec!("std", "hash", "Writer"))))),
},
Path::new_local("__S"))
} else {
(Path::new(vec!("std", "hash", "Hash")),
LifetimeBounds::empty(),
Path::new(vec!("std", "hash", "sip", "SipState")))
let path = Path::new_(vec!("std", "hash", "Hash"), None,
vec!(box Literal(Path::new_local("__S"))), true);
let generics = LifetimeBounds {
lifetimes: Vec::new(),
bounds: vec!(("__S",
vec!(Path::new(vec!("std", "hash", "Writer"))))),
};
let args = Path::new_local("__S");
let inline = cx.meta_word(span, InternedString::new("inline"));
let attrs = vec!(cx.attribute(span, inline));
let hash_trait_def = TraitDef {
Expand Down
2 changes: 0 additions & 2 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,6 @@ fn new_span(cx: &ExtCtxt, sp: Span) -> Span {

pub struct ExpansionConfig {
pub crate_name: String,
pub deriving_hash_type_parameter: bool,
pub enable_quotes: bool,
pub recursion_limit: uint,
}
Expand All @@ -1170,7 +1169,6 @@ impl ExpansionConfig {
pub fn default(crate_name: String) -> ExpansionConfig {
ExpansionConfig {
crate_name: crate_name,
deriving_hash_type_parameter: false,
enable_quotes: false,
recursion_limit: 64,
}
Expand Down
56 changes: 5 additions & 51 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use std::ascii::AsciiExt;

// if you change this list without updating src/doc/reference.md, @cmr will be sad
static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
("globs", Active),
("globs", Accepted),
("macro_rules", Active),
("struct_variant", Accepted),
("asm", Active),
Expand All @@ -54,7 +54,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
("lang_items", Active),

("simd", Active),
("default_type_params", Active),
("default_type_params", Accepted),
("quote", Active),
("link_llvm_intrinsics", Active),
("linkage", Active),
Expand All @@ -67,7 +67,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
("import_shadowing", Active),
("advanced_slice_patterns", Active),
("tuple_indexing", Accepted),
("associated_types", Active),
("associated_types", Accepted),
("visible_private_types", Active),
("slicing_syntax", Active),

Expand Down Expand Up @@ -112,7 +112,6 @@ enum Status {
/// A set of features to be used by later passes.
#[derive(Copy)]
pub struct Features {
pub default_type_params: bool,
pub unboxed_closures: bool,
pub rustc_diagnostic_macros: bool,
pub import_shadowing: bool,
Expand All @@ -125,7 +124,6 @@ pub struct Features {
impl Features {
pub fn new() -> Features {
Features {
default_type_params: false,
unboxed_closures: false,
rustc_diagnostic_macros: false,
import_shadowing: false,
Expand Down Expand Up @@ -232,13 +230,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {

fn visit_view_item(&mut self, i: &ast::ViewItem) {
match i.node {
ast::ViewItemUse(ref path) => {
if let ast::ViewPathGlob(..) = path.node {
self.gate_feature("globs", path.span,
"glob import statements are \
experimental and possibly buggy");
}
}
ast::ViewItemUse(..) => {}
ast::ViewItemExternCrate(..) => {
for attr in i.attrs.iter() {
if attr.name().get() == "phase"{
Expand Down Expand Up @@ -294,7 +286,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
}
}

ast::ItemImpl(_, polarity, _, _, _, ref items) => {
ast::ItemImpl(_, polarity, _, _, _, _) => {
match polarity {
ast::ImplPolarity::Negative => {
self.gate_feature("optin_builtin_traits",
Expand All @@ -313,18 +305,6 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
many unsafe patterns and may be \
removed in the future");
}

for item in items.iter() {
match *item {
ast::MethodImplItem(_) => {}
ast::TypeImplItem(ref typedef) => {
self.gate_feature("associated_types",
typedef.span,
"associated types are \
experimental")
}
}
}
}

_ => {}
Expand All @@ -333,17 +313,6 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
visit::walk_item(self, i);
}

fn visit_trait_item(&mut self, trait_item: &ast::TraitItem) {
match *trait_item {
ast::RequiredMethod(_) | ast::ProvidedMethod(_) => {}
ast::TypeTraitItem(ref ti) => {
self.gate_feature("associated_types",
ti.ty_param.span,
"associated types are experimental")
}
}
}

fn visit_foreign_item(&mut self, i: &ast::ForeignItem) {
if attr::contains_name(i.attrs[], "linkage") {
self.gate_feature("linkage", i.span,
Expand Down Expand Up @@ -385,20 +354,6 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
visit::walk_expr(self, e);
}

fn visit_generics(&mut self, generics: &ast::Generics) {
for type_parameter in generics.ty_params.iter() {
match type_parameter.default {
Some(ref ty) => {
self.gate_feature("default_type_params", ty.span,
"default type parameters are \
experimental and possibly buggy");
}
None => {}
}
}
visit::walk_generics(self, generics);
}

fn visit_attribute(&mut self, attr: &ast::Attribute) {
if attr::contains_name(slice::ref_slice(attr), "lang") {
self.gate_feature("lang_items",
Expand Down Expand Up @@ -504,7 +459,6 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::C
check(&mut cx, krate);

(Features {
default_type_params: cx.has_feature("default_type_params"),
unboxed_closures: cx.has_feature("unboxed_closures"),
rustc_diagnostic_macros: cx.has_feature("rustc_diagnostic_macros"),
import_shadowing: cx.has_feature("import_shadowing"),
Expand Down
1 change: 0 additions & 1 deletion src/test/auxiliary/associated-types-cc-lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// cross-crate scenario.

#![crate_type="lib"]
#![feature(associated_types)]

pub trait Bar {
type T;
Expand Down
2 changes: 0 additions & 2 deletions src/test/auxiliary/default_type_params_xc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(default_type_params)]

pub struct Heap;

pub struct FakeHeap;
Expand Down
1 change: 0 additions & 1 deletion src/test/auxiliary/issue-16643.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

#![crate_type = "lib"]
#![feature(associated_types)]

pub struct TreeBuilder<H>;

Expand Down
2 changes: 0 additions & 2 deletions src/test/auxiliary/issue_20389.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(associated_types)]

pub trait T {
type C;
}
1 change: 0 additions & 1 deletion src/test/auxiliary/issue_2316_b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

#![allow(unused_imports)]
#![feature(globs)]

extern crate issue_2316_a;

Expand Down
2 changes: 1 addition & 1 deletion src/test/auxiliary/macro_crate_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// force-host

#![feature(globs, plugin_registrar, macro_rules, quote)]
#![feature(plugin_registrar, macro_rules, quote)]

extern crate syntax;
extern crate rustc;
Expand Down
3 changes: 0 additions & 3 deletions src/test/auxiliary/namespaced_enum_emulate_flat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// <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.
#![feature(globs)]

pub use Foo::*;

Expand All @@ -34,5 +33,3 @@ pub mod nest {
pub fn foo() {}
}
}


2 changes: 0 additions & 2 deletions src/test/auxiliary/overloaded_autoderef_xc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(associated_types)]

use std::ops::Deref;

struct DerefWithHelper<H, T> {
Expand Down
2 changes: 1 addition & 1 deletion src/test/auxiliary/syntax-extension-with-dll-deps-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// force-host

#![crate_type = "dylib"]
#![feature(plugin_registrar, quote, globs)]
#![feature(plugin_registrar, quote)]

extern crate "syntax-extension-with-dll-deps-1" as other;
extern crate syntax;
Expand Down
2 changes: 0 additions & 2 deletions src/test/auxiliary/trait_inheritance_overloading_xc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(associated_types)]

use std::cmp::PartialEq;
use std::ops::{Add, Sub, Mul};

Expand Down
2 changes: 1 addition & 1 deletion src/test/bench/shootout-fasta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.

#![feature(associated_types, slicing_syntax)]
#![feature(slicing_syntax)]

use std::cmp::min;
use std::io::{BufferedWriter, File};
Expand Down
2 changes: 1 addition & 1 deletion src/test/bench/shootout-k-nucleotide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

// ignore-android see #10393 #13206

#![feature(associated_types, slicing_syntax)]
#![feature(slicing_syntax)]

use std::ascii::OwnedAsciiExt;
use std::iter::repeat;
Expand Down
2 changes: 0 additions & 2 deletions src/test/bench/shootout-meteor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@

// no-pretty-expanded FIXME #15189

#![feature(associated_types)]

use std::iter::repeat;
use std::sync::Arc;
use std::sync::mpsc::channel;
Expand Down
2 changes: 1 addition & 1 deletion src/test/bench/shootout-reverse-complement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

// ignore-android see #10393 #13206

#![feature(associated_types, slicing_syntax, unboxed_closures)]
#![feature(slicing_syntax, unboxed_closures)]

extern crate libc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// just propagate the error.

#![crate_type = "lib"]
#![feature(associated_types, default_type_params, lang_items)]
#![feature(lang_items)]
#![no_std]

#[lang="sized"]
Expand Down
2 changes: 0 additions & 2 deletions src/test/compile-fail/associated-types-bound-failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// Test equality constraints on associated types in a where clause.

#![feature(associated_types)]

pub trait ToInt {
fn to_int(&self) -> int;
}
Expand Down
2 changes: 0 additions & 2 deletions src/test/compile-fail/associated-types-eq-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// Test equality constraints on associated types. Check that unsupported syntax
// does not ICE.

#![feature(associated_types)]

pub trait Foo {
type A;
fn boo(&self) -> <Self as Foo>::A;
Expand Down
2 changes: 0 additions & 2 deletions src/test/compile-fail/associated-types-eq-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// Test equality constraints on associated types. Check we get an error when an
// equality constraint is used in a qualified path.

#![feature(associated_types)]

pub trait Foo {
type A;
fn boo(&self) -> <Self as Foo>::A;
Expand Down
2 changes: 0 additions & 2 deletions src/test/compile-fail/associated-types-eq-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// Test equality constraints on associated types. Check we get type errors
// where we should.

#![feature(associated_types)]

pub trait Foo {
type A;
fn boo(&self) -> <Self as Foo>::A;
Expand Down
2 changes: 0 additions & 2 deletions src/test/compile-fail/associated-types-eq-expr-path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// Check that an associated type cannot be bound in an expression path.

#![feature(associated_types)]

trait Foo {
type A;
fn bar() -> int;
Expand Down
Loading