Skip to content

Commit 7a028e5

Browse files
authored
Rollup merge of rust-lang#39761 - est31:master, r=aturon
Stabilize field init shorthand Closes rust-lang#37340. ~Still blocked by the documentation issue rust-lang#38830.~ EDIT: seems that all parts required for stabilisation are fixed, so its not blocked.
2 parents 4d6019d + aebd94f commit 7a028e5

File tree

11 files changed

+5
-45
lines changed

11 files changed

+5
-45
lines changed

src/doc/book/src/structs.md

-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ fields of the data structure are initialized with variables of the same
122122
names as the fields.
123123

124124
```
125-
#![feature(field_init_shorthand)]
126-
127125
#[derive(Debug)]
128126
struct Person<'a> {
129127
name: &'a str,

src/doc/reference.md

-1
Original file line numberDiff line numberDiff line change
@@ -2825,7 +2825,6 @@ This allows a compact syntax with less duplication.
28252825
Example:
28262826

28272827
```
2828-
# #![feature(field_init_shorthand)]
28292828
# struct Point3d { x: i32, y: i32, z: i32 }
28302829
# let x = 0;
28312830
# let y_value = 0;

src/librustc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#![feature(conservative_impl_trait)]
3030
#![feature(const_fn)]
3131
#![feature(core_intrinsics)]
32-
#![feature(field_init_shorthand)]
32+
#![cfg_attr(stage0,feature(field_init_shorthand))]
3333
#![feature(i128_type)]
3434
#![feature(libc)]
3535
#![feature(loop_break_value)]

src/librustc_incremental/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#![feature(rand)]
2525
#![feature(core_intrinsics)]
2626
#![feature(conservative_impl_trait)]
27-
#![feature(field_init_shorthand)]
27+
#![cfg_attr(stage0,feature(field_init_shorthand))]
2828
#![feature(pub_restricted)]
2929

3030
extern crate graphviz;

src/librustc_typeck/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ This API is completely unstable and subject to change.
7777
#![feature(box_patterns)]
7878
#![feature(box_syntax)]
7979
#![feature(conservative_impl_trait)]
80-
#![feature(field_init_shorthand)]
80+
#![cfg_attr(stage0,feature(field_init_shorthand))]
8181
#![feature(loop_break_value)]
8282
#![feature(quote)]
8383
#![feature(rustc_diagnostic_macros)]

src/libsyntax/feature_gate.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,6 @@ declare_features! (
288288
// Allows attributes on lifetime/type formal parameters in generics (RFC 1327)
289289
(active, generic_param_attrs, "1.11.0", Some(34761)),
290290

291-
// Allows field shorthands (`x` meaning `x: x`) in struct literal expressions.
292-
(active, field_init_shorthand, "1.14.0", Some(37340)),
293-
294291
// The #![windows_subsystem] attribute
295292
(active, windows_subsystem, "1.14.0", Some(37499)),
296293

@@ -385,6 +382,8 @@ declare_features! (
385382
(accepted, more_struct_aliases, "1.16.0", Some(37544)),
386383
// elide `'static` lifetimes in `static`s and `const`s
387384
(accepted, static_in_const, "1.17.0", Some(35897)),
385+
// Allows field shorthands (`x` meaning `x: x`) in struct literal expressions.
386+
(accepted, field_init_shorthand, "1.17.0", Some(37340)),
388387
);
389388
// (changing above list without updating src/doc/reference.md makes @cmr sad)
390389

@@ -1233,10 +1232,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
12331232
}
12341233
ast::ExprKind::Struct(_, ref fields, _) => {
12351234
for field in fields {
1236-
if field.is_shorthand {
1237-
gate_feature_post!(&self, field_init_shorthand, field.span,
1238-
"struct field shorthands are unstable");
1239-
}
12401235
if starts_with_digit(&field.ident.node.name.as_str()) {
12411236
gate_feature_post!(&self, relaxed_adts,
12421237
field.span,

src/test/compile-fail/feature-gate-field-init-shorthand.rs

-24
This file was deleted.

src/test/compile-fail/struct-fields-shorthand-unresolved.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(field_init_shorthand)]
12-
1311
struct Foo {
1412
x: i32,
1513
y: i32

src/test/compile-fail/struct-fields-shorthand.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(field_init_shorthand)]
12-
1311
struct Foo {
1412
x: i32,
1513
y: i32

src/test/parse-fail/struct-field-numeric-shorthand.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// compile-flags: -Z parse-only
1212

13-
#![feature(field_init_shorthand)]
14-
1513
struct Rgb(u8, u8, u8);
1614

1715
fn main() {

src/test/run-pass/struct-field-shorthand.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(field_init_shorthand)]
12-
1311
struct Foo {
1412
x: i32,
1513
y: bool,

0 commit comments

Comments
 (0)