diff --git a/src/doc/book/src/structs.md b/src/doc/book/src/structs.md index 51af343c130123b4a8fda6887f6353bf02e17826..6423147e66e094986dc09f15546daab1d4dbe64b 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 7155641e2c28a790ca06f788889137f163e6839e..f2be20d4a75168818d565830334f23cbae43df5e 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 5c0ec8de7ecd266d8eeb9b4469baa0be127cc1d8..d144f7575a2e2dfa4e7d36d0a224c9f417084cf9 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 e3c339829f6a4f64cf0de3557601fe0682fd66ed..906c4b7256fdc56c45e35e77502918681f5918aa 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 f19a59a5d38aeb56e33733149ee59ce6c1347447..0bcf8ab7d6c2092079a822943aaa66222b20a895 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -77,7 +77,7 @@ #![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 a7c86bf8e06bae014aa2b2c8ed08c2ffe10e6e79..1bed3e2784773906d3730e3ad0b1cf3b074fa081 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -288,9 +288,6 @@ pub fn new() -> 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 @@ pub fn new() -> 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 @@ fn visit_expr(&mut self, e: &'a ast::Expr) { } 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 cd2dae7f461abe608babd25ee7eb42e4a0cfb712..0000000000000000000000000000000000000000 --- 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 02372a3919da553727c406bc4341520391dc9cf4..984f337fb3d14e5251ec135757bff4f065e7978a 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 f764322cadbbb380338ff28876007cef0c5e32ed..e46ae73f1a1d4740faad26754ea23ccd259b17bc 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 2a5c25d1868f5309926cf671d6b74c9fd03704c6..49ba0d8bde62524f5dcfdc6a246613c2339a202e 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 fe91db572d20ea66af8b0a870b47df279b41a8f9..b61e232200c9af3db7726f32a71018552c684da0 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,