Skip to content

Commit ee8ca0a

Browse files
Port #[panic_handler] to the new attribute parsers
1 parent c61c260 commit ee8ca0a

3 files changed

Lines changed: 11 additions & 1 deletion

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>>,

compiler/rustc_passes/src/lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! * Functions called by the compiler itself.
99
1010
use rustc_ast as ast;
11-
use rustc_ast::fmvisit;
11+
use rustc_ast::visit;
1212
use rustc_data_structures::fx::FxHashMap;
1313
use rustc_hir::def_id::{DefId, LocalDefId};
1414
use rustc_hir::lang_items::GenericRequirement;

0 commit comments

Comments
 (0)