Port #[rustc_coinductive] to the new attribute system
This commit is contained in:
@@ -211,6 +211,9 @@ pub enum AttributeKind {
|
||||
span: Span,
|
||||
},
|
||||
|
||||
/// Represents `#[rustc_coinductive]`.
|
||||
Coinductive(Span),
|
||||
|
||||
/// Represents `#[cold]`.
|
||||
Cold(Span),
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ impl AttributeKind {
|
||||
AllowInternalUnstable(..) => Yes,
|
||||
AsPtr(..) => Yes,
|
||||
BodyStability { .. } => No,
|
||||
Coinductive(..) => No,
|
||||
Cold(..) => No,
|
||||
Confusables { .. } => Yes,
|
||||
ConstContinue(..) => No,
|
||||
|
||||
@@ -75,3 +75,10 @@ impl<S: Stage> NoArgsAttributeParser<S> for DoNotImplementViaObjectParser {
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
|
||||
const CREATE: fn(Span) -> AttributeKind = AttributeKind::DoNotImplementViaObject;
|
||||
}
|
||||
|
||||
pub(crate) struct CoinductiveParser;
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for CoinductiveParser {
|
||||
const PATH: &[Symbol] = &[sym::rustc_coinductive];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
|
||||
const CREATE: fn(Span) -> AttributeKind = AttributeKind::Coinductive;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ use crate::attributes::stability::{
|
||||
};
|
||||
use crate::attributes::test_attrs::IgnoreParser;
|
||||
use crate::attributes::traits::{
|
||||
ConstTraitParser, DenyExplicitImplParser, DoNotImplementViaObjectParser,
|
||||
CoinductiveParser, ConstTraitParser, DenyExplicitImplParser, DoNotImplementViaObjectParser,
|
||||
SkipDuringMethodDispatchParser,
|
||||
};
|
||||
use crate::attributes::transparency::TransparencyParser;
|
||||
@@ -150,6 +150,7 @@ attribute_parsers!(
|
||||
Single<SkipDuringMethodDispatchParser>,
|
||||
Single<TransparencyParser>,
|
||||
Single<WithoutArgs<AsPtrParser>>,
|
||||
Single<WithoutArgs<CoinductiveParser>>,
|
||||
Single<WithoutArgs<ColdParser>>,
|
||||
Single<WithoutArgs<ConstContinueParser>>,
|
||||
Single<WithoutArgs<ConstStabilityIndirectParser>>,
|
||||
|
||||
@@ -868,7 +868,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
||||
// Only regular traits can be marker.
|
||||
let is_marker = !is_alias && attrs.iter().any(|attr| attr.has_name(sym::marker));
|
||||
|
||||
let rustc_coinductive = attrs.iter().any(|attr| attr.has_name(sym::rustc_coinductive));
|
||||
let rustc_coinductive = find_attr!(attrs, AttributeKind::Coinductive(_));
|
||||
let is_fundamental = attrs.iter().any(|attr| attr.has_name(sym::fundamental));
|
||||
|
||||
let [skip_array_during_method_dispatch, skip_boxed_slice_during_method_dispatch] = find_attr!(
|
||||
|
||||
@@ -285,6 +285,7 @@ pub fn check_builtin_meta_item(
|
||||
| sym::rustc_pass_by_value
|
||||
| sym::rustc_deny_explicit_impl
|
||||
| sym::rustc_do_not_implement_via_object
|
||||
| sym::rustc_coinductive
|
||||
| sym::const_trait
|
||||
| sym::repr
|
||||
| sym::align
|
||||
|
||||
@@ -122,6 +122,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||
match attr {
|
||||
Attribute::Parsed(
|
||||
AttributeKind::SkipDuringMethodDispatch { span: attr_span, .. }
|
||||
| AttributeKind::Coinductive(attr_span)
|
||||
| AttributeKind::ConstTrait(attr_span)
|
||||
| AttributeKind::DenyExplicitImpl(attr_span)
|
||||
| AttributeKind::DoNotImplementViaObject(attr_span),
|
||||
@@ -299,9 +300,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||
| [sym::rustc_dirty, ..]
|
||||
| [sym::rustc_if_this_changed, ..]
|
||||
| [sym::rustc_then_this_would_need, ..] => self.check_rustc_dirty_clean(attr),
|
||||
[sym::rustc_coinductive, ..]
|
||||
| [sym::rustc_must_implement_one_of, ..]
|
||||
=> self.check_must_be_applied_to_trait(attr.span(), span, target),
|
||||
[sym::rustc_must_implement_one_of, ..] => self.check_must_be_applied_to_trait(attr.span(), span, target),
|
||||
[sym::collapse_debuginfo, ..] => self.check_collapse_debuginfo(attr, span, target),
|
||||
[sym::must_not_suspend, ..] => self.check_must_not_suspend(attr, span, target),
|
||||
[sym::rustc_allow_incoherent_impl, ..] => {
|
||||
|
||||
Reference in New Issue
Block a user