Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
track_caller: harden naked interactions
  • Loading branch information
Centril committed Apr 8, 2020
1 parent 42abbd8 commit f6c729d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/librustc_passes/check_attr.rs
Expand Up @@ -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,
Expand Down
17 changes: 15 additions & 2 deletions src/test/ui/rfc-2091-track-caller/error-with-naked.rs
@@ -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() {}
14 changes: 13 additions & 1 deletion src/test/ui/rfc-2091-track-caller/error-with-naked.stderr
Expand Up @@ -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`.

0 comments on commit f6c729d

Please sign in to comment.