Port #[fundamental] to the new attribute system
This commit is contained in:
@@ -272,6 +272,9 @@ pub enum AttributeKind {
|
||||
/// Represents `#[ffi_pure]`.
|
||||
FfiPure(Span),
|
||||
|
||||
/// Represents `#[fundamental]`.
|
||||
Fundamental,
|
||||
|
||||
/// Represents `#[ignore]`
|
||||
Ignore {
|
||||
span: Span,
|
||||
|
||||
@@ -34,6 +34,7 @@ impl AttributeKind {
|
||||
ExportStable => No,
|
||||
FfiConst(..) => No,
|
||||
FfiPure(..) => No,
|
||||
Fundamental { .. } => Yes,
|
||||
Ignore { .. } => No,
|
||||
Inline(..) => No,
|
||||
LinkName { .. } => Yes,
|
||||
|
||||
@@ -110,3 +110,10 @@ impl<S: Stage> NoArgsAttributeParser<S> for MarkerParser {
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
|
||||
const CREATE: fn(Span) -> AttributeKind = AttributeKind::Marker;
|
||||
}
|
||||
|
||||
pub(crate) struct FundamentalParser;
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for FundamentalParser {
|
||||
const PATH: &[Symbol] = &[sym::fundamental];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
|
||||
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::Fundamental;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ use crate::attributes::stability::{
|
||||
use crate::attributes::test_attrs::IgnoreParser;
|
||||
use crate::attributes::traits::{
|
||||
CoinductiveParser, ConstTraitParser, DenyExplicitImplParser, DoNotImplementViaObjectParser,
|
||||
MarkerParser, SkipDuringMethodDispatchParser, SpecializationTraitParser, TypeConstParser,
|
||||
UnsafeSpecializationMarkerParser,
|
||||
FundamentalParser, MarkerParser, SkipDuringMethodDispatchParser, SpecializationTraitParser,
|
||||
TypeConstParser, UnsafeSpecializationMarkerParser,
|
||||
};
|
||||
use crate::attributes::transparency::TransparencyParser;
|
||||
use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs};
|
||||
@@ -161,6 +161,7 @@ attribute_parsers!(
|
||||
Single<WithoutArgs<ExportStableParser>>,
|
||||
Single<WithoutArgs<FfiConstParser>>,
|
||||
Single<WithoutArgs<FfiPureParser>>,
|
||||
Single<WithoutArgs<FundamentalParser>>,
|
||||
Single<WithoutArgs<LoopMatchParser>>,
|
||||
Single<WithoutArgs<MarkerParser>>,
|
||||
Single<WithoutArgs<MayDangleParser>>,
|
||||
|
||||
@@ -869,7 +869,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
||||
let is_marker = !is_alias && find_attr!(attrs, AttributeKind::Marker(_));
|
||||
|
||||
let rustc_coinductive = find_attr!(attrs, AttributeKind::Coinductive(_));
|
||||
let is_fundamental = attrs.iter().any(|attr| attr.has_name(sym::fundamental));
|
||||
let is_fundamental = find_attr!(attrs, AttributeKind::Fundamental);
|
||||
|
||||
let [skip_array_during_method_dispatch, skip_boxed_slice_during_method_dispatch] = find_attr!(
|
||||
attrs,
|
||||
|
||||
@@ -17,7 +17,6 @@ use rustc_index::{IndexSlice, IndexVec};
|
||||
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
|
||||
use rustc_query_system::ich::StableHashingContext;
|
||||
use rustc_session::DataTypeKind;
|
||||
use rustc_span::sym;
|
||||
use rustc_type_ir::solve::AdtDestructorKind;
|
||||
use tracing::{debug, info, trace};
|
||||
|
||||
@@ -296,7 +295,7 @@ impl AdtDefData {
|
||||
flags |= AdtFlags::HAS_CTOR;
|
||||
}
|
||||
|
||||
if tcx.has_attr(did, sym::fundamental) {
|
||||
if find_attr!(tcx.get_all_attrs(did), AttributeKind::Fundamental) {
|
||||
flags |= AdtFlags::IS_FUNDAMENTAL;
|
||||
}
|
||||
if tcx.is_lang_item(did, LangItem::PhantomData) {
|
||||
|
||||
@@ -290,6 +290,7 @@ pub fn check_builtin_meta_item(
|
||||
| sym::rustc_specialization_trait
|
||||
| sym::rustc_unsafe_specialization_marker
|
||||
| sym::marker
|
||||
| sym::fundamental
|
||||
| sym::type_const
|
||||
| sym::repr
|
||||
| sym::align
|
||||
|
||||
@@ -142,6 +142,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||
&Attribute::Parsed(AttributeKind::Marker(attr_span)) => {
|
||||
self.check_marker(hir_id, attr_span, span, target)
|
||||
}
|
||||
Attribute::Parsed(AttributeKind::Fundamental) => {
|
||||
// FIXME: add validation
|
||||
}
|
||||
Attribute::Parsed(AttributeKind::Confusables { first_span, .. }) => {
|
||||
self.check_confusables(*first_span, target);
|
||||
}
|
||||
@@ -374,7 +377,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||
| sym::prelude_import
|
||||
| sym::panic_handler
|
||||
| sym::allow_internal_unsafe
|
||||
| sym::fundamental
|
||||
| sym::lang
|
||||
| sym::needs_allocator
|
||||
| sym::default_lib_allocator
|
||||
|
||||
@@ -116,12 +116,6 @@ error: malformed `cfi_encoding` attribute input
|
||||
LL | #[cfi_encoding]
|
||||
| ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]`
|
||||
|
||||
error: malformed `fundamental` attribute input
|
||||
--> $DIR/malformed-attrs.rs:157:1
|
||||
|
|
||||
LL | #[fundamental()]
|
||||
| ^^^^^^^^^^^^^^^^ help: must be of the form: `#[fundamental]`
|
||||
|
||||
error: malformed `link_ordinal` attribute input
|
||||
--> $DIR/malformed-attrs.rs:167:5
|
||||
|
|
||||
@@ -525,6 +519,15 @@ LL | #[marker = 3]
|
||||
| | didn't expect any arguments here
|
||||
| help: must be of the form: `#[marker]`
|
||||
|
||||
error[E0565]: malformed `fundamental` attribute input
|
||||
--> $DIR/malformed-attrs.rs:157:1
|
||||
|
|
||||
LL | #[fundamental()]
|
||||
| ^^^^^^^^^^^^^--^
|
||||
| | |
|
||||
| | didn't expect any arguments here
|
||||
| help: must be of the form: `#[fundamental]`
|
||||
|
||||
error[E0565]: malformed `ffi_pure` attribute input
|
||||
--> $DIR/malformed-attrs.rs:165:5
|
||||
|
|
||||
|
||||
Reference in New Issue
Block a user