track_caller: harden naked interactions

This commit is contained in:
Mazdak Farrokhzad 2020-04-08 03:49:53 +02:00
parent 42abbd8878
commit f6c729d4a0
3 changed files with 29 additions and 4 deletions

View file

@ -141,7 +141,7 @@ impl CheckAttrVisitor<'tcx> {
target: Target,
) -> bool {
match target {
Target::Fn if attr::contains_name(attrs, sym::naked) => {
_ if attr::contains_name(attrs, sym::naked) => {
struct_span_err!(
self.tcx.sess,
*attr_span,

View file

@ -1,8 +1,21 @@
#![feature(naked_functions, track_caller)]
#[track_caller]
#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
#[naked]
fn f() {}
//~^^^ ERROR cannot use `#[track_caller]` with `#[naked]`
struct S;
impl S {
#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
#[naked]
fn g() {}
}
extern "Rust" {
#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
#[naked]
fn h();
}
fn main() {}

View file

@ -4,6 +4,18 @@ error[E0736]: cannot use `#[track_caller]` with `#[naked]`
LL | #[track_caller]
| ^^^^^^^^^^^^^^^
error: aborting due to previous error
error[E0736]: cannot use `#[track_caller]` with `#[naked]`
--> $DIR/error-with-naked.rs:16:5
|
LL | #[track_caller]
| ^^^^^^^^^^^^^^^
error[E0736]: cannot use `#[track_caller]` with `#[naked]`
--> $DIR/error-with-naked.rs:10:5
|
LL | #[track_caller]
| ^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0736`.