Rollup merge of #152431 - oli-obk:limited_stability_attr, r=jdonszelmann
Restrict the set of things that const stability can be applied to r? @jdonszelmann
This commit is contained in:
commit
88eda646f2
6 changed files with 26 additions and 35 deletions
|
|
@ -244,7 +244,20 @@ impl<S: Stage> AttributeParser<S> for ConstStabilityParser {
|
|||
this.promotable = true;
|
||||
}),
|
||||
];
|
||||
const ALLOWED_TARGETS: AllowedTargets = ALLOWED_TARGETS;
|
||||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
|
||||
Allow(Target::Fn),
|
||||
Allow(Target::Method(MethodKind::Inherent)),
|
||||
Allow(Target::Method(MethodKind::TraitImpl)),
|
||||
Allow(Target::Method(MethodKind::Trait { body: true })),
|
||||
Allow(Target::Impl { of_trait: false }),
|
||||
Allow(Target::Impl { of_trait: true }),
|
||||
Allow(Target::Use), // FIXME I don't think this does anything?
|
||||
Allow(Target::Const),
|
||||
Allow(Target::AssocConst),
|
||||
Allow(Target::Trait),
|
||||
Allow(Target::Static),
|
||||
Allow(Target::Crate),
|
||||
]);
|
||||
|
||||
fn finalize(mut self, cx: &FinalizeContext<'_, '_, S>) -> Option<AttributeKind> {
|
||||
if self.promotable {
|
||||
|
|
|
|||
|
|
@ -962,15 +962,6 @@ impl SyntaxExtension {
|
|||
|
||||
let stability = find_attr!(attrs, AttributeKind::Stability { stability, .. } => *stability);
|
||||
|
||||
// FIXME(jdonszelmann): make it impossible to miss the or_else in the typesystem
|
||||
if let Some(sp) =
|
||||
find_attr!(attrs, AttributeKind::RustcConstStability { span, .. } => *span)
|
||||
{
|
||||
sess.dcx().emit_err(errors::MacroConstStability {
|
||||
span: sp,
|
||||
head_span: sess.source_map().guess_head_span(span),
|
||||
});
|
||||
}
|
||||
if let Some(sp) = find_attr!(attrs, AttributeKind::RustcBodyStability{ span, .. } => *span)
|
||||
{
|
||||
sess.dcx().emit_err(errors::MacroBodyStability {
|
||||
|
|
|
|||
|
|
@ -80,16 +80,6 @@ pub(crate) struct ResolveRelativePath {
|
|||
pub path: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("macros cannot have const stability attributes")]
|
||||
pub(crate) struct MacroConstStability {
|
||||
#[primary_span]
|
||||
#[label("invalid const stability attribute")]
|
||||
pub span: Span,
|
||||
#[label("const stability attribute affects this macro")]
|
||||
pub head_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("macros cannot have body stability attributes")]
|
||||
pub(crate) struct MacroBodyStability {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue