Stabilise attributes on statements.
Note that attributes on expressions are still unstable and are behind the `stmt_expr_attributes` flag. cc [Tracking issue](https://github.com/rust-lang/rust/issues/15701)
This commit is contained in:
parent
9bc6d26092
commit
a94f5934cd
@ -2472,8 +2472,7 @@ The currently implemented features of the reference compiler are:
|
||||
* - `default_type_parameter_fallback` - Allows type parameter defaults to
|
||||
influence type inference.
|
||||
|
||||
* - `stmt_expr_attributes` - Allows attributes on expressions and
|
||||
non-item statements.
|
||||
* - `stmt_expr_attributes` - Allows attributes on expressions.
|
||||
|
||||
* - `type_ascription` - Allows type ascription expressions `expr: Type`.
|
||||
|
||||
|
@ -153,7 +153,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||
}
|
||||
|
||||
// Visit attributes on expression and statements (but not attributes on items in blocks).
|
||||
fn visit_stmt_or_expr_attrs(&mut self, attrs: &[ast::Attribute]) {
|
||||
fn visit_expr_attrs(&mut self, attrs: &[ast::Attribute]) {
|
||||
// flag the offending attributes
|
||||
for attr in attrs.iter() {
|
||||
if !self.features.map(|features| features.stmt_expr_attributes).unwrap_or(true) {
|
||||
@ -227,7 +227,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||
}
|
||||
|
||||
pub fn configure_expr(&mut self, expr: P<ast::Expr>) -> P<ast::Expr> {
|
||||
self.visit_stmt_or_expr_attrs(expr.attrs());
|
||||
self.visit_expr_attrs(expr.attrs());
|
||||
|
||||
// If an expr is valid to cfg away it will have been removed by the
|
||||
// outer stmt or expression folder before descending in here.
|
||||
@ -245,7 +245,6 @@ impl<'a> StripUnconfigured<'a> {
|
||||
}
|
||||
|
||||
pub fn configure_stmt(&mut self, stmt: ast::Stmt) -> Option<ast::Stmt> {
|
||||
self.visit_stmt_or_expr_attrs(stmt.attrs());
|
||||
self.configure(stmt)
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
// General test of maybe_uninits state computed by MIR dataflow.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
use std::intrinsics::rustc_peek;
|
||||
use std::mem::{drop, replace};
|
||||
|
@ -11,7 +11,6 @@
|
||||
// General test of maybe_inits state computed by MIR dataflow.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
use std::intrinsics::rustc_peek;
|
||||
use std::mem::{drop, replace};
|
||||
|
@ -11,7 +11,6 @@
|
||||
// General test of maybe_uninits state computed by MIR dataflow.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
use std::intrinsics::rustc_peek;
|
||||
use std::mem::{drop, replace};
|
||||
|
@ -11,7 +11,6 @@
|
||||
// General test of maybe_uninits state computed by MIR dataflow.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
use std::intrinsics::rustc_peek;
|
||||
use std::mem::{drop, replace};
|
||||
|
@ -21,15 +21,15 @@ fn main() {
|
||||
#[attr]
|
||||
fn a() {}
|
||||
|
||||
#[attr] //~ ERROR 15701
|
||||
#[attr]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#[attr] //~ ERROR 15701
|
||||
#[attr]
|
||||
5;
|
||||
|
||||
#[attr] //~ ERROR 15701
|
||||
#[attr]
|
||||
stmt_mac!();
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ fn c() {
|
||||
|
||||
#[cfg(not(unset))]
|
||||
fn j() {
|
||||
#[attr] //~ ERROR 15701
|
||||
#[attr]
|
||||
5;
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ fn d() {
|
||||
|
||||
#[cfg_attr(not(unset), cfg(not(unset)))]
|
||||
fn i() {
|
||||
#[attr] //~ ERROR 15701
|
||||
#[attr]
|
||||
8;
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ fn i() {
|
||||
macro_rules! item_mac {
|
||||
($e:ident) => {
|
||||
fn $e() {
|
||||
#[attr] //~ ERROR 15701
|
||||
#[attr]
|
||||
42;
|
||||
|
||||
#[cfg(unset)]
|
||||
@ -75,7 +75,7 @@ macro_rules! item_mac {
|
||||
|
||||
#[cfg(not(unset))]
|
||||
fn k() {
|
||||
#[attr] //~ ERROR 15701
|
||||
#[attr]
|
||||
5;
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ macro_rules! item_mac {
|
||||
|
||||
#[cfg_attr(not(unset), cfg(not(unset)))]
|
||||
fn h() {
|
||||
#[attr] //~ ERROR 15701
|
||||
#[attr]
|
||||
8;
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
#[deny(const_err)]
|
||||
|
||||
fn main() {
|
||||
|
@ -8,8 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
use std::mem::size_of;
|
||||
|
||||
enum Ei8 {
|
||||
|
@ -11,7 +11,7 @@
|
||||
// ignore-emscripten no threads support
|
||||
// ignore-pretty : (#23623) problems when ending with // comments
|
||||
|
||||
#![feature(rustc_attrs, stmt_expr_attributes, zero_one)]
|
||||
#![feature(rustc_attrs, zero_one)]
|
||||
|
||||
use std::num::Zero;
|
||||
use std::thread;
|
||||
|
Loading…
x
Reference in New Issue
Block a user