Skip to content

Commit 999f3ad

Browse files
authored
Rollup merge of #42656 - VBChunguk:struct-field-attributes, r=nikomatsakis
Remove struct_field_attributes feature gate Part of #41681. ~This PR only removes the feature gate; this *does not* update any documentations.~ This PR removes the feature gate and the corresponding chapter of the Unstable Book. I'm not very sure about the changes I made though... Just followed the stabilization guideline. r? @nikomatsakis
2 parents f05afa0 + 65288f4 commit 999f3ad

File tree

7 files changed

+3
-67
lines changed

7 files changed

+3
-67
lines changed

src/doc/unstable-book/src/SUMMARY.md

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
- [start](language-features/start.md)
8888
- [static_nobundle](language-features/static-nobundle.md)
8989
- [stmt_expr_attributes](language-features/stmt-expr-attributes.md)
90-
- [struct_field_attributes](language-features/struct-field-attributes.md)
9190
- [structural_match](language-features/structural-match.md)
9291
- [target_feature](language-features/target-feature.md)
9392
- [thread_local](language-features/thread-local.md)

src/doc/unstable-book/src/language-features/struct-field-attributes.md

-10
This file was deleted.

src/librustc_data_structures/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
#![feature(discriminant_value)]
3737
#![feature(specialization)]
3838
#![feature(manually_drop)]
39-
#![feature(struct_field_attributes)]
4039

4140
#![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
4241
#![cfg_attr(stage0, feature(rustc_private))]
4342
#![cfg_attr(stage0, feature(staged_api))]
43+
#![cfg_attr(stage0, feature(struct_field_attributes))]
4444

4545
#![cfg_attr(unix, feature(libc))]
4646
#![cfg_attr(test, feature(test))]

src/libsyntax/config.rs

-28
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ impl<'a> StripUnconfigured<'a> {
223223
ast::ExprKind::Struct(path, fields, base) => {
224224
let fields = fields.into_iter()
225225
.filter_map(|field| {
226-
self.visit_struct_field_attrs(field.attrs());
227226
self.configure(field)
228227
})
229228
.collect();
@@ -256,17 +255,6 @@ impl<'a> StripUnconfigured<'a> {
256255
}
257256

258257
pub fn configure_struct_expr_field(&mut self, field: ast::Field) -> Option<ast::Field> {
259-
if !self.features.map(|features| features.struct_field_attributes).unwrap_or(true) {
260-
if !field.attrs.is_empty() {
261-
let mut err = feature_err(self.sess,
262-
"struct_field_attributes",
263-
field.span,
264-
GateIssue::Language,
265-
"attributes on struct literal fields are unstable");
266-
err.emit();
267-
}
268-
}
269-
270258
self.configure(field)
271259
}
272260

@@ -275,7 +263,6 @@ impl<'a> StripUnconfigured<'a> {
275263
if let ast::PatKind::Struct(path, fields, etc) = pattern.node {
276264
let fields = fields.into_iter()
277265
.filter_map(|field| {
278-
self.visit_struct_field_attrs(field.attrs());
279266
self.configure(field)
280267
})
281268
.collect();
@@ -284,21 +271,6 @@ impl<'a> StripUnconfigured<'a> {
284271
pattern
285272
})
286273
}
287-
288-
fn visit_struct_field_attrs(&mut self, attrs: &[ast::Attribute]) {
289-
// flag the offending attributes
290-
for attr in attrs.iter() {
291-
if !self.features.map(|features| features.struct_field_attributes).unwrap_or(true) {
292-
let mut err = feature_err(
293-
self.sess,
294-
"struct_field_attributes",
295-
attr.span,
296-
GateIssue::Language,
297-
"attributes on struct pattern or literal fields are unstable");
298-
err.emit();
299-
}
300-
}
301-
}
302274
}
303275

304276
impl<'a> fold::Folder for StripUnconfigured<'a> {

src/libsyntax/feature_gate.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,6 @@ declare_features! (
312312
// Declarative macros 2.0 (`macro`).
313313
(active, decl_macro, "1.17.0", Some(39412)),
314314

315-
// Allows attributes on struct literal fields.
316-
(active, struct_field_attributes, "1.16.0", Some(38814)),
317-
318315
// Allows #[link(kind="static-nobundle"...]
319316
(active, static_nobundle, "1.16.0", Some(37403)),
320317

@@ -430,6 +427,8 @@ declare_features! (
430427
(accepted, relaxed_adts, "1.19.0", Some(35626)),
431428
// Coerces non capturing closures to function pointers
432429
(accepted, closure_to_fn_coercion, "1.19.0", Some(39817)),
430+
// Allows attributes on struct literal fields.
431+
(accepted, struct_field_attributes, "1.20.0", Some(38814)),
433432
);
434433

435434
// If you change this, please modify src/doc/unstable-book as well. You must

src/test/compile-fail/struct-field-attr-feature-gate.rs

-22
This file was deleted.

src/test/compile-fail/struct-field-cfg.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(struct_field_attributes)]
12-
1311
struct Foo {
1412
present: (),
1513
}

0 commit comments

Comments
 (0)