diff --git a/src/doc/book/src/structs.md b/src/doc/book/src/structs.md index 51af343c13012..6423147e66e09 100644 --- a/src/doc/book/src/structs.md +++ b/src/doc/book/src/structs.md @@ -122,8 +122,6 @@ fields of the data structure are initialized with variables of the same names as the fields. ``` -#![feature(field_init_shorthand)] - #[derive(Debug)] struct Person<'a> { name: &'a str, diff --git a/src/doc/reference.md b/src/doc/reference.md index 7155641e2c28a..f2be20d4a7516 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2825,7 +2825,6 @@ This allows a compact syntax with less duplication. Example: ``` -# #![feature(field_init_shorthand)] # struct Point3d { x: i32, y: i32, z: i32 } # let x = 0; # let y_value = 0; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 5c0ec8de7ecd2..d144f7575a2e2 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -29,7 +29,7 @@ #![feature(conservative_impl_trait)] #![feature(const_fn)] #![feature(core_intrinsics)] -#![feature(field_init_shorthand)] +#![cfg_attr(stage0,feature(field_init_shorthand))] #![feature(i128_type)] #![feature(libc)] #![feature(loop_break_value)] diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index e3c339829f6a4..906c4b7256fdc 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -24,7 +24,7 @@ #![feature(rand)] #![feature(core_intrinsics)] #![feature(conservative_impl_trait)] -#![feature(field_init_shorthand)] +#![cfg_attr(stage0,feature(field_init_shorthand))] #![feature(pub_restricted)] extern crate graphviz; diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index f19a59a5d38ae..0bcf8ab7d6c20 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -77,7 +77,7 @@ This API is completely unstable and subject to change. #![feature(box_patterns)] #![feature(box_syntax)] #![feature(conservative_impl_trait)] -#![feature(field_init_shorthand)] +#![cfg_attr(stage0,feature(field_init_shorthand))] #![feature(loop_break_value)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index a7c86bf8e06ba..1bed3e2784773 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -288,9 +288,6 @@ declare_features! ( // Allows attributes on lifetime/type formal parameters in generics (RFC 1327) (active, generic_param_attrs, "1.11.0", Some(34761)), - // Allows field shorthands (`x` meaning `x: x`) in struct literal expressions. - (active, field_init_shorthand, "1.14.0", Some(37340)), - // The #![windows_subsystem] attribute (active, windows_subsystem, "1.14.0", Some(37499)), @@ -385,6 +382,8 @@ declare_features! ( (accepted, more_struct_aliases, "1.16.0", Some(37544)), // elide `'static` lifetimes in `static`s and `const`s (accepted, static_in_const, "1.17.0", Some(35897)), + // Allows field shorthands (`x` meaning `x: x`) in struct literal expressions. + (accepted, field_init_shorthand, "1.17.0", Some(37340)), ); // (changing above list without updating src/doc/reference.md makes @cmr sad) @@ -1233,10 +1232,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } ast::ExprKind::Struct(_, ref fields, _) => { for field in fields { - if field.is_shorthand { - gate_feature_post!(&self, field_init_shorthand, field.span, - "struct field shorthands are unstable"); - } if starts_with_digit(&field.ident.node.name.as_str()) { gate_feature_post!(&self, relaxed_adts, field.span, diff --git a/src/test/compile-fail/feature-gate-field-init-shorthand.rs b/src/test/compile-fail/feature-gate-field-init-shorthand.rs deleted file mode 100644 index cd2dae7f461ab..0000000000000 --- a/src/test/compile-fail/feature-gate-field-init-shorthand.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo { - x: i32, - y: bool, - z: i32 -} - -fn main() { - let (x, y, z) = (1, true, 2); - let _ = Foo { - x, //~ ERROR struct field shorthands are unstable - y: y, - z //~ ERROR struct field shorthands are unstable - }; -} diff --git a/src/test/compile-fail/struct-fields-shorthand-unresolved.rs b/src/test/compile-fail/struct-fields-shorthand-unresolved.rs index 02372a3919da5..984f337fb3d14 100644 --- a/src/test/compile-fail/struct-fields-shorthand-unresolved.rs +++ b/src/test/compile-fail/struct-fields-shorthand-unresolved.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(field_init_shorthand)] - struct Foo { x: i32, y: i32 diff --git a/src/test/compile-fail/struct-fields-shorthand.rs b/src/test/compile-fail/struct-fields-shorthand.rs index f764322cadbbb..e46ae73f1a1d4 100644 --- a/src/test/compile-fail/struct-fields-shorthand.rs +++ b/src/test/compile-fail/struct-fields-shorthand.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(field_init_shorthand)] - struct Foo { x: i32, y: i32 diff --git a/src/test/parse-fail/struct-field-numeric-shorthand.rs b/src/test/parse-fail/struct-field-numeric-shorthand.rs index 2a5c25d1868f5..49ba0d8bde625 100644 --- a/src/test/parse-fail/struct-field-numeric-shorthand.rs +++ b/src/test/parse-fail/struct-field-numeric-shorthand.rs @@ -10,8 +10,6 @@ // compile-flags: -Z parse-only -#![feature(field_init_shorthand)] - struct Rgb(u8, u8, u8); fn main() { diff --git a/src/test/run-pass/struct-field-shorthand.rs b/src/test/run-pass/struct-field-shorthand.rs index fe91db572d20e..b61e232200c9a 100644 --- a/src/test/run-pass/struct-field-shorthand.rs +++ b/src/test/run-pass/struct-field-shorthand.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(field_init_shorthand)] - struct Foo { x: i32, y: bool,