Skip to content

Commit 92e7c93

Browse files
Remove Stage
1 parent 119aa32 commit 92e7c93

3 files changed

Lines changed: 8 additions & 62 deletions

File tree

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ use std::mem;
55
use std::ops::{Deref, DerefMut};
66
use std::sync::LazyLock;
77

8-
use rustc_ast::{AttrStyle, MetaItemLit, NodeId};
8+
use rustc_ast::{AttrStyle, MetaItemLit};
99
use rustc_data_structures::sync::{DynSend, DynSync};
1010
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, MultiSpan};
1111
use rustc_feature::{AttrSuggestionStyle, AttributeTemplate};
1212
use rustc_hir::AttrPath;
1313
use rustc_hir::attrs::AttributeKind;
1414
use rustc_hir::lints::AttributeLintKind;
15-
use rustc_hir::{AttrPath, HirId};
1615
use rustc_parse::parser::Recovery;
1716
use rustc_session::lint::{Lint, LintId};
1817
use rustc_span::{ErrorGuaranteed, Span, Symbol};
@@ -67,7 +66,6 @@ use crate::session_diagnostics::{
6766
};
6867
use crate::target_checking::AllowedTargets;
6968
use crate::{AttributeParser, EmitAttribute};
70-
use crate::context::private::Sealed;
7169

7270
type GroupType = LazyLock<GroupTypeInner>;
7371

@@ -91,20 +89,6 @@ pub(crate) type FinalizeFn =
9189
macro_rules! attribute_parsers {
9290
(
9391
pub(crate) static $name: ident = [$($names: ty),* $(,)?];
94-
) => {
95-
mod early {
96-
use super::*;
97-
98-
attribute_parsers!(@[Early] pub(crate) static $name = [$($names),*];);
99-
}
100-
mod late {
101-
use super::*;
102-
103-
attribute_parsers!(@[Late] pub(crate) static $name = [$($names),*];);
104-
}
105-
};
106-
(
107-
@[$stage: ty] pub(crate) static $name: ident = [$($names: ty),* $(,)?];
10892
) => {
10993
pub(crate) static $name: GroupType = LazyLock::new(|| {
11094
let mut accepters = BTreeMap::<_, GroupTypeInnerAccept>::new();
@@ -339,46 +323,6 @@ attribute_parsers!(
339323
];
340324
);
341325

342-
mod private {
343-
pub trait Sealed {}
344-
impl Sealed for super::Early {}
345-
impl Sealed for super::Late {}
346-
}
347-
348-
// allow because it's a sealed trait
349-
#[allow(private_interfaces)]
350-
pub trait Stage: Sized + 'static + Sealed {
351-
type Id: Copy;
352-
353-
fn parsers() -> &'static GroupType;
354-
}
355-
356-
// allow because it's a sealed trait
357-
#[allow(private_interfaces)]
358-
impl Stage for Early {
359-
type Id = NodeId;
360-
361-
fn parsers() -> &'static GroupType {
362-
&early::ATTRIBUTE_PARSERS
363-
}
364-
}
365-
366-
// allow because it's a sealed trait
367-
#[allow(private_interfaces)]
368-
impl Stage for Late {
369-
type Id = HirId;
370-
371-
fn parsers() -> &'static GroupType {
372-
&late::ATTRIBUTE_PARSERS
373-
}
374-
}
375-
376-
/// Used when parsing attributes for miscellaneous things *before* ast lowering
377-
pub struct Early;
378-
379-
/// used when parsing attributes during ast lowering
380-
pub struct Late;
381-
382326
/// Context given to every attribute parser when accepting
383327
///
384328
/// Gives [`AttributeParser`]s enough information to create errors, for example.

compiler/rustc_attr_parsing/src/interface.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ use rustc_session::lint::LintId;
1414
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
1515

1616
use crate::attributes::AttributeSafety;
17-
use crate::context::{AcceptContext, FinalizeContext, FinalizeFn, SharedContext, Stage};
17+
use crate::context::{
18+
ATTRIBUTE_PARSERS, AcceptContext, FinalizeContext, FinalizeFn, SharedContext,
19+
};
1820
use crate::early_parsed::{EARLY_PARSED_ATTRIBUTES, EarlyParsedState};
1921
use crate::parser::{AllowExprMetavar, ArgParser, PathParser, RefPathParser};
2022
use crate::session_diagnostics::ParsedDescription;
21-
use crate::{Late, OmitDoc, ShouldEmit};
23+
use crate::{OmitDoc, ShouldEmit};
2224

2325
pub enum EmitAttribute {
2426
Static(AttributeLintKind),
@@ -344,7 +346,7 @@ impl<'sess> AttributeParser<'sess> {
344346
let parts =
345347
n.item.path.segments.iter().map(|seg| seg.ident.name).collect::<Vec<_>>();
346348

347-
if let Some(accept) = Late::parsers().accepters.get(parts.as_slice()) {
349+
if let Some(accept) = ATTRIBUTE_PARSERS.accepters.get(parts.as_slice()) {
348350
self.check_attribute_safety(
349351
&attr_path,
350352
lower_span(n.item.span()),
@@ -483,7 +485,7 @@ impl<'sess> AttributeParser<'sess> {
483485
&[sym::cfg_attr],
484486
];
485487

486-
Late::parsers().accepters.contains_key(path)
488+
ATTRIBUTE_PARSERS.accepters.contains_key(path)
487489
|| EARLY_PARSED_ATTRIBUTES.contains(&path)
488490
|| SPECIAL_ATTRIBUTES.contains(&path)
489491
}

compiler/rustc_attr_parsing/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub use attributes::cfg::{
112112
};
113113
pub use attributes::cfg_select::*;
114114
pub use attributes::util::{is_builtin_attr, parse_version};
115-
pub use context::{Early, Late, OmitDoc, ShouldEmit};
115+
pub use context::{OmitDoc, ShouldEmit};
116116
pub use interface::{AttributeParser, EmitAttribute};
117117
pub use rustc_parse::parser::Recovery;
118118
pub use session_diagnostics::ParsedDescription;

0 commit comments

Comments
 (0)