Skip to content

Commit 3b550fe

Browse files
committed
Restrict the set of things that const stability can be applied
Remove the custom special case rejecting const stability on macros as it is now handled by the general check
1 parent 2c8cac8 commit 3b550fe

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,21 @@ impl<S: Stage> AttributeParser<S> for ConstStabilityParser {
243243
this.promotable = true;
244244
}),
245245
];
246-
const ALLOWED_TARGETS: AllowedTargets = ALLOWED_TARGETS;
246+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
247+
Allow(Target::Fn),
248+
Allow(Target::Method(MethodKind::Inherent)),
249+
Allow(Target::Method(MethodKind::TraitImpl)),
250+
Allow(Target::Method(MethodKind::Trait { body: true })),
251+
Allow(Target::Impl { of_trait: false }),
252+
Allow(Target::Impl { of_trait: true }),
253+
Allow(Target::Use), // FIXME I don't think this does anything?
254+
Allow(Target::Const),
255+
Allow(Target::AssocConst),
256+
Allow(Target::Trait),
257+
Allow(Target::Static),
258+
Allow(Target::Crate),
259+
Allow(Target::MacroDef), // FIXME(oli-obk): remove this and eliminate the manual check for it
260+
]);
247261

248262
fn finalize(mut self, cx: &FinalizeContext<'_, '_, S>) -> Option<AttributeKind> {
249263
if self.promotable {

0 commit comments

Comments
 (0)