Add context to E0084, E00517, E0518

Show both the attribute and the item
This commit is contained in:
Michael Lamparski 2017-11-13 20:13:26 -05:00
parent 24840dab0b
commit dcbedf78a0
8 changed files with 49 additions and 42 deletions

View file

@ -8,10 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[repr(i32)]
enum Foo {}
//~^ ERROR E0084
//~| unsupported enum representation
#[repr(i32)] //~ ERROR E0084
enum Foo {} //~ zero-variant enum
fn main() {
}

View file

@ -9,20 +9,16 @@
// except according to those terms.
#[repr(C)] //~ ERROR E0517
//~| requires a struct, enum or union
type Foo = u8;
type Foo = u8; //~ not a struct, enum or union
#[repr(packed)] //~ ERROR E0517
//~| requires a struct
enum Foo2 {Bar, Baz}
enum Foo2 {Bar, Baz} //~ not a struct
#[repr(u8)] //~ ERROR E0517
//~| requires an enum
struct Foo3 {bar: bool, baz: bool}
struct Foo3 {bar: bool, baz: bool} //~ not an enum
#[repr(C)] //~ ERROR E0517
//~| requires a struct, enum or union
impl Foo3 {
impl Foo3 { //~ not a struct, enum or union
}
fn main() {

View file

@ -9,12 +9,10 @@
// except according to those terms.
#[inline(always)] //~ ERROR E0518
//~| requires a function
struct Foo;
struct Foo; //~ not a function
#[inline(never)] //~ ERROR E0518
//~| requires a function
impl Foo {
impl Foo { //~ not a function
}
fn main() {

View file

@ -14,6 +14,6 @@
fn f() {}
#[inline] //~ ERROR: attribute should be applied to function
struct S;
struct S; //~ not a function
fn main() {}

View file

@ -13,7 +13,7 @@
#![feature(repr_simd)]
#[repr(C)] //~ ERROR: attribute should be applied to struct, enum or union
fn f() {}
fn f() {} //~ not a struct, enum or union
#[repr(C)]
struct SExtern(f64, f64);
@ -25,19 +25,19 @@ struct SPacked(f64, f64);
struct SSimd(f64, f64);
#[repr(i8)] //~ ERROR: attribute should be applied to enum
struct SInt(f64, f64);
struct SInt(f64, f64); //~ not an enum
#[repr(C)]
enum EExtern { A, B }
#[repr(align(8))] //~ ERROR: attribute should be applied to struct
enum EAlign { A, B }
enum EAlign { A, B } // not a struct
#[repr(packed)] //~ ERROR: attribute should be applied to struct
enum EPacked { A, B }
enum EPacked { A, B } // not a struct
#[repr(simd)] //~ ERROR: attribute should be applied to struct
enum ESimd { A, B }
enum ESimd { A, B } // not a struct
#[repr(i8)]
enum EInt { A, B }

View file

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