Skip to content

Commit a781160

Browse files
nrcbrson
authored andcommitted
Stabilise attributes on statements.
Note that attributes on expressions are still unstable and are behind the `stmt_expr_attributes` flag. cc [Tracking issue](#15701)
1 parent 8dc1c24 commit a781160

File tree

10 files changed

+12
-22
lines changed

10 files changed

+12
-22
lines changed

src/doc/reference.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,8 +2472,7 @@ The currently implemented features of the reference compiler are:
24722472
* - `default_type_parameter_fallback` - Allows type parameter defaults to
24732473
influence type inference.
24742474

2475-
* - `stmt_expr_attributes` - Allows attributes on expressions and
2476-
non-item statements.
2475+
* - `stmt_expr_attributes` - Allows attributes on expressions.
24772476

24782477
* - `type_ascription` - Allows type ascription expressions `expr: Type`.
24792478

src/libsyntax/config.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<'a> StripUnconfigured<'a> {
153153
}
154154

155155
// Visit attributes on expression and statements (but not attributes on items in blocks).
156-
fn visit_stmt_or_expr_attrs(&mut self, attrs: &[ast::Attribute]) {
156+
fn visit_expr_attrs(&mut self, attrs: &[ast::Attribute]) {
157157
// flag the offending attributes
158158
for attr in attrs.iter() {
159159
if !self.features.map(|features| features.stmt_expr_attributes).unwrap_or(true) {
@@ -227,7 +227,7 @@ impl<'a> StripUnconfigured<'a> {
227227
}
228228

229229
pub fn configure_expr(&mut self, expr: P<ast::Expr>) -> P<ast::Expr> {
230-
self.visit_stmt_or_expr_attrs(expr.attrs());
230+
self.visit_expr_attrs(expr.attrs());
231231

232232
// If an expr is valid to cfg away it will have been removed by the
233233
// outer stmt or expression folder before descending in here.
@@ -245,7 +245,6 @@ impl<'a> StripUnconfigured<'a> {
245245
}
246246

247247
pub fn configure_stmt(&mut self, stmt: ast::Stmt) -> Option<ast::Stmt> {
248-
self.visit_stmt_or_expr_attrs(stmt.attrs());
249248
self.configure(stmt)
250249
}
251250
}

src/test/compile-fail/mir-dataflow/def-inits-1.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// General test of maybe_uninits state computed by MIR dataflow.
1212

1313
#![feature(rustc_attrs)]
14-
#![feature(stmt_expr_attributes)]
1514

1615
use std::intrinsics::rustc_peek;
1716
use std::mem::{drop, replace};

src/test/compile-fail/mir-dataflow/inits-1.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// General test of maybe_inits state computed by MIR dataflow.
1212

1313
#![feature(rustc_attrs)]
14-
#![feature(stmt_expr_attributes)]
1514

1615
use std::intrinsics::rustc_peek;
1716
use std::mem::{drop, replace};

src/test/compile-fail/mir-dataflow/uninits-1.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// General test of maybe_uninits state computed by MIR dataflow.
1212

1313
#![feature(rustc_attrs)]
14-
#![feature(stmt_expr_attributes)]
1514

1615
use std::intrinsics::rustc_peek;
1716
use std::mem::{drop, replace};

src/test/compile-fail/mir-dataflow/uninits-2.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// General test of maybe_uninits state computed by MIR dataflow.
1212

1313
#![feature(rustc_attrs)]
14-
#![feature(stmt_expr_attributes)]
1514

1615
use std::intrinsics::rustc_peek;
1716
use std::mem::{drop, replace};

src/test/compile-fail/stmt_expr_attrs_no_feature.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ fn main() {
2121
#[attr]
2222
fn a() {}
2323

24-
#[attr] //~ ERROR 15701
24+
#[attr]
2525
{
2626

2727
}
2828

29-
#[attr] //~ ERROR 15701
29+
#[attr]
3030
5;
3131

32-
#[attr] //~ ERROR 15701
32+
#[attr]
3333
stmt_mac!();
3434
}
3535

@@ -43,7 +43,7 @@ fn c() {
4343

4444
#[cfg(not(unset))]
4545
fn j() {
46-
#[attr] //~ ERROR 15701
46+
#[attr]
4747
5;
4848
}
4949

@@ -55,7 +55,7 @@ fn d() {
5555

5656
#[cfg_attr(not(unset), cfg(not(unset)))]
5757
fn i() {
58-
#[attr] //~ ERROR 15701
58+
#[attr]
5959
8;
6060
}
6161

@@ -64,7 +64,7 @@ fn i() {
6464
macro_rules! item_mac {
6565
($e:ident) => {
6666
fn $e() {
67-
#[attr] //~ ERROR 15701
67+
#[attr]
6868
42;
6969

7070
#[cfg(unset)]
@@ -75,7 +75,7 @@ macro_rules! item_mac {
7575

7676
#[cfg(not(unset))]
7777
fn k() {
78-
#[attr] //~ ERROR 15701
78+
#[attr]
7979
5;
8080
}
8181

@@ -87,7 +87,7 @@ macro_rules! item_mac {
8787

8888
#[cfg_attr(not(unset), cfg(not(unset)))]
8989
fn h() {
90-
#[attr] //~ ERROR 15701
90+
#[attr]
9191
8;
9292
}
9393

src/test/run-pass/const-negation.rs

Lines changed: 0 additions & 2 deletions
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(stmt_expr_attributes)]
12-
1311
#[deny(const_err)]
1412

1513
fn main() {

src/test/run-pass/enum-discrim-autosizing.rs

Lines changed: 0 additions & 2 deletions
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(stmt_expr_attributes)]
12-
1311
use std::mem::size_of;
1412

1513
enum Ei8 {

src/test/run-pass/issue-8460.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// ignore-emscripten no threads support
1212
// ignore-pretty : (#23623) problems when ending with // comments
1313

14-
#![feature(rustc_attrs, stmt_expr_attributes, zero_one)]
14+
#![feature(rustc_attrs, zero_one)]
1515

1616
use std::num::Zero;
1717
use std::thread;

0 commit comments

Comments
 (0)