1
Fork 0

Extend UI tests for fixed check_attr()

Add testcases for the `#[track_caller]` and `#[target_feature(..)]`
function attributes for errors that were not not caught before.
This commit is contained in:
Matthias Schiffer 2020-04-16 17:11:05 +02:00
parent 9a2bca6a52
commit 6c700dc11c
No known key found for this signature in database
GPG key ID: 16EF3F64CB201D9C
4 changed files with 49 additions and 2 deletions

View file

@ -4,4 +4,10 @@
extern "C" fn f() {}
//~^^ ERROR `#[track_caller]` requires Rust ABI
extern "C" {
#[track_caller]
fn g();
//~^^ ERROR `#[track_caller]` requires Rust ABI
}
fn main() {}

View file

@ -4,6 +4,12 @@ error[E0737]: `#[track_caller]` requires Rust ABI
LL | #[track_caller]
| ^^^^^^^^^^^^^^^
error: aborting due to previous error
error[E0737]: `#[track_caller]` requires Rust ABI
--> $DIR/error-with-invalid-abi.rs:8:5
|
LL | #[track_caller]
| ^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0737`.

View file

@ -65,9 +65,26 @@ trait Baz { }
#[target_feature(enable = "sse2")]
unsafe fn test() {}
trait Quux {
fn foo();
}
impl Quux for Foo {
#[target_feature(enable = "sse2")]
//~^ ERROR `#[target_feature(..)]` can only be applied to `unsafe` functions
//~| NOTE can only be applied to `unsafe` functions
fn foo() {}
//~^ NOTE not an `unsafe` function
}
fn main() {
unsafe {
foo();
bar();
}
#[target_feature(enable = "sse2")]
//~^ ERROR `#[target_feature(..)]` can only be applied to `unsafe` functions
//~| NOTE can only be applied to `unsafe` functions
|| {};
//~^ NOTE not an `unsafe` function
}

View file

@ -91,5 +91,23 @@ error: cannot use `#[inline(always)]` with `#[target_feature]`
LL | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
error: aborting due to 12 previous errors
error: `#[target_feature(..)]` can only be applied to `unsafe` functions
--> $DIR/invalid-attribute.rs:85:5
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can only be applied to `unsafe` functions
...
LL | || {};
| ----- not an `unsafe` function
error: `#[target_feature(..)]` can only be applied to `unsafe` functions
--> $DIR/invalid-attribute.rs:73:5
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can only be applied to `unsafe` functions
...
LL | fn foo() {}
| ----------- not an `unsafe` function
error: aborting due to 14 previous errors