about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-08-07 14:01:43 +0000
committerbors <bors@rust-lang.org>2025-08-07 14:01:43 +0000
commit321a89bec57b8ca723d1af8f784490b950458c6a (patch)
tree8a0137b29007700853d5d19739718beda89a42be /compiler/rustc_builtin_macros/src
parentcd434309efcf5dc68b253e5ef6ba40c1c43711c9 (diff)
parentbd8e7fdc543880073dcfc0fce9096b188f915f9a (diff)
downloadrust-321a89bec57b8ca723d1af8f784490b950458c6a.tar.gz
rust-321a89bec57b8ca723d1af8f784490b950458c6a.zip
Auto merge of #145043 - Zalathar:rollup-3dbvdrm, r=Zalathar
Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#137831 (Tweak auto trait errors)
 - rust-lang/rust#138689 (add nvptx_target_feature)
 - rust-lang/rust#140267 (implement continue_ok and break_ok for ControlFlow)
 - rust-lang/rust#143028 (emit `StorageLive` and schedule `StorageDead` for `let`-`else`'s bindings after matching)
 - rust-lang/rust#143764 (lower pattern bindings in the order they're written and base drop order on primary bindings' order)
 - rust-lang/rust#143808 (Port `#[should_panic]` to the new attribute parsing infrastructure )
 - rust-lang/rust#143906 (Miri: non-deterministic floating point operations in `foreign_items`)
 - rust-lang/rust#143929 (Mark all deprecation lints in name resolution as deny-by-default and report-in-deps)
 - rust-lang/rust#144133 (Stabilize const TypeId::of)
 - rust-lang/rust#144369 (Upgrade semicolon_in_expressions_from_macros from warn to deny)
 - rust-lang/rust#144439 (Introduce ModernIdent type to unify macro 2.0 hygiene handling)
 - rust-lang/rust#144473 (Address libunwind.a inconsistency issues in the bootstrap program)
 - rust-lang/rust#144601 (Allow `cargo fix` to partially apply `mismatched_lifetime_syntaxes`)
 - rust-lang/rust#144650 (Additional tce tests)
 - rust-lang/rust#144659 (bootstrap: refactor mingw dist and fix gnullvm)
 - rust-lang/rust#144682 (Stabilize `strict_overflow_ops`)
 - rust-lang/rust#145026 (Update books)
 - rust-lang/rust#145033 (Reimplement `print_region` in `type_name.rs`.)
 - rust-lang/rust#145040 (rustc-dev-guide subtree update)

Failed merges:

 - rust-lang/rust#143857 (Port #[macro_export] to the new attribute parsing infrastructure)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_builtin_macros/src')
-rw-r--r--compiler/rustc_builtin_macros/src/test.rs51
1 files changed, 17 insertions, 34 deletions
diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs
index ba3d8368b2a..7b57c02b197 100644
--- a/compiler/rustc_builtin_macros/src/test.rs
+++ b/compiler/rustc_builtin_macros/src/test.rs
@@ -5,10 +5,13 @@ use std::assert_matches::assert_matches;
 use std::iter;
 
 use rustc_ast::ptr::P;
-use rustc_ast::{self as ast, GenericParamKind, attr, join_path_idents};
+use rustc_ast::{self as ast, GenericParamKind, HasNodeId, attr, join_path_idents};
 use rustc_ast_pretty::pprust;
+use rustc_attr_parsing::AttributeParser;
 use rustc_errors::{Applicability, Diag, Level};
 use rustc_expand::base::*;
+use rustc_hir::Attribute;
+use rustc_hir::attrs::AttributeKind;
 use rustc_span::{ErrorGuaranteed, FileNameDisplayPreference, Ident, Span, Symbol, sym};
 use thin_vec::{ThinVec, thin_vec};
 use tracing::debug;
@@ -473,39 +476,19 @@ fn should_ignore_message(i: &ast::Item) -> Option<Symbol> {
 }
 
 fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
-    match attr::find_by_name(&i.attrs, sym::should_panic) {
-        Some(attr) => {
-            match attr.meta_item_list() {
-                // Handle #[should_panic(expected = "foo")]
-                Some(list) => {
-                    let msg = list
-                        .iter()
-                        .find(|mi| mi.has_name(sym::expected))
-                        .and_then(|mi| mi.meta_item())
-                        .and_then(|mi| mi.value_str());
-                    if list.len() != 1 || msg.is_none() {
-                        cx.dcx()
-                            .struct_span_warn(
-                                attr.span,
-                                "argument must be of the form: \
-                             `expected = \"error message\"`",
-                            )
-                            .with_note(
-                                "errors in this attribute were erroneously \
-                                allowed and will become a hard error in a \
-                                future release",
-                            )
-                            .emit();
-                        ShouldPanic::Yes(None)
-                    } else {
-                        ShouldPanic::Yes(msg)
-                    }
-                }
-                // Handle #[should_panic] and #[should_panic = "expected"]
-                None => ShouldPanic::Yes(attr.value_str()),
-            }
-        }
-        None => ShouldPanic::No,
+    if let Some(Attribute::Parsed(AttributeKind::ShouldPanic { reason, .. })) =
+        AttributeParser::parse_limited(
+            cx.sess,
+            &i.attrs,
+            sym::should_panic,
+            i.span,
+            i.node_id(),
+            None,
+        )
+    {
+        ShouldPanic::Yes(reason)
+    } else {
+        ShouldPanic::No
     }
 }