about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-28 09:18:53 +0000
committerbors <bors@rust-lang.org>2024-07-28 09:18:53 +0000
commit3954398882707ce3f683722795d1a7111312b5d9 (patch)
tree6d45276077db571a573ec0bb3aed963523decf45 /compiler/rustc_builtin_macros/src
parent0bb6fec1c9aa484a7ec987a9e8ffca2eb647b0b3 (diff)
parentb801fab0034cd81072825a55213ab76c62e4857e (diff)
downloadrust-3954398882707ce3f683722795d1a7111312b5d9.tar.gz
rust-3954398882707ce3f683722795d1a7111312b5d9.zip
Auto merge of #128298 - matthiaskrgr:rollup-0wdu2wo, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #127853 (`#[naked]`: report incompatible attributes)
 - #128276 (Add a README to rustbook to explain its purpose)
 - #128279 (Stabilize `is_sorted`)
 - #128282 (bitwise and bytewise methods on `NonZero`)
 - #128285 (rustc book: document how the RUST_TARGET_PATH variable is used)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_builtin_macros/src')
-rw-r--r--compiler/rustc_builtin_macros/src/errors.rs10
-rw-r--r--compiler/rustc_builtin_macros/src/test.rs8
2 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs
index 2e6bdae14a8..f17819474ad 100644
--- a/compiler/rustc_builtin_macros/src/errors.rs
+++ b/compiler/rustc_builtin_macros/src/errors.rs
@@ -923,3 +923,13 @@ pub(crate) struct ExpectedItem<'a> {
     pub span: Span,
     pub token: &'a str,
 }
+
+#[derive(Diagnostic)]
+#[diag(builtin_macros_naked_functions_testing_attribute, code = E0736)]
+pub struct NakedFunctionTestingAttribute {
+    #[primary_span]
+    #[label(builtin_macros_naked_attribute)]
+    pub naked_span: Span,
+    #[label]
+    pub testing_span: Span,
+}
diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs
index c0310a2f4b0..bb00c8de1b8 100644
--- a/compiler/rustc_builtin_macros/src/test.rs
+++ b/compiler/rustc_builtin_macros/src/test.rs
@@ -133,6 +133,14 @@ pub(crate) fn expand_test_or_bench(
         };
     };
 
+    if let Some(attr) = attr::find_by_name(&item.attrs, sym::naked) {
+        cx.dcx().emit_err(errors::NakedFunctionTestingAttribute {
+            testing_span: attr_sp,
+            naked_span: attr.span,
+        });
+        return vec![Annotatable::Item(item)];
+    }
+
     // check_*_signature will report any errors in the type so compilation
     // will fail. We shouldn't try to expand in this case because the errors
     // would be spurious.