Auto merge of #39761 - est31:master, r=aturon
Stabilize field init shorthand Closes #37340. ~Still blocked by the documentation issue #38830.~ EDIT: seems that all parts required for stabilisation are fixed, so its not blocked.
This commit is contained in:
commit
1b6f1fe9dd
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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)]
|
||||
|
@ -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;
|
||||
|
@ -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)]
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
};
|
||||
}
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -10,8 +10,6 @@
|
||||
|
||||
// compile-flags: -Z parse-only
|
||||
|
||||
#![feature(field_init_shorthand)]
|
||||
|
||||
struct Rgb(u8, u8, u8);
|
||||
|
||||
fn main() {
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user