Allow #[inline] on closures

Fixes #49632
This commit is contained in:
Amanieu d'Antras 2018-04-27 07:20:46 +02:00
parent 9822b5709c
commit 5f2c111165
8 changed files with 54 additions and 32 deletions

View file

@ -13,7 +13,7 @@
#[inline]
fn f() {}
#[inline] //~ ERROR: attribute should be applied to function
#[inline] //~ ERROR: attribute should be applied to function or closure
struct S;
fn main() {}

View file

@ -9,6 +9,6 @@
// except according to those terms.
fn main() {
#[inline] struct Foo; //~ ERROR attribute should be applied to function
#[inline] struct Foo; //~ ERROR attribute should be applied to function or closure
#[repr(C)] fn foo() {} //~ ERROR attribute should be applied to struct, enum or union
}

View file

@ -14,12 +14,12 @@ fn main() {
#[inline]
let _a = 4;
//~^^ ERROR attribute should be applied to function
//~^^ ERROR attribute should be applied to function or closure
#[inline(XYZ)]
let _b = 4;
//~^^ ERROR attribute should be applied to function
//~^^ ERROR attribute should be applied to function or closure
#[repr(nothing)]
let _x = 0;
@ -40,7 +40,7 @@ fn main() {
#[inline(ABC)]
foo();
//~^^ ERROR attribute should be applied to function
//~^^ ERROR attribute should be applied to function or closure
let _z = #[repr] 1;
//~^ ERROR attribute should not be applied to an expression

View file

@ -0,0 +1,17 @@
// Copyright 2018 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.
#![feature(stmt_expr_attributes)]
pub fn main() {
let _x = #[inline(always)] || {};
let _y = #[inline(never)] || {};
let _z = #[inline] || {};
}

View file

@ -1,19 +1,19 @@
error[E0518]: attribute should be applied to function
error[E0518]: attribute should be applied to function or closure
--> $DIR/E0518.rs:11:1
|
LL | #[inline(always)] //~ ERROR: E0518
| ^^^^^^^^^^^^^^^^^
LL | struct Foo;
| ----------- not a function
| ----------- not a function or closure
error[E0518]: attribute should be applied to function
error[E0518]: attribute should be applied to function or closure
--> $DIR/E0518.rs:14:1
|
LL | #[inline(never)] //~ ERROR: E0518
| ^^^^^^^^^^^^^^^^
LL | / impl Foo {
LL | | }
| |_- not a function
| |_- not a function or closure
error: aborting due to 2 previous errors

View file

@ -19,21 +19,21 @@
#![inline = "2100"]
#[inline = "2100"]
//~^ ERROR attribute should be applied to function
//~^ ERROR attribute should be applied to function or closure
mod inline {
mod inner { #![inline="2100"] }
//~^ ERROR attribute should be applied to function
//~^ ERROR attribute should be applied to function or closure
#[inline = "2100"] fn f() { }
#[inline = "2100"] struct S;
//~^ ERROR attribute should be applied to function
//~^ ERROR attribute should be applied to function or closure
#[inline = "2100"] type T = S;
//~^ ERROR attribute should be applied to function
//~^ ERROR attribute should be applied to function or closure
#[inline = "2100"] impl S { }
//~^ ERROR attribute should be applied to function
//~^ ERROR attribute should be applied to function or closure
}
fn main() {}

View file

@ -1,41 +1,41 @@
error[E0518]: attribute should be applied to function
error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43106-gating-of-inline.rs:21:1
|
LL | #[inline = "2100"]
| ^^^^^^^^^^^^^^^^^^
LL | //~^ ERROR attribute should be applied to function
LL | //~^ ERROR attribute should be applied to function or closure
LL | / mod inline {
LL | | mod inner { #![inline="2100"] }
LL | | //~^ ERROR attribute should be applied to function
LL | | //~^ ERROR attribute should be applied to function or closure
LL | |
... |
LL | | //~^ ERROR attribute should be applied to function
LL | | //~^ ERROR attribute should be applied to function or closure
LL | | }
| |_- not a function
| |_- not a function or closure
error[E0518]: attribute should be applied to function
error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43106-gating-of-inline.rs:24:17
|
LL | mod inner { #![inline="2100"] }
| ------------^^^^^^^^^^^^^^^^^-- not a function
| ------------^^^^^^^^^^^^^^^^^-- not a function or closure
error[E0518]: attribute should be applied to function
error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43106-gating-of-inline.rs:29:5
|
LL | #[inline = "2100"] struct S;
| ^^^^^^^^^^^^^^^^^^ --------- not a function
| ^^^^^^^^^^^^^^^^^^ --------- not a function or closure
error[E0518]: attribute should be applied to function
error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43106-gating-of-inline.rs:32:5
|
LL | #[inline = "2100"] type T = S;
| ^^^^^^^^^^^^^^^^^^ ----------- not a function
| ^^^^^^^^^^^^^^^^^^ ----------- not a function or closure
error[E0518]: attribute should be applied to function
error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43106-gating-of-inline.rs:35:5
|
LL | #[inline = "2100"] impl S { }
| ^^^^^^^^^^^^^^^^^^ ---------- not a function
| ^^^^^^^^^^^^^^^^^^ ---------- not a function or closure
error: aborting due to 5 previous errors