mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 12:36:35 +03:00
Rollup merge of #152170 - jdonszelmann:port-rustc-effective-visibility, r=JonathanBrouwer
Port `rustc_effective_visibility` to the new attribute parser r? @JonathanBrouwer
This commit is contained in:
@@ -721,3 +721,42 @@ fn extend(
|
||||
Some(ident)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct RustcEffectiveVisibilityParser;
|
||||
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for RustcEffectiveVisibilityParser {
|
||||
const PATH: &'static [Symbol] = &[sym::rustc_effective_visibility];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
|
||||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
|
||||
Allow(Target::Use),
|
||||
Allow(Target::Static),
|
||||
Allow(Target::Const),
|
||||
Allow(Target::Fn),
|
||||
Allow(Target::Closure),
|
||||
Allow(Target::Mod),
|
||||
Allow(Target::ForeignMod),
|
||||
Allow(Target::TyAlias),
|
||||
Allow(Target::Enum),
|
||||
Allow(Target::Variant),
|
||||
Allow(Target::Struct),
|
||||
Allow(Target::Field),
|
||||
Allow(Target::Union),
|
||||
Allow(Target::Trait),
|
||||
Allow(Target::TraitAlias),
|
||||
Allow(Target::Impl { of_trait: false }),
|
||||
Allow(Target::Impl { of_trait: true }),
|
||||
Allow(Target::AssocConst),
|
||||
Allow(Target::Method(MethodKind::Inherent)),
|
||||
Allow(Target::Method(MethodKind::Trait { body: false })),
|
||||
Allow(Target::Method(MethodKind::Trait { body: true })),
|
||||
Allow(Target::Method(MethodKind::TraitImpl)),
|
||||
Allow(Target::AssocTy),
|
||||
Allow(Target::ForeignFn),
|
||||
Allow(Target::ForeignStatic),
|
||||
Allow(Target::ForeignTy),
|
||||
Allow(Target::MacroDef),
|
||||
Allow(Target::PatField),
|
||||
Allow(Target::Crate),
|
||||
]);
|
||||
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcEffectiveVisibility;
|
||||
}
|
||||
|
||||
@@ -258,6 +258,7 @@ mod late {
|
||||
Single<WithoutArgs<RustcDumpPredicatesParser>>,
|
||||
Single<WithoutArgs<RustcDumpUserArgsParser>>,
|
||||
Single<WithoutArgs<RustcDumpVtableParser>>,
|
||||
Single<WithoutArgs<RustcEffectiveVisibilityParser>>,
|
||||
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
|
||||
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
|
||||
Single<WithoutArgs<RustcLintOptTyParser>>,
|
||||
|
||||
@@ -1094,6 +1094,9 @@ pub enum AttributeKind {
|
||||
/// Represents `#[rustc_dyn_incompatible_trait]`.
|
||||
RustcDynIncompatibleTrait(Span),
|
||||
|
||||
/// Represents `#[rustc_effective_visibility]`.
|
||||
RustcEffectiveVisibility,
|
||||
|
||||
/// Represents `#[rustc_has_incoherent_inherent_impls]`
|
||||
RustcHasIncoherentInherentImpls,
|
||||
|
||||
|
||||
@@ -112,6 +112,7 @@ pub fn encode_cross_crate(&self) -> EncodeCrossCrate {
|
||||
RustcDumpUserArgs => No,
|
||||
RustcDumpVtable(..) => No,
|
||||
RustcDynIncompatibleTrait(..) => No,
|
||||
RustcEffectiveVisibility => Yes,
|
||||
RustcHasIncoherentInherentImpls => Yes,
|
||||
RustcHiddenTypeOfOpaques => No,
|
||||
RustcIfThisChanged(..) => No,
|
||||
|
||||
@@ -307,6 +307,7 @@ fn check_attributes(
|
||||
| AttributeKind::RustcDumpUserArgs
|
||||
| AttributeKind::RustcDumpVtable(..)
|
||||
| AttributeKind::RustcDynIncompatibleTrait(..)
|
||||
| AttributeKind::RustcEffectiveVisibility
|
||||
| AttributeKind::RustcHasIncoherentInherentImpls
|
||||
| AttributeKind::RustcHiddenTypeOfOpaques
|
||||
| AttributeKind::RustcIfThisChanged(..)
|
||||
@@ -401,7 +402,6 @@ fn check_attributes(
|
||||
| sym::rustc_regions
|
||||
| sym::rustc_strict_coherence
|
||||
| sym::rustc_mir
|
||||
| sym::rustc_effective_visibility
|
||||
| sym::rustc_outlives
|
||||
| sym::rustc_symbol_name
|
||||
| sym::rustc_evaluate_where_clauses
|
||||
|
||||
@@ -876,7 +876,7 @@ pub struct TestReachabilityVisitor<'a, 'tcx> {
|
||||
|
||||
impl<'a, 'tcx> TestReachabilityVisitor<'a, 'tcx> {
|
||||
fn effective_visibility_diagnostic(&self, def_id: LocalDefId) {
|
||||
if self.tcx.has_attr(def_id, sym::rustc_effective_visibility) {
|
||||
if find_attr!(self.tcx.get_all_attrs(def_id), AttributeKind::RustcEffectiveVisibility) {
|
||||
let mut error_msg = String::new();
|
||||
let span = self.tcx.def_span(def_id.to_def_id());
|
||||
if let Some(effective_vis) = self.effective_visibilities.effective_vis(def_id) {
|
||||
|
||||
Reference in New Issue
Block a user