@@ -223,6 +223,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
223223 Attribute :: Parsed ( AttributeKind :: RustcMustImplementOneOf { attr_span, fn_names } ) => {
224224 self . check_rustc_must_implement_one_of ( * attr_span, fn_names, hir_id, target)
225225 } ,
226+ Attribute :: Parsed ( AttributeKind :: ShouldPanic { span, .. } ) => {
227+ self . check_should_panic ( attrs, * span, target) ;
228+ } ,
226229 Attribute :: Parsed (
227230 AttributeKind :: EiiExternTarget { .. }
228231 | AttributeKind :: EiiExternItem
@@ -272,6 +275,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
272275 | AttributeKind :: RustcSimdMonomorphizeLaneLimit ( ..)
273276 | AttributeKind :: RustcShouldNotBeCalledOnConstItems ( ..)
274277 | AttributeKind :: RustcTestMarker { .. }
278+ | AttributeKind :: RustcTestDummy
275279 | AttributeKind :: ExportStable
276280 | AttributeKind :: FfiConst ( ..)
277281 | AttributeKind :: UnstableFeatureBound ( ..)
@@ -283,7 +287,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
283287 | AttributeKind :: PassByValue ( ..)
284288 | AttributeKind :: StdInternalSymbol ( ..)
285289 | AttributeKind :: Coverage ( ..)
286- | AttributeKind :: ShouldPanic { .. }
287290 | AttributeKind :: Coroutine ( ..)
288291 | AttributeKind :: Linkage ( ..)
289292 | AttributeKind :: MustUse { .. }
@@ -449,6 +452,15 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
449452 self . check_mix_no_mangle_export ( hir_id, attrs) ;
450453 }
451454
455+ fn check_should_panic ( & self , attrs : & [ Attribute ] , attr_span : Span , target : Target ) {
456+ // The error message only makes sense if it's actually being applied on a function
457+ if matches ! ( target, Target :: Fn ) {
458+ if !find_attr ! ( attrs, AttributeKind :: RustcTestDummy ) {
459+ self . dcx ( ) . emit_warn ( errors:: MustBeAppliedToTest { attr_span, warning : true } ) ;
460+ }
461+ }
462+ }
463+
452464 fn check_rustc_must_implement_one_of (
453465 & self ,
454466 attr_span : Span ,
0 commit comments