Skip to content

Commit f6c729d

Browse files
committed
track_caller: harden naked interactions
1 parent 42abbd8 commit f6c729d

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

src/librustc_passes/check_attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl CheckAttrVisitor<'tcx> {
141141
target: Target,
142142
) -> bool {
143143
match target {
144-
Target::Fn if attr::contains_name(attrs, sym::naked) => {
144+
_ if attr::contains_name(attrs, sym::naked) => {
145145
struct_span_err!(
146146
self.tcx.sess,
147147
*attr_span,
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
#![feature(naked_functions, track_caller)]
22

3-
#[track_caller]
3+
#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
44
#[naked]
55
fn f() {}
6-
//~^^^ ERROR cannot use `#[track_caller]` with `#[naked]`
6+
7+
struct S;
8+
9+
impl S {
10+
#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
11+
#[naked]
12+
fn g() {}
13+
}
14+
15+
extern "Rust" {
16+
#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
17+
#[naked]
18+
fn h();
19+
}
720

821
fn main() {}

src/test/ui/rfc-2091-track-caller/error-with-naked.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ error[E0736]: cannot use `#[track_caller]` with `#[naked]`
44
LL | #[track_caller]
55
| ^^^^^^^^^^^^^^^
66

7-
error: aborting due to previous error
7+
error[E0736]: cannot use `#[track_caller]` with `#[naked]`
8+
--> $DIR/error-with-naked.rs:16:5
9+
|
10+
LL | #[track_caller]
11+
| ^^^^^^^^^^^^^^^
12+
13+
error[E0736]: cannot use `#[track_caller]` with `#[naked]`
14+
--> $DIR/error-with-naked.rs:10:5
15+
|
16+
LL | #[track_caller]
17+
| ^^^^^^^^^^^^^^^
18+
19+
error: aborting due to 3 previous errors
820

921
For more information about this error, try `rustc --explain E0736`.

0 commit comments

Comments
 (0)