NoArgsAttributeParser: use an assoc const instead
This commit is contained in:
@@ -49,10 +49,7 @@ pub(crate) struct ColdParser;
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for ColdParser {
|
||||
const PATH: &[Symbol] = &[sym::cold];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
|
||||
|
||||
fn create(span: Span) -> AttributeKind {
|
||||
AttributeKind::Cold(span)
|
||||
}
|
||||
const CREATE: fn(Span) -> AttributeKind = AttributeKind::Cold;
|
||||
}
|
||||
|
||||
pub(crate) struct ExportNameParser;
|
||||
@@ -193,20 +190,14 @@ pub(crate) struct TrackCallerParser;
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for TrackCallerParser {
|
||||
const PATH: &[Symbol] = &[sym::track_caller];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
|
||||
|
||||
fn create(span: Span) -> AttributeKind {
|
||||
AttributeKind::TrackCaller(span)
|
||||
}
|
||||
const CREATE: fn(Span) -> AttributeKind = AttributeKind::TrackCaller;
|
||||
}
|
||||
|
||||
pub(crate) struct NoMangleParser;
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for NoMangleParser {
|
||||
const PATH: &[Symbol] = &[sym::no_mangle];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
|
||||
|
||||
fn create(span: Span) -> AttributeKind {
|
||||
AttributeKind::NoMangle(span)
|
||||
}
|
||||
const CREATE: fn(Span) -> AttributeKind = AttributeKind::NoMangle;
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
||||
@@ -8,18 +8,12 @@ pub(crate) struct AsPtrParser;
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for AsPtrParser {
|
||||
const PATH: &[Symbol] = &[sym::rustc_as_ptr];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
|
||||
|
||||
fn create(span: Span) -> AttributeKind {
|
||||
AttributeKind::AsPtr(span)
|
||||
}
|
||||
const CREATE: fn(Span) -> AttributeKind = AttributeKind::AsPtr;
|
||||
}
|
||||
|
||||
pub(crate) struct PubTransparentParser;
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for PubTransparentParser {
|
||||
const PATH: &[Symbol] = &[sym::rustc_pub_transparent];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
|
||||
|
||||
fn create(span: Span) -> AttributeKind {
|
||||
AttributeKind::PubTransparent(span)
|
||||
}
|
||||
const CREATE: fn(Span) -> AttributeKind = AttributeKind::PubTransparent;
|
||||
}
|
||||
|
||||
@@ -8,18 +8,12 @@ pub(crate) struct LoopMatchParser;
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for LoopMatchParser {
|
||||
const PATH: &[Symbol] = &[sym::loop_match];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
|
||||
|
||||
fn create(span: Span) -> AttributeKind {
|
||||
AttributeKind::LoopMatch(span)
|
||||
}
|
||||
const CREATE: fn(Span) -> AttributeKind = AttributeKind::LoopMatch;
|
||||
}
|
||||
|
||||
pub(crate) struct ConstContinueParser;
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for ConstContinueParser {
|
||||
const PATH: &[Symbol] = &[sym::const_continue];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
|
||||
|
||||
fn create(span: Span) -> AttributeKind {
|
||||
AttributeKind::ConstContinue(span)
|
||||
}
|
||||
const CREATE: fn(Span) -> AttributeKind = AttributeKind::ConstContinue;
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ pub(crate) trait NoArgsAttributeParser<S: Stage>: 'static {
|
||||
const ON_DUPLICATE: OnDuplicate<S>;
|
||||
|
||||
/// Create the [`AttributeKind`] given attribute's [`Span`].
|
||||
fn create(span: Span) -> AttributeKind;
|
||||
const CREATE: fn(Span) -> AttributeKind;
|
||||
}
|
||||
|
||||
pub(crate) struct WithoutArgs<T: NoArgsAttributeParser<S>, S: Stage>(PhantomData<(S, T)>);
|
||||
@@ -259,7 +259,7 @@ impl<T: NoArgsAttributeParser<S>, S: Stage> SingleAttributeParser<S> for Without
|
||||
if let Err(span) = args.no_args() {
|
||||
cx.expected_no_args(span);
|
||||
}
|
||||
Some(T::create(cx.attr_span))
|
||||
Some(T::CREATE(cx.attr_span))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,5 @@ pub(crate) struct MayDangleParser;
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for MayDangleParser {
|
||||
const PATH: &[Symbol] = &[sym::may_dangle];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
|
||||
|
||||
fn create(span: Span) -> AttributeKind {
|
||||
AttributeKind::MayDangle(span)
|
||||
}
|
||||
const CREATE: fn(span: Span) -> AttributeKind = AttributeKind::MayDangle;
|
||||
}
|
||||
|
||||
@@ -136,10 +136,7 @@ pub(crate) struct ConstStabilityIndirectParser;
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for ConstStabilityIndirectParser {
|
||||
const PATH: &[Symbol] = &[sym::rustc_const_stable_indirect];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Ignore;
|
||||
|
||||
fn create(_: Span) -> AttributeKind {
|
||||
AttributeKind::ConstStabilityIndirect
|
||||
}
|
||||
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::ConstStabilityIndirect;
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
||||
Reference in New Issue
Block a user