Skip to content

Commit 0185274

Browse files
Port #[panic_handler] to the new attribute parsers
1 parent 4560e80 commit 0185274

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,15 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcHasIncoherentInherentImplsParse
668668
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcHasIncoherentInherentImpls;
669669
}
670670

671+
pub(crate) struct PanicHandlerParser;
672+
673+
impl<S: Stage> NoArgsAttributeParser<S> for PanicHandlerParser {
674+
const PATH: &[Symbol] = &[sym::panic_handler];
675+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
676+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS); // Targets are checked per lang item in `rustc_passes`
677+
const CREATE: fn(Span) -> AttributeKind = |span| AttributeKind::Lang(LangItem::PanicImpl, span);
678+
}
679+
671680
pub(crate) struct RustcHiddenTypeOfOpaquesParser;
672681

673682
impl<S: Stage> NoArgsAttributeParser<S> for RustcHiddenTypeOfOpaquesParser {

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ attribute_parsers!(
254254
Single<WithoutArgs<NoMangleParser>>,
255255
Single<WithoutArgs<NoStdParser>>,
256256
Single<WithoutArgs<NonExhaustiveParser>>,
257+
Single<WithoutArgs<PanicHandlerParser>>,
257258
Single<WithoutArgs<PanicRuntimeParser>>,
258259
Single<WithoutArgs<ParenSugarParser>>,
259260
Single<WithoutArgs<PassByValueParser>>,

0 commit comments

Comments
 (0)