]> git.lizzy.rs Git - rust.git/commitdiff
track_caller: harden naked interactions
authorMazdak Farrokhzad <twingoow@gmail.com>
Wed, 8 Apr 2020 01:49:53 +0000 (03:49 +0200)
committerMazdak Farrokhzad <twingoow@gmail.com>
Wed, 8 Apr 2020 01:49:53 +0000 (03:49 +0200)
src/librustc_passes/check_attr.rs
src/test/ui/rfc-2091-track-caller/error-with-naked.rs
src/test/ui/rfc-2091-track-caller/error-with-naked.stderr

index 619a8c6f229b3b7f1202ea346b22584a30eb0607..376ff1108d63859fc4d85244718c5f15dd2c31dd 100644 (file)
@@ -141,7 +141,7 @@ fn check_track_caller(
         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,
index dd9e5d04135851cd4f1fe97c6ed828cae38b11b8..f45738483333599caa3ec2e98354933dfde62561 100644 (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() {}
index 2f5003cfdb7a57aab2466517101303f8398d4308..1249d1df07179cbc655ec28fd566acb6b3b1ba2a 100644 (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`.