about summary refs log tree commit diff
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2017-02-12 06:49:15 +0100
committerest31 <MTest31@outlook.com>2017-02-15 07:11:13 +0100
commitaebd94fd3c151212723906fb0445f0153917abac (patch)
treeb1b6539f9641e661575e3c33a587ae532515ba68
parent025c328bf5ab336ff708e62a59292298dc1bc089 (diff)
downloadrust-aebd94fd3c151212723906fb0445f0153917abac.tar.gz
rust-aebd94fd3c151212723906fb0445f0153917abac.zip
Stabilize field init shorthand
Closes #37340.
-rw-r--r--src/doc/book/src/structs.md2
-rw-r--r--src/doc/reference.md1
-rw-r--r--src/librustc/lib.rs2
-rw-r--r--src/librustc_incremental/lib.rs2
-rw-r--r--src/librustc_typeck/lib.rs2
-rw-r--r--src/libsyntax/feature_gate.rs9
-rw-r--r--src/test/compile-fail/feature-gate-field-init-shorthand.rs24
-rw-r--r--src/test/compile-fail/struct-fields-shorthand-unresolved.rs2
-rw-r--r--src/test/compile-fail/struct-fields-shorthand.rs2
-rw-r--r--src/test/parse-fail/struct-field-numeric-shorthand.rs2
-rw-r--r--src/test/run-pass/struct-field-shorthand.rs2
11 files changed, 5 insertions, 45 deletions
diff --git a/src/doc/book/src/structs.md b/src/doc/book/src/structs.md
index 51af343c130..6423147e66e 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 7155641e2c2..f2be20d4a75 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 5c0ec8de7ec..d144f7575a2 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 e3c339829f6..906c4b7256f 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 f19a59a5d38..0bcf8ab7d6c 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 a7c86bf8e06..1bed3e27847 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 cd2dae7f461..00000000000
--- 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 <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.
-
-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 02372a3919d..984f337fb3d 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 f764322cadb..e46ae73f1a1 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 2a5c25d1868..49ba0d8bde6 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 fe91db572d2..b61e232200c 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,