mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 19:17:43 +00:00
parent
025c328bf5
commit
aebd94fd3c
@ -122,8 +122,6 @@ fields of the data structure are initialized with variables of the same
|
|||||||
names as the fields.
|
names as the fields.
|
||||||
|
|
||||||
```
|
```
|
||||||
#![feature(field_init_shorthand)]
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Person<'a> {
|
struct Person<'a> {
|
||||||
name: &'a str,
|
name: &'a str,
|
||||||
|
@ -2825,7 +2825,6 @@ This allows a compact syntax with less duplication.
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
```
|
```
|
||||||
# #![feature(field_init_shorthand)]
|
|
||||||
# struct Point3d { x: i32, y: i32, z: i32 }
|
# struct Point3d { x: i32, y: i32, z: i32 }
|
||||||
# let x = 0;
|
# let x = 0;
|
||||||
# let y_value = 0;
|
# let y_value = 0;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#![feature(conservative_impl_trait)]
|
#![feature(conservative_impl_trait)]
|
||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
#![feature(core_intrinsics)]
|
#![feature(core_intrinsics)]
|
||||||
#![feature(field_init_shorthand)]
|
#![cfg_attr(stage0,feature(field_init_shorthand))]
|
||||||
#![feature(i128_type)]
|
#![feature(i128_type)]
|
||||||
#![feature(libc)]
|
#![feature(libc)]
|
||||||
#![feature(loop_break_value)]
|
#![feature(loop_break_value)]
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#![feature(rand)]
|
#![feature(rand)]
|
||||||
#![feature(core_intrinsics)]
|
#![feature(core_intrinsics)]
|
||||||
#![feature(conservative_impl_trait)]
|
#![feature(conservative_impl_trait)]
|
||||||
#![feature(field_init_shorthand)]
|
#![cfg_attr(stage0,feature(field_init_shorthand))]
|
||||||
#![feature(pub_restricted)]
|
#![feature(pub_restricted)]
|
||||||
|
|
||||||
extern crate graphviz;
|
extern crate graphviz;
|
||||||
|
@ -77,7 +77,7 @@ This API is completely unstable and subject to change.
|
|||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
#![feature(conservative_impl_trait)]
|
#![feature(conservative_impl_trait)]
|
||||||
#![feature(field_init_shorthand)]
|
#![cfg_attr(stage0,feature(field_init_shorthand))]
|
||||||
#![feature(loop_break_value)]
|
#![feature(loop_break_value)]
|
||||||
#![feature(quote)]
|
#![feature(quote)]
|
||||||
#![feature(rustc_diagnostic_macros)]
|
#![feature(rustc_diagnostic_macros)]
|
||||||
|
@ -288,9 +288,6 @@ declare_features! (
|
|||||||
// Allows attributes on lifetime/type formal parameters in generics (RFC 1327)
|
// Allows attributes on lifetime/type formal parameters in generics (RFC 1327)
|
||||||
(active, generic_param_attrs, "1.11.0", Some(34761)),
|
(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
|
// The #![windows_subsystem] attribute
|
||||||
(active, windows_subsystem, "1.14.0", Some(37499)),
|
(active, windows_subsystem, "1.14.0", Some(37499)),
|
||||||
|
|
||||||
@ -385,6 +382,8 @@ declare_features! (
|
|||||||
(accepted, more_struct_aliases, "1.16.0", Some(37544)),
|
(accepted, more_struct_aliases, "1.16.0", Some(37544)),
|
||||||
// elide `'static` lifetimes in `static`s and `const`s
|
// elide `'static` lifetimes in `static`s and `const`s
|
||||||
(accepted, static_in_const, "1.17.0", Some(35897)),
|
(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)
|
// (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, _) => {
|
ast::ExprKind::Struct(_, ref fields, _) => {
|
||||||
for field in 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()) {
|
if starts_with_digit(&field.ident.node.name.as_str()) {
|
||||||
gate_feature_post!(&self, relaxed_adts,
|
gate_feature_post!(&self, relaxed_adts,
|
||||||
field.span,
|
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
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(field_init_shorthand)]
|
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
x: i32,
|
x: i32,
|
||||||
y: i32
|
y: i32
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(field_init_shorthand)]
|
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
x: i32,
|
x: i32,
|
||||||
y: i32
|
y: i32
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
// compile-flags: -Z parse-only
|
// compile-flags: -Z parse-only
|
||||||
|
|
||||||
#![feature(field_init_shorthand)]
|
|
||||||
|
|
||||||
struct Rgb(u8, u8, u8);
|
struct Rgb(u8, u8, u8);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(field_init_shorthand)]
|
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
x: i32,
|
x: i32,
|
||||||
y: bool,
|
y: bool,
|
||||||
|
Loading…
Reference in New Issue
Block a user