Auto merge of #134381 - jdonszelmann:move-attribute-types, r=oli-obk
Split up attribute parsing code and move data types to `rustc_attr_data_structures` This change renames `rustc_attr` to `rustc_attr_parsing`, and splits up the parsing code. At the same time, all the data types used move to `rustc_attr_data_structures`. This is in preparation of also having a third crate: `rustc_attr_validation` I initially envisioned this as two separate PRs, but I think doing it in one go reduces the number of ways others would have to rebase their changes on this. However, I can still split them. r? `@oli-obk` (we already discussed how this is a first step in a larger plan) For a more detailed plan on how attributes are going to change, see https://github.com/rust-lang/rust/issues/131229 Edit: this looks like a giant PR, but the changes are actually rather trivial. Each commit is reviewable on its own, and mostly moves code around. No new logic is added.
This commit is contained in:
commit
a4cb3c8318
108 changed files with 1821 additions and 1629 deletions
|
@ -4,7 +4,7 @@
|
|||
//! but are not declared in one single location (unlike lang features), which means we need to
|
||||
//! collect them instead.
|
||||
|
||||
use rustc_attr::VERSION_PLACEHOLDER;
|
||||
use rustc_attr_parsing::VERSION_PLACEHOLDER;
|
||||
use rustc_hir::Attribute;
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
use std::mem::replace;
|
||||
use std::num::NonZero;
|
||||
|
||||
use rustc_attr::{
|
||||
use rustc_attr_parsing::{
|
||||
self as attr, ConstStability, DeprecatedSince, Stability, StabilityLevel, StableSince,
|
||||
Unstable, UnstableReason, VERSION_PLACEHOLDER,
|
||||
UnstableReason, VERSION_PLACEHOLDER,
|
||||
};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::unord::{ExtendUnord, UnordMap, UnordSet};
|
||||
|
@ -199,7 +199,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
|||
// this is *almost surely* an accident.
|
||||
if let (
|
||||
&Some(DeprecatedSince::RustcVersion(dep_since)),
|
||||
&attr::Stable { since: stab_since, .. },
|
||||
&attr::StabilityLevel::Stable { since: stab_since, .. },
|
||||
) = (&depr.as_ref().map(|(d, _)| d.since), &stab.level)
|
||||
{
|
||||
match stab_since {
|
||||
|
@ -224,15 +224,17 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
|||
|
||||
// Stable *language* features shouldn't be used as unstable library features.
|
||||
// (Not doing this for stable library features is checked by tidy.)
|
||||
if let Stability { level: Unstable { .. }, feature } = stab {
|
||||
if let Stability { level: StabilityLevel::Unstable { .. }, feature } = stab {
|
||||
if ACCEPTED_LANG_FEATURES.iter().find(|f| f.name == feature).is_some() {
|
||||
self.tcx
|
||||
.dcx()
|
||||
.emit_err(errors::UnstableAttrForAlreadyStableFeature { span, item_sp });
|
||||
}
|
||||
}
|
||||
if let Stability { level: Unstable { implied_by: Some(implied_by), .. }, feature } =
|
||||
stab
|
||||
if let Stability {
|
||||
level: StabilityLevel::Unstable { implied_by: Some(implied_by), .. },
|
||||
feature,
|
||||
} = stab
|
||||
{
|
||||
self.index.implications.insert(implied_by, feature);
|
||||
}
|
||||
|
@ -278,8 +280,10 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
|||
|
||||
// Stable *language* features shouldn't be used as unstable library features.
|
||||
// (Not doing this for stable library features is checked by tidy.)
|
||||
if let Some((ConstStability { level: Unstable { .. }, feature, .. }, const_span)) =
|
||||
const_stab
|
||||
if let Some((
|
||||
ConstStability { level: StabilityLevel::Unstable { .. }, feature, .. },
|
||||
const_span,
|
||||
)) = const_stab
|
||||
{
|
||||
if ACCEPTED_LANG_FEATURES.iter().find(|f| f.name == feature).is_some() {
|
||||
self.tcx.dcx().emit_err(errors::UnstableAttrForAlreadyStableFeature {
|
||||
|
@ -314,7 +318,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
|||
});
|
||||
|
||||
if let Some(ConstStability {
|
||||
level: Unstable { implied_by: Some(implied_by), .. },
|
||||
level: StabilityLevel::Unstable { implied_by: Some(implied_by), .. },
|
||||
feature,
|
||||
..
|
||||
}) = const_stab
|
||||
|
@ -780,7 +784,11 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
|
|||
// error if all involved types and traits are stable, because
|
||||
// it will have no effect.
|
||||
// See: https://github.com/rust-lang/rust/issues/55436
|
||||
if let Some((Stability { level: attr::Unstable { .. }, .. }, span)) = stab {
|
||||
if let Some((
|
||||
Stability { level: attr::StabilityLevel::Unstable { .. }, .. },
|
||||
span,
|
||||
)) = stab
|
||||
{
|
||||
let mut c = CheckTraitImplStable { tcx: self.tcx, fully_stable: true };
|
||||
c.visit_ty(self_ty);
|
||||
c.visit_trait_ref(t);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue