Port rustc_trivial_field_reads to the new attribute parser
This commit is contained in:
parent
954f483557
commit
f4c135f91b
6 changed files with 48 additions and 11 deletions
|
|
@ -502,6 +502,15 @@ impl<S: Stage> SingleAttributeParser<S> for RustcNeverTypeOptionsParser {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) struct RustcTrivialFieldReadsParser;
|
||||
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for RustcTrivialFieldReadsParser {
|
||||
const PATH: &[Symbol] = &[sym::rustc_trivial_field_reads];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
|
||||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Trait)]);
|
||||
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcTrivialFieldReads;
|
||||
}
|
||||
|
||||
pub(crate) struct RustcLintQueryInstabilityParser;
|
||||
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for RustcLintQueryInstabilityParser {
|
||||
|
|
|
|||
|
|
@ -169,6 +169,32 @@ attribute_parsers!(
|
|||
// tidy-alphabetical-end
|
||||
|
||||
// tidy-alphabetical-start
|
||||
%%%%%%% Changes from base to side #1
|
||||
%%%%%%%%%%% Changes from base to side #1
|
||||
Single<WithoutArgs<RustcStrictCoherenceParser>>,
|
||||
Single<WithoutArgs<RustcVarianceOfOpaquesParser>>,
|
||||
Single<WithoutArgs<RustcVarianceParser>>,
|
||||
Single<WithoutArgs<SpecializationTraitParser>>,
|
||||
Single<WithoutArgs<StdInternalSymbolParser>>,
|
||||
Single<WithoutArgs<ThreadLocalParser>>,
|
||||
Single<WithoutArgs<TrackCallerParser>>,
|
||||
+ Single<WithoutArgs<RustcStrictCoherenceParser>>,
|
||||
+++++++ Contents of side #2
|
||||
Single<WithoutArgs<RustcTrivialFieldReadsParser>>,
|
||||
+++++++++++ Contents of side #2
|
||||
- Single<WithoutArgs<TypeConstParser>>,
|
||||
Single<WithoutArgs<UnsafeSpecializationMarkerParser>>,
|
||||
<<<<<<< Conflict 1 of 1
|
||||
<<<<<<<<<<< Conflict 2 of 2
|
||||
>>>>>>> Conflict 1 of 1 ends
|
||||
Single<WithoutArgs<RustcVarianceOfOpaquesParser>>,
|
||||
Single<WithoutArgs<RustcVarianceParser>>,
|
||||
Single<WithoutArgs<SpecializationTraitParser>>,
|
||||
Single<WithoutArgs<StdInternalSymbolParser>>,
|
||||
Single<WithoutArgs<ThreadLocalParser>>,
|
||||
Single<WithoutArgs<TrackCallerParser>>,
|
||||
Single<WithoutArgs<TypeConstParser>>,
|
||||
Single<WithoutArgs<UnsafeSpecializationMarkerParser>>,
|
||||
Single<CfiEncodingParser>,
|
||||
Single<CollapseDebugInfoParser>,
|
||||
Single<CoverageParser>,
|
||||
|
|
@ -213,6 +239,7 @@ attribute_parsers!(
|
|||
Single<RustcNeverTypeOptionsParser>,
|
||||
Single<RustcObjectLifetimeDefaultParser>,
|
||||
Single<RustcReservationImplParser>,
|
||||
Single<RustcNeverTypeOptionsParser>,
|
||||
Single<RustcScalableVectorParser>,
|
||||
Single<RustcSimdMonomorphizeLaneLimitParser>,
|
||||
Single<RustcSymbolName>,
|
||||
|
|
@ -297,14 +324,7 @@ attribute_parsers!(
|
|||
Single<WithoutArgs<RustcReallocatorParser>>,
|
||||
Single<WithoutArgs<RustcRegionsParser>>,
|
||||
Single<WithoutArgs<RustcShouldNotBeCalledOnConstItems>>,
|
||||
Single<WithoutArgs<RustcStrictCoherenceParser>>,
|
||||
Single<WithoutArgs<RustcVarianceOfOpaquesParser>>,
|
||||
Single<WithoutArgs<RustcVarianceParser>>,
|
||||
Single<WithoutArgs<SpecializationTraitParser>>,
|
||||
Single<WithoutArgs<StdInternalSymbolParser>>,
|
||||
Single<WithoutArgs<ThreadLocalParser>>,
|
||||
Single<WithoutArgs<TrackCallerParser>>,
|
||||
Single<WithoutArgs<UnsafeSpecializationMarkerParser>>,
|
||||
>>>>>>>>>>> Conflict 2 of 2 ends
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1326,6 +1326,9 @@ pub enum AttributeKind {
|
|||
/// Represents `#[rustc_then_this_would_need]`
|
||||
RustcThenThisWouldNeed(Span, ThinVec<Ident>),
|
||||
|
||||
/// Represents `#[rustc_trivial_field_reads]`
|
||||
RustcTrivialFieldReads,
|
||||
|
||||
/// Represents `#[rustc_unsafe_specialization_marker]`.
|
||||
RustcUnsafeSpecializationMarker(Span),
|
||||
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ impl AttributeKind {
|
|||
RustcStrictCoherence(..) => Yes,
|
||||
RustcSymbolName(..) => Yes,
|
||||
RustcThenThisWouldNeed(..) => No,
|
||||
RustcTrivialFieldReads => Yes,
|
||||
RustcUnsafeSpecializationMarker(..) => No,
|
||||
RustcVariance => No,
|
||||
RustcVarianceOfOpaques => No,
|
||||
|
|
|
|||
|
|
@ -358,6 +358,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
| AttributeKind::RustcStrictCoherence(..)
|
||||
| AttributeKind::RustcSymbolName(..)
|
||||
| AttributeKind::RustcThenThisWouldNeed(..)
|
||||
| AttributeKind::RustcTrivialFieldReads
|
||||
| AttributeKind::RustcUnsafeSpecializationMarker(..)
|
||||
| AttributeKind::RustcVariance
|
||||
| AttributeKind::RustcVarianceOfOpaques
|
||||
|
|
@ -399,7 +400,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
| sym::rustc_no_mir_inline
|
||||
| sym::rustc_nonnull_optimization_guaranteed
|
||||
| sym::rustc_inherit_overflow_checks
|
||||
| sym::rustc_trivial_field_reads
|
||||
| sym::rustc_on_unimplemented
|
||||
| sym::rustc_do_not_const_check
|
||||
| sym::rustc_doc_primitive
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@ use hir::def_id::{LocalDefIdMap, LocalDefIdSet};
|
|||
use rustc_abi::FieldIdx;
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_errors::{ErrorGuaranteed, MultiSpan};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::def::{CtorOf, DefKind, Res};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::{self as hir, Node, PatKind, QPath};
|
||||
use rustc_hir::{self as hir, Node, PatKind, QPath, find_attr};
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::middle::privacy::Level;
|
||||
use rustc_middle::query::Providers;
|
||||
|
|
@ -380,7 +381,10 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
|||
&& let impl_of = self.tcx.parent(impl_item.owner_id.to_def_id())
|
||||
&& self.tcx.is_automatically_derived(impl_of)
|
||||
&& let trait_ref = self.tcx.impl_trait_ref(impl_of).instantiate_identity()
|
||||
&& self.tcx.has_attr(trait_ref.def_id, sym::rustc_trivial_field_reads)
|
||||
&& find_attr!(
|
||||
self.tcx.get_all_attrs(trait_ref.def_id),
|
||||
AttributeKind::RustcTrivialFieldReads
|
||||
)
|
||||
{
|
||||
if let ty::Adt(adt_def, _) = trait_ref.self_ty().kind()
|
||||
&& let Some(adt_def_id) = adt_def.did().as_local()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue