Skip to content

Stabilize field init shorthand #39761

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

Merged
merged 1 commit into from
Feb 16, 2017
Merged
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
2 changes: 0 additions & 2 deletions src/doc/book/src/structs.md
Original file line number Diff line number Diff line change
@@ -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,
1 change: 0 additions & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
2 changes: 1 addition & 1 deletion src/librustc_incremental/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
9 changes: 2 additions & 7 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
@@ -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,
24 changes: 0 additions & 24 deletions src/test/compile-fail/feature-gate-field-init-shorthand.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/test/compile-fail/struct-fields-shorthand-unresolved.rs
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions src/test/compile-fail/struct-fields-shorthand.rs
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions src/test/parse-fail/struct-field-numeric-shorthand.rs
Original file line number Diff line number Diff line change
@@ -10,8 +10,6 @@

// compile-flags: -Z parse-only

#![feature(field_init_shorthand)]

struct Rgb(u8, u8, u8);

fn main() {
2 changes: 0 additions & 2 deletions src/test/run-pass/struct-field-shorthand.rs
Original file line number Diff line number Diff line change
@@ -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,