1
Fork 0

rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structures

This commit is contained in:
Jonathan Dönszelmann 2024-12-13 14:47:11 +01:00
parent 1341366af9
commit efb98b6552
No known key found for this signature in database
103 changed files with 481 additions and 395 deletions

View file

@ -3354,7 +3354,7 @@ dependencies = [
"itertools", "itertools",
"rustc_ast", "rustc_ast",
"rustc_ast_pretty", "rustc_ast_pretty",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_feature", "rustc_feature",
@ -3380,7 +3380,7 @@ dependencies = [
] ]
[[package]] [[package]]
name = "rustc_attr" name = "rustc_attr_data_structures"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"rustc_abi", "rustc_abi",
@ -3397,6 +3397,25 @@ dependencies = [
"rustc_span", "rustc_span",
] ]
[[package]]
name = "rustc_attr_parsing"
version = "0.0.0"
dependencies = [
"rustc_abi",
"rustc_ast",
"rustc_ast_pretty",
"rustc_attr_data_structures",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
"rustc_fluent_macro",
"rustc_lexer",
"rustc_macros",
"rustc_serialize",
"rustc_session",
"rustc_span",
]
[[package]] [[package]]
name = "rustc_baked_icu_data" name = "rustc_baked_icu_data"
version = "0.0.0" version = "0.0.0"
@ -3441,7 +3460,7 @@ version = "0.0.0"
dependencies = [ dependencies = [
"rustc_ast", "rustc_ast",
"rustc_ast_pretty", "rustc_ast_pretty",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_expand", "rustc_expand",
@ -3473,7 +3492,7 @@ dependencies = [
"rustc-demangle", "rustc-demangle",
"rustc_abi", "rustc_abi",
"rustc_ast", "rustc_ast",
"rustc_attr", "rustc_attr_parsing",
"rustc_codegen_ssa", "rustc_codegen_ssa",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
@ -3515,7 +3534,7 @@ dependencies = [
"rustc_arena", "rustc_arena",
"rustc_ast", "rustc_ast",
"rustc_ast_pretty", "rustc_ast_pretty",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_fluent_macro", "rustc_fluent_macro",
@ -3553,7 +3572,7 @@ dependencies = [
"rustc_abi", "rustc_abi",
"rustc_apfloat", "rustc_apfloat",
"rustc_ast", "rustc_ast",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_fluent_macro", "rustc_fluent_macro",
@ -3620,7 +3639,7 @@ dependencies = [
"rustc_ast_lowering", "rustc_ast_lowering",
"rustc_ast_passes", "rustc_ast_passes",
"rustc_ast_pretty", "rustc_ast_pretty",
"rustc_attr", "rustc_attr_parsing",
"rustc_borrowck", "rustc_borrowck",
"rustc_builtin_macros", "rustc_builtin_macros",
"rustc_codegen_ssa", "rustc_codegen_ssa",
@ -3724,7 +3743,7 @@ dependencies = [
"rustc_ast", "rustc_ast",
"rustc_ast_passes", "rustc_ast_passes",
"rustc_ast_pretty", "rustc_ast_pretty",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_feature", "rustc_feature",
@ -3799,7 +3818,7 @@ dependencies = [
"rustc_abi", "rustc_abi",
"rustc_arena", "rustc_arena",
"rustc_ast", "rustc_ast",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_feature", "rustc_feature",
@ -3838,7 +3857,7 @@ dependencies = [
"rustc_abi", "rustc_abi",
"rustc_ast", "rustc_ast",
"rustc_ast_ir", "rustc_ast_ir",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_fluent_macro", "rustc_fluent_macro",
@ -3927,7 +3946,7 @@ dependencies = [
"rustc_ast_lowering", "rustc_ast_lowering",
"rustc_ast_passes", "rustc_ast_passes",
"rustc_ast_pretty", "rustc_ast_pretty",
"rustc_attr", "rustc_attr_parsing",
"rustc_borrowck", "rustc_borrowck",
"rustc_builtin_macros", "rustc_builtin_macros",
"rustc_codegen_llvm", "rustc_codegen_llvm",
@ -3983,7 +4002,7 @@ dependencies = [
"rustc_abi", "rustc_abi",
"rustc_ast", "rustc_ast",
"rustc_ast_pretty", "rustc_ast_pretty",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_feature", "rustc_feature",
@ -4057,7 +4076,7 @@ dependencies = [
"odht", "odht",
"rustc_abi", "rustc_abi",
"rustc_ast", "rustc_ast",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_expand", "rustc_expand",
@ -4094,7 +4113,7 @@ dependencies = [
"rustc_arena", "rustc_arena",
"rustc_ast", "rustc_ast",
"rustc_ast_ir", "rustc_ast_ir",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_error_messages", "rustc_error_messages",
"rustc_errors", "rustc_errors",
@ -4173,7 +4192,7 @@ dependencies = [
"rustc_abi", "rustc_abi",
"rustc_arena", "rustc_arena",
"rustc_ast", "rustc_ast",
"rustc_attr", "rustc_attr_parsing",
"rustc_const_eval", "rustc_const_eval",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
@ -4199,7 +4218,7 @@ name = "rustc_monomorphize"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"rustc_abi", "rustc_abi",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_fluent_macro", "rustc_fluent_macro",
@ -4267,7 +4286,7 @@ dependencies = [
"rustc_abi", "rustc_abi",
"rustc_ast", "rustc_ast",
"rustc_ast_pretty", "rustc_ast_pretty",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_expand", "rustc_expand",
@ -4314,7 +4333,7 @@ name = "rustc_privacy"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"rustc_ast", "rustc_ast",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_fluent_macro", "rustc_fluent_macro",
@ -4378,7 +4397,7 @@ dependencies = [
"rustc_arena", "rustc_arena",
"rustc_ast", "rustc_ast",
"rustc_ast_pretty", "rustc_ast_pretty",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_expand", "rustc_expand",
@ -4535,7 +4554,7 @@ dependencies = [
"rustc_abi", "rustc_abi",
"rustc_ast", "rustc_ast",
"rustc_ast_ir", "rustc_ast_ir",
"rustc_attr", "rustc_attr_parsing",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_fluent_macro", "rustc_fluent_macro",

View file

@ -8,7 +8,7 @@ edition = "2021"
itertools = "0.12" itertools = "0.12"
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" } rustc_feature = { path = "../rustc_feature" }

View file

@ -342,7 +342,7 @@ impl<'a> AstValidator<'a> {
sym::forbid, sym::forbid,
sym::warn, sym::warn,
]; ];
!arr.contains(&attr.name_or_empty()) && rustc_attr::is_builtin_attr(*attr) !arr.contains(&attr.name_or_empty()) && rustc_attr_parsing::is_builtin_attr(*attr)
}) })
.for_each(|attr| { .for_each(|attr| {
if attr.is_doc_comment() { if attr.is_doc_comment() {

View file

@ -1,40 +0,0 @@
//! Centralized logic for parsing and validating all attributes used after HIR.
//!
//! History: Check out [#131229](https://github.com/rust-lang/rust/issues/131229).
//! There used to be only one definition of attributes in the compiler: `ast::Attribute`.
//! These were then parsed or validated or both in places distributed all over the compiler.
//!
//! Attributes are markers on items. Most are actually attribute-like proc-macros, and are expanded
//! but some remain as the built-in attributes to guide compilation.
//!
//! In this crate, syntactical attributes (sequences of tokens that look like
//! `#[something(something else)]`) are parsed into more semantic attributes, markers on items.
//! Multiple syntactic attributes might influence a single semantic attribute. For example,
//! `#[stable(...)]` and `#[unstable()]` cannot occur together, and both semantically define
//! a "stability". Stability defines an [`AttributeExtractor`](attributes::AttributeExtractor)
//! that recognizes both `#[stable()]` and `#[unstable()]` syntactic attributes, and at the end
//! produce a single [`ParsedAttributeKind::Stability`].
//!
//! FIXME(jdonszelmann): update devguide for best practices on attributes
//! FIXME(jdonszelmann): rename to `rustc_attr` in the future, integrating it into this crate.
//!
//! To define a new builtin, first add it
// tidy-alphabetical-start
#![allow(internal_features)]
#![doc(rust_logo)]
#![feature(let_chains)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
mod attributes;
mod session_diagnostics;
mod types;
pub use attributes::*;
pub(crate) use rustc_session::HashStableContext;
pub use types::*;
pub use util::{find_crate_name, is_builtin_attr, parse_version};
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View file

@ -1,5 +1,5 @@
[package] [package]
name = "rustc_attr" name = "rustc_attr_data_structures"
version = "0.0.0" version = "0.0.0"
edition = "2021" edition = "2021"

View file

@ -0,0 +1,106 @@
use rustc_abi::Align;
use rustc_ast as ast;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::{Span, Symbol};
use crate::RustcVersion;
#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
pub enum InlineAttr {
None,
Hint,
Always,
Never,
}
#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq, HashStable_Generic)]
pub enum InstructionSetAttr {
ArmA32,
ArmT32,
}
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
pub enum OptimizeAttr {
None,
Speed,
Size,
}
#[derive(Clone, Debug, Encodable, Decodable)]
pub enum DiagnosticAttribute {
// tidy-alphabetical-start
DoNotRecommend,
OnUnimplemented,
// tidy-alphabetical-end
}
#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone)]
pub enum ReprAttr {
ReprInt(IntType),
ReprRust,
ReprC,
ReprPacked(Align),
ReprSimd,
ReprTransparent,
ReprAlign(Align),
}
pub use ReprAttr::*;
pub enum TransparencyError {
UnknownTransparency(Symbol, Span),
MultipleTransparencyAttrs(Span, Span),
}
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
#[derive(Encodable, Decodable)]
pub enum IntType {
SignedInt(ast::IntTy),
UnsignedInt(ast::UintTy),
}
#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic)]
pub struct Deprecation {
pub since: DeprecatedSince,
/// The note to issue a reason.
pub note: Option<Symbol>,
/// A text snippet used to completely replace any use of the deprecated item in an expression.
///
/// This is currently unstable.
pub suggestion: Option<Symbol>,
}
/// Release in which an API is deprecated.
#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic)]
pub enum DeprecatedSince {
RustcVersion(RustcVersion),
/// Deprecated in the future ("to be determined").
Future,
/// `feature(staged_api)` is off. Deprecation versions outside the standard
/// library are allowed to be arbitrary strings, for better or worse.
NonStandard(Symbol),
/// Deprecation version is unspecified but optional.
Unspecified,
/// Failed to parse a deprecation version, or the deprecation version is
/// unspecified and required. An error has already been emitted.
Err,
}
impl Deprecation {
/// Whether an item marked with #[deprecated(since = "X")] is currently
/// deprecated (i.e., whether X is not greater than the current rustc
/// version).
pub fn is_in_effect(&self) -> bool {
match self.since {
DeprecatedSince::RustcVersion(since) => since <= RustcVersion::CURRENT,
DeprecatedSince::Future => false,
// The `since` field doesn't have semantic purpose without `#![staged_api]`.
DeprecatedSince::NonStandard(_) => true,
// Assume deprecation is in effect if "since" field is absent or invalid.
DeprecatedSince::Unspecified | DeprecatedSince::Err => true,
}
}
pub fn is_since_rustc_version(&self) -> bool {
matches!(self.since, DeprecatedSince::RustcVersion(_))
}
}

View file

@ -0,0 +1,16 @@
// tidy-alphabetical-start
#![allow(internal_features)]
#![doc(rust_logo)]
#![feature(let_chains)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
mod attributes;
mod stability;
mod version;
pub use attributes::*;
pub(crate) use rustc_session::HashStableContext;
pub use stability::*;
pub use version::*;

View file

@ -1,10 +1,9 @@
use std::num::NonZero; use std::num::NonZero;
use rustc_abi::Align; use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_ast as ast; use rustc_span::{Symbol, sym};
use rustc_macros::{Encodable, Decodable, HashStable_Generic};
use rustc_session::RustcVersion; use crate::RustcVersion;
use rustc_span::{sym, Span, Symbol};
/// The version placeholder that recently stabilized features contain inside the /// The version placeholder that recently stabilized features contain inside the
/// `since` field of the `#[stable]` attribute. /// `since` field of the `#[stable]` attribute.
@ -12,59 +11,6 @@ use rustc_span::{sym, Span, Symbol};
/// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591). /// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591).
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION"; pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
pub enum InlineAttr {
None,
Hint,
Always,
Never,
}
#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq, HashStable_Generic)]
pub enum InstructionSetAttr {
ArmA32,
ArmT32,
}
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
pub enum OptimizeAttr {
None,
Speed,
Size,
}
#[derive(Clone, Debug, Encodable, Decodable)]
pub enum DiagnosticAttribute {
// tidy-alphabetical-start
DoNotRecommend,
OnUnimplemented,
// tidy-alphabetical-end
}
#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone)]
pub enum ReprAttr {
ReprInt(IntType),
ReprRust,
ReprC,
ReprPacked(Align),
ReprSimd,
ReprTransparent,
ReprAlign(Align),
}
pub use ReprAttr::*;
pub enum TransparencyError {
UnknownTransparency(Symbol, Span),
MultipleTransparencyAttrs(Span, Span),
}
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
#[derive(Encodable, Decodable)]
pub enum IntType {
SignedInt(ast::IntTy),
UnsignedInt(ast::UintTy),
}
/// Represents the following attributes: /// Represents the following attributes:
/// ///
/// - `#[stable]` /// - `#[stable]`
@ -96,13 +42,30 @@ impl Stability {
pub struct ConstStability { pub struct ConstStability {
pub level: StabilityLevel, pub level: StabilityLevel,
pub feature: Symbol, pub feature: Symbol,
/// This is true iff the `const_stable_indirect` attribute is present.
pub const_stable_indirect: bool,
/// whether the function has a `#[rustc_promotable]` attribute /// whether the function has a `#[rustc_promotable]` attribute
pub promotable: bool, pub promotable: bool,
/// This is true iff the `const_stable_indirect` attribute is present.
pub const_stable_indirect: bool,
} }
impl ConstStability { impl ConstStability {
pub fn from_partial(
PartialConstStability { level, feature, promotable }: PartialConstStability,
const_stable_indirect: bool,
) -> Self {
Self { const_stable_indirect, level, feature, promotable }
}
/// The stability assigned to unmarked items when -Zforce-unstable-if-unmarked is set.
pub fn unmarked(const_stable_indirect: bool, regular_stab: Stability) -> Self {
Self {
feature: regular_stab.feature,
promotable: false,
level: regular_stab.level,
const_stable_indirect,
}
}
pub fn is_const_unstable(&self) -> bool { pub fn is_const_unstable(&self) -> bool {
self.level.is_unstable() self.level.is_unstable()
} }
@ -112,12 +75,25 @@ impl ConstStability {
} }
} }
/// Represents the `#[rustc_default_body_unstable]` attribute. /// Excludes `const_stable_indirect`. This is necessary because when `-Zforce-unstable-if-unmarked`
/// is set, we need to encode standalone `#[rustc_const_stable_indirect]` attributes
#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)] #[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[derive(HashStable_Generic)] #[derive(HashStable_Generic)]
pub struct DefaultBodyStability { pub struct PartialConstStability {
pub level: StabilityLevel, pub level: StabilityLevel,
pub feature: Symbol, pub feature: Symbol,
/// whether the function has a `#[rustc_promotable]` attribute
pub promotable: bool,
}
impl PartialConstStability {
pub fn is_const_unstable(&self) -> bool {
self.level.is_unstable()
}
pub fn is_const_stable(&self) -> bool {
self.level.is_stable()
}
} }
/// The available stability levels. /// The available stability levels.
@ -166,6 +142,7 @@ pub enum StabilityLevel {
#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, PartialOrd, Ord, Hash)] #[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, PartialOrd, Ord, Hash)]
#[derive(HashStable_Generic)] #[derive(HashStable_Generic)]
pub enum StableSince { pub enum StableSince {
/// also stores the original symbol for printing
Version(RustcVersion), Version(RustcVersion),
/// Stabilized in the upcoming version, whatever number that is. /// Stabilized in the upcoming version, whatever number that is.
Current, Current,
@ -196,8 +173,16 @@ pub enum UnstableReason {
Some(Symbol), Some(Symbol),
} }
/// Represents the `#[rustc_default_body_unstable]` attribute.
#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[derive(HashStable_Generic)]
pub struct DefaultBodyStability {
pub level: StabilityLevel,
pub feature: Symbol,
}
impl UnstableReason { impl UnstableReason {
pub(crate) fn from_opt_reason(reason: Option<Symbol>) -> Self { pub fn from_opt_reason(reason: Option<Symbol>) -> Self {
// UnstableReason::Default constructed manually // UnstableReason::Default constructed manually
match reason { match reason {
Some(r) => Self::Some(r), Some(r) => Self::Some(r),
@ -213,50 +198,3 @@ impl UnstableReason {
} }
} }
} }
#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic)]
pub struct Deprecation {
pub since: DeprecatedSince,
/// The note to issue a reason.
pub note: Option<Symbol>,
/// A text snippet used to completely replace any use of the deprecated item in an expression.
///
/// This is currently unstable.
pub suggestion: Option<Symbol>,
}
/// Release in which an API is deprecated.
#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic)]
pub enum DeprecatedSince {
RustcVersion(RustcVersion),
/// Deprecated in the future ("to be determined").
Future,
/// `feature(staged_api)` is off. Deprecation versions outside the standard
/// library are allowed to be arbitrary strings, for better or worse.
NonStandard(Symbol),
/// Deprecation version is unspecified but optional.
Unspecified,
/// Failed to parse a deprecation version, or the deprecation version is
/// unspecified and required. An error has already been emitted.
Err,
}
impl Deprecation {
/// Whether an item marked with #[deprecated(since = "X")] is currently
/// deprecated (i.e., whether X is not greater than the current rustc
/// version).
pub fn is_in_effect(&self) -> bool {
match self.since {
DeprecatedSince::RustcVersion(since) => since <= RustcVersion::CURRENT,
DeprecatedSince::Future => false,
// The `since` field doesn't have semantic purpose without `#![staged_api]`.
DeprecatedSince::NonStandard(_) => true,
// Assume deprecation is in effect if "since" field is absent or invalid.
DeprecatedSince::Unspecified | DeprecatedSince::Err => true,
}
}
pub fn is_since_rustc_version(&self) -> bool {
matches!(self.since, DeprecatedSince::RustcVersion(_))
}
}

View file

@ -1,7 +1,5 @@
use std::borrow::Cow;
use std::fmt::{self, Display}; use std::fmt::{self, Display};
use rustc_errors::IntoDiagArg;
use rustc_macros::{Decodable, Encodable, HashStable_Generic, current_rustc_version}; use rustc_macros::{Decodable, Encodable, HashStable_Generic, current_rustc_version};
#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
@ -21,9 +19,3 @@ impl Display for RustcVersion {
write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch) write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch)
} }
} }
impl IntoDiagArg for RustcVersion {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
rustc_errors::DiagArgValue::Str(Cow::Owned(self.to_string()))
}
}

View file

@ -0,0 +1,21 @@
[package]
name = "rustc_attr_parsing"
version = "0.0.0"
edition = "2021"
[dependencies]
# tidy-alphabetical-start
rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_lexer = { path = "../rustc_lexer" }
rustc_macros = { path = "../rustc_macros" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
# tidy-alphabetical-end

View file

@ -1,46 +1,46 @@
attr_cfg_predicate_identifier = attr_parsing_cfg_predicate_identifier =
`cfg` predicate key must be an identifier `cfg` predicate key must be an identifier
attr_deprecated_item_suggestion = attr_parsing_deprecated_item_suggestion =
suggestions on deprecated items are unstable suggestions on deprecated items are unstable
.help = add `#![feature(deprecated_suggestion)]` to the crate root .help = add `#![feature(deprecated_suggestion)]` to the crate root
.note = see #94785 for more details .note = see #94785 for more details
attr_expected_one_cfg_pattern = attr_parsing_expected_one_cfg_pattern =
expected 1 cfg-pattern expected 1 cfg-pattern
attr_expected_single_version_literal = attr_parsing_expected_single_version_literal =
expected single version literal expected single version literal
attr_expected_version_literal = attr_parsing_expected_version_literal =
expected a version literal expected a version literal
attr_expects_feature_list = attr_parsing_expects_feature_list =
`{$name}` expects a list of feature names `{$name}` expects a list of feature names
attr_expects_features = attr_parsing_expects_features =
`{$name}` expects feature names `{$name}` expects feature names
attr_incorrect_meta_item = attr_parsing_incorrect_meta_item =
incorrect meta item incorrect meta item
attr_incorrect_repr_format_align_one_arg = attr_parsing_incorrect_repr_format_align_one_arg =
incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
attr_incorrect_repr_format_expect_literal_integer = attr_parsing_incorrect_repr_format_expect_literal_integer =
incorrect `repr(align)` attribute format: `align` expects a literal integer as argument incorrect `repr(align)` attribute format: `align` expects a literal integer as argument
attr_incorrect_repr_format_generic = attr_parsing_incorrect_repr_format_generic =
incorrect `repr({$repr_arg})` attribute format incorrect `repr({$repr_arg})` attribute format
.suggestion = use parentheses instead .suggestion = use parentheses instead
attr_incorrect_repr_format_packed_expect_integer = attr_parsing_incorrect_repr_format_packed_expect_integer =
incorrect `repr(packed)` attribute format: `packed` expects a literal integer as argument incorrect `repr(packed)` attribute format: `packed` expects a literal integer as argument
attr_incorrect_repr_format_packed_one_or_zero_arg = attr_parsing_incorrect_repr_format_packed_one_or_zero_arg =
incorrect `repr(packed)` attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all incorrect `repr(packed)` attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all
attr_invalid_issue_string = attr_parsing_invalid_issue_string =
`issue` must be a non-zero numeric string or "none" `issue` must be a non-zero numeric string or "none"
.must_not_be_zero = `issue` must not be "0", use "none" instead .must_not_be_zero = `issue` must not be "0", use "none" instead
.empty = cannot parse integer from empty string .empty = cannot parse integer from empty string
@ -48,77 +48,77 @@ attr_invalid_issue_string =
.pos_overflow = number too large to fit in target type .pos_overflow = number too large to fit in target type
.neg_overflow = number too small to fit in target type .neg_overflow = number too small to fit in target type
attr_invalid_predicate = attr_parsing_invalid_predicate =
invalid predicate `{$predicate}` invalid predicate `{$predicate}`
attr_invalid_repr_align_need_arg = attr_parsing_invalid_repr_align_need_arg =
invalid `repr(align)` attribute: `align` needs an argument invalid `repr(align)` attribute: `align` needs an argument
.suggestion = supply an argument here .suggestion = supply an argument here
attr_invalid_repr_generic = attr_parsing_invalid_repr_generic =
invalid `repr({$repr_arg})` attribute: {$error_part} invalid `repr({$repr_arg})` attribute: {$error_part}
attr_invalid_repr_hint_no_paren = attr_parsing_invalid_repr_hint_no_paren =
invalid representation hint: `{$name}` does not take a parenthesized argument list invalid representation hint: `{$name}` does not take a parenthesized argument list
attr_invalid_repr_hint_no_value = attr_parsing_invalid_repr_hint_no_value =
invalid representation hint: `{$name}` does not take a value invalid representation hint: `{$name}` does not take a value
attr_invalid_since = attr_parsing_invalid_since =
'since' must be a Rust version number, such as "1.31.0" 'since' must be a Rust version number, such as "1.31.0"
attr_missing_feature = attr_parsing_missing_feature =
missing 'feature' missing 'feature'
attr_missing_issue = attr_parsing_missing_issue =
missing 'issue' missing 'issue'
attr_missing_note = attr_parsing_missing_note =
missing 'note' missing 'note'
attr_missing_since = attr_parsing_missing_since =
missing 'since' missing 'since'
attr_multiple_item = attr_parsing_multiple_item =
multiple '{$item}' items multiple '{$item}' items
attr_multiple_stability_levels = attr_parsing_multiple_stability_levels =
multiple stability levels multiple stability levels
attr_non_ident_feature = attr_parsing_non_ident_feature =
'feature' is not an identifier 'feature' is not an identifier
attr_rustc_allowed_unstable_pairing = attr_parsing_rustc_allowed_unstable_pairing =
`rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute
attr_rustc_const_stable_indirect_pairing = attr_parsing_rustc_const_stable_indirect_pairing =
`const_stable_indirect` attribute does not make sense on `rustc_const_stable` function, its behavior is already implied `const_stable_indirect` attribute does not make sense on `rustc_const_stable` function, its behavior is already implied
attr_rustc_promotable_pairing = attr_parsing_rustc_promotable_pairing =
`rustc_promotable` attribute must be paired with either a `rustc_const_unstable` or a `rustc_const_stable` attribute `rustc_promotable` attribute must be paired with either a `rustc_const_unstable` or a `rustc_const_stable` attribute
attr_soft_no_args = attr_parsing_soft_no_args =
`soft` should not have any arguments `soft` should not have any arguments
attr_unknown_meta_item = attr_parsing_unknown_meta_item =
unknown meta item '{$item}' unknown meta item '{$item}'
.label = expected one of {$expected} .label = expected one of {$expected}
attr_unknown_version_literal = attr_parsing_unknown_version_literal =
unknown version literal format, assuming it refers to a future version unknown version literal format, assuming it refers to a future version
attr_unstable_cfg_target_compact = attr_parsing_unstable_cfg_target_compact =
compact `cfg(target(..))` is experimental and subject to change compact `cfg(target(..))` is experimental and subject to change
attr_unsupported_literal_cfg_boolean = attr_parsing_unsupported_literal_cfg_boolean =
literal in `cfg` predicate value must be a boolean literal in `cfg` predicate value must be a boolean
attr_unsupported_literal_cfg_string = attr_parsing_unsupported_literal_cfg_string =
literal in `cfg` predicate value must be a string literal in `cfg` predicate value must be a string
attr_unsupported_literal_deprecated_kv_pair = attr_parsing_unsupported_literal_deprecated_kv_pair =
item in `deprecated` must be a key/value pair item in `deprecated` must be a key/value pair
attr_unsupported_literal_deprecated_string = attr_parsing_unsupported_literal_deprecated_string =
literal in `deprecated` value must be a string literal in `deprecated` value must be a string
attr_unsupported_literal_generic = attr_parsing_unsupported_literal_generic =
unsupported literal unsupported literal
attr_unsupported_literal_suggestion = attr_parsing_unsupported_literal_suggestion =
consider removing the prefix consider removing the prefix

View file

@ -2,8 +2,8 @@
use rustc_ast::{self as ast, LitKind, MetaItem, MetaItemInner, MetaItemKind, MetaItemLit, NodeId}; use rustc_ast::{self as ast, LitKind, MetaItem, MetaItemInner, MetaItemKind, MetaItemLit, NodeId};
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_attr_data_structures::RustcVersion;
use rustc_feature::{Features, GatedCfg, find_gated_cfg}; use rustc_feature::{Features, GatedCfg, find_gated_cfg};
use rustc_session::RustcVersion;
use rustc_session::Session; use rustc_session::Session;
use rustc_session::config::ExpectedValues; use rustc_session::config::ExpectedValues;
use rustc_session::lint::BuiltinLintDiag; use rustc_session::lint::BuiltinLintDiag;
@ -12,9 +12,8 @@ use rustc_session::parse::feature_err;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Symbol, kw, sym}; use rustc_span::symbol::{Symbol, kw, sym};
use crate::{fluent_generated, parse_version};
use crate::session_diagnostics;
use crate::util::UnsupportedLiteralReason; use crate::util::UnsupportedLiteralReason;
use crate::{fluent_generated, parse_version, session_diagnostics};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Condition { pub struct Condition {
@ -194,7 +193,7 @@ pub fn eval_condition(
sess, sess,
sym::cfg_target_compact, sym::cfg_target_compact,
cfg.span, cfg.span,
fluent_generated::attr_unstable_cfg_target_compact, fluent_generated::attr_parsing_unstable_cfg_target_compact,
) )
.emit(); .emit();
} }

View file

@ -1,10 +1,9 @@
//! Parsing and validation of builtin attributes //! Parsing and validation of builtin attributes
use rustc_ast::attr::AttributeExt;
use rustc_ast::MetaItemInner; use rustc_ast::MetaItemInner;
use rustc_ast::attr::AttributeExt;
use rustc_span::symbol::Symbol; use rustc_span::symbol::Symbol;
/// Read the content of a `rustc_confusables` attribute, and return the list of candidate names. /// Read the content of a `rustc_confusables` attribute, and return the list of candidate names.
pub fn parse_confusables(attr: &impl AttributeExt) -> Option<Vec<Symbol>> { pub fn parse_confusables(attr: &impl AttributeExt) -> Option<Vec<Symbol>> {
let metas = attr.meta_item_list()?; let metas = attr.meta_item_list()?;

View file

@ -1,16 +1,16 @@
//! Parsing and validation of builtin attributes //! Parsing and validation of builtin attributes
use rustc_ast::attr::AttributeExt; use rustc_ast::attr::AttributeExt;
use rustc_ast::{MetaItemInner, MetaItem}; use rustc_ast::{MetaItem, MetaItemInner};
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_attr_data_structures::{DeprecatedSince, Deprecation};
use rustc_feature::Features; use rustc_feature::Features;
use crate::types::{DeprecatedSince, Deprecation};
use rustc_session::Session; use rustc_session::Session;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Symbol, sym}; use rustc_span::symbol::{Symbol, sym};
use crate::{parse_version, session_diagnostics};
use super::util::UnsupportedLiteralReason; use super::util::UnsupportedLiteralReason;
use crate::{parse_version, session_diagnostics};
/// Finds the deprecation attribute. `None` if none exists. /// Finds the deprecation attribute. `None` if none exists.
pub fn find_deprecation( pub fn find_deprecation(

View file

@ -3,14 +3,13 @@
use rustc_abi::Align; use rustc_abi::Align;
use rustc_ast::attr::AttributeExt; use rustc_ast::attr::AttributeExt;
use rustc_ast::{self as ast, MetaItemKind}; use rustc_ast::{self as ast, MetaItemKind};
use crate::types::{ use rustc_attr_data_structures::IntType;
IntType, ReprAttr::*, use rustc_attr_data_structures::ReprAttr::*;
};
use crate::ReprAttr;
use rustc_session::Session; use rustc_session::Session;
use rustc_span::symbol::{Symbol, sym}; use rustc_span::symbol::{Symbol, sym};
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
use crate::ReprAttr;
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
/// Parse #[repr(...)] forms. /// Parse #[repr(...)] forms.
/// ///
@ -177,7 +176,7 @@ pub fn parse_repr_attr(sess: &Session, attr: &impl AttributeExt) -> Vec<ReprAttr
} }
fn int_type_of_word(s: Symbol) -> Option<IntType> { fn int_type_of_word(s: Symbol) -> Option<IntType> {
use crate::types::IntType::*; use rustc_attr_data_structures::IntType::*;
match s { match s {
sym::i8 => Some(SignedInt(ast::IntTy::I8)), sym::i8 => Some(SignedInt(ast::IntTy::I8)),

View file

@ -2,20 +2,20 @@
use std::num::NonZero; use std::num::NonZero;
use rustc_ast::attr::AttributeExt;
use rustc_ast::MetaItem; use rustc_ast::MetaItem;
use rustc_ast::attr::AttributeExt;
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_errors::ErrorGuaranteed; use rustc_attr_data_structures::{
use crate::types::{ ConstStability, DefaultBodyStability, Stability, StabilityLevel, StableSince, UnstableReason,
ConstStability, DefaultBodyStability, VERSION_PLACEHOLDER,
Stability, StabilityLevel, StableSince, UnstableReason, VERSION_PLACEHOLDER,
}; };
use rustc_errors::ErrorGuaranteed;
use rustc_session::Session; use rustc_session::Session;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Symbol, sym}; use rustc_span::symbol::{Symbol, sym};
use crate::{parse_version, session_diagnostics};
use crate::attributes::util::UnsupportedLiteralReason; use crate::attributes::util::UnsupportedLiteralReason;
use crate::{parse_version, session_diagnostics};
/// Collects stability info from `stable`/`unstable`/`rustc_allowed_through_unstable_modules` /// Collects stability info from `stable`/`unstable`/`rustc_allowed_through_unstable_modules`
/// attributes in `attrs`. Returns `None` if no stability attributes are found. /// attributes in `attrs`. Returns `None` if no stability attributes are found.

View file

@ -1,6 +1,7 @@
use rustc_ast::attr::AttributeExt; use rustc_ast::attr::AttributeExt;
use crate::types::TransparencyError; use rustc_attr_data_structures::TransparencyError;
use rustc_span::{hygiene::Transparency, sym}; use rustc_span::hygiene::Transparency;
use rustc_span::sym;
pub fn find_transparency( pub fn find_transparency(
attrs: &[impl AttributeExt], attrs: &[impl AttributeExt],

View file

@ -1,6 +1,6 @@
use rustc_ast::attr::{AttributeExt, first_attr_value_str_by_name}; use rustc_ast::attr::{AttributeExt, first_attr_value_str_by_name};
use rustc_attr_data_structures::RustcVersion;
use rustc_feature::is_builtin_attr_name; use rustc_feature::is_builtin_attr_name;
use rustc_session::RustcVersion;
use rustc_span::symbol::{Symbol, sym}; use rustc_span::symbol::{Symbol, sym};
pub(crate) enum UnsupportedLiteralReason { pub(crate) enum UnsupportedLiteralReason {

View file

@ -0,0 +1,22 @@
//! Functions and types dealing with attributes and meta items.
//!
//! FIXME(Centril): For now being, much of the logic is still in `rustc_ast::attr`.
//! The goal is to move the definition of `MetaItem` and things that don't need to be in `syntax`
//! to this crate.
// tidy-alphabetical-start
#![allow(internal_features)]
#![doc(rust_logo)]
#![feature(let_chains)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
mod attributes;
mod session_diagnostics;
pub use attributes::*;
pub use rustc_attr_data_structures::*;
pub use util::{find_crate_name, is_builtin_attr, parse_version};
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View file

@ -10,14 +10,14 @@ use crate::attributes::util::UnsupportedLiteralReason;
use crate::fluent_generated as fluent; use crate::fluent_generated as fluent;
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_expected_one_cfg_pattern, code = E0536)] #[diag(attr_parsing_expected_one_cfg_pattern, code = E0536)]
pub(crate) struct ExpectedOneCfgPattern { pub(crate) struct ExpectedOneCfgPattern {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_invalid_predicate, code = E0537)] #[diag(attr_parsing_invalid_predicate, code = E0537)]
pub(crate) struct InvalidPredicate { pub(crate) struct InvalidPredicate {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -26,7 +26,7 @@ pub(crate) struct InvalidPredicate {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_multiple_item, code = E0538)] #[diag(attr_parsing_multiple_item, code = E0538)]
pub(crate) struct MultipleItem { pub(crate) struct MultipleItem {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -35,7 +35,7 @@ pub(crate) struct MultipleItem {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_incorrect_meta_item, code = E0539)] #[diag(attr_parsing_incorrect_meta_item, code = E0539)]
pub(crate) struct IncorrectMetaItem { pub(crate) struct IncorrectMetaItem {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -52,38 +52,38 @@ pub(crate) struct UnknownMetaItem<'a> {
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnknownMetaItem<'_> { impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnknownMetaItem<'_> {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>(); let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
Diag::new(dcx, level, fluent::attr_unknown_meta_item) Diag::new(dcx, level, fluent::attr_parsing_unknown_meta_item)
.with_span(self.span) .with_span(self.span)
.with_code(E0541) .with_code(E0541)
.with_arg("item", self.item) .with_arg("item", self.item)
.with_arg("expected", expected.join(", ")) .with_arg("expected", expected.join(", "))
.with_span_label(self.span, fluent::attr_label) .with_span_label(self.span, fluent::attr_parsing_label)
} }
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_missing_since, code = E0542)] #[diag(attr_parsing_missing_since, code = E0542)]
pub(crate) struct MissingSince { pub(crate) struct MissingSince {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_missing_note, code = E0543)] #[diag(attr_parsing_missing_note, code = E0543)]
pub(crate) struct MissingNote { pub(crate) struct MissingNote {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_multiple_stability_levels, code = E0544)] #[diag(attr_parsing_multiple_stability_levels, code = E0544)]
pub(crate) struct MultipleStabilityLevels { pub(crate) struct MultipleStabilityLevels {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_invalid_issue_string, code = E0545)] #[diag(attr_parsing_invalid_issue_string, code = E0545)]
pub(crate) struct InvalidIssueString { pub(crate) struct InvalidIssueString {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -96,31 +96,31 @@ pub(crate) struct InvalidIssueString {
// translatable. // translatable.
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum InvalidIssueStringCause { pub(crate) enum InvalidIssueStringCause {
#[label(attr_must_not_be_zero)] #[label(attr_parsing_must_not_be_zero)]
MustNotBeZero { MustNotBeZero {
#[primary_span] #[primary_span]
span: Span, span: Span,
}, },
#[label(attr_empty)] #[label(attr_parsing_empty)]
Empty { Empty {
#[primary_span] #[primary_span]
span: Span, span: Span,
}, },
#[label(attr_invalid_digit)] #[label(attr_parsing_invalid_digit)]
InvalidDigit { InvalidDigit {
#[primary_span] #[primary_span]
span: Span, span: Span,
}, },
#[label(attr_pos_overflow)] #[label(attr_parsing_pos_overflow)]
PosOverflow { PosOverflow {
#[primary_span] #[primary_span]
span: Span, span: Span,
}, },
#[label(attr_neg_overflow)] #[label(attr_parsing_neg_overflow)]
NegOverflow { NegOverflow {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -141,21 +141,21 @@ impl InvalidIssueStringCause {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_missing_feature, code = E0546)] #[diag(attr_parsing_missing_feature, code = E0546)]
pub(crate) struct MissingFeature { pub(crate) struct MissingFeature {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_non_ident_feature, code = E0546)] #[diag(attr_parsing_non_ident_feature, code = E0546)]
pub(crate) struct NonIdentFeature { pub(crate) struct NonIdentFeature {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_missing_issue, code = E0547)] #[diag(attr_parsing_missing_issue, code = E0547)]
pub(crate) struct MissingIssue { pub(crate) struct MissingIssue {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -164,20 +164,20 @@ pub(crate) struct MissingIssue {
// FIXME: Why is this the same error code as `InvalidReprHintNoParen` and `InvalidReprHintNoValue`? // FIXME: Why is this the same error code as `InvalidReprHintNoParen` and `InvalidReprHintNoValue`?
// It is more similar to `IncorrectReprFormatGeneric`. // It is more similar to `IncorrectReprFormatGeneric`.
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_incorrect_repr_format_packed_one_or_zero_arg, code = E0552)] #[diag(attr_parsing_incorrect_repr_format_packed_one_or_zero_arg, code = E0552)]
pub(crate) struct IncorrectReprFormatPackedOneOrZeroArg { pub(crate) struct IncorrectReprFormatPackedOneOrZeroArg {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_incorrect_repr_format_packed_expect_integer, code = E0552)] #[diag(attr_parsing_incorrect_repr_format_packed_expect_integer, code = E0552)]
pub(crate) struct IncorrectReprFormatPackedExpectInteger { pub(crate) struct IncorrectReprFormatPackedExpectInteger {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_invalid_repr_hint_no_paren, code = E0552)] #[diag(attr_parsing_invalid_repr_hint_no_paren, code = E0552)]
pub(crate) struct InvalidReprHintNoParen { pub(crate) struct InvalidReprHintNoParen {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -186,7 +186,7 @@ pub(crate) struct InvalidReprHintNoParen {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_invalid_repr_hint_no_value, code = E0552)] #[diag(attr_parsing_invalid_repr_hint_no_value, code = E0552)]
pub(crate) struct InvalidReprHintNoValue { pub(crate) struct InvalidReprHintNoValue {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -205,14 +205,18 @@ pub(crate) struct UnsupportedLiteral {
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral { impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
let mut diag = Diag::new(dcx, level, match self.reason { let mut diag = Diag::new(dcx, level, match self.reason {
UnsupportedLiteralReason::Generic => fluent::attr_unsupported_literal_generic, UnsupportedLiteralReason::Generic => fluent::attr_parsing_unsupported_literal_generic,
UnsupportedLiteralReason::CfgString => fluent::attr_unsupported_literal_cfg_string, UnsupportedLiteralReason::CfgString => {
UnsupportedLiteralReason::CfgBoolean => fluent::attr_unsupported_literal_cfg_boolean, fluent::attr_parsing_unsupported_literal_cfg_string
}
UnsupportedLiteralReason::CfgBoolean => {
fluent::attr_parsing_unsupported_literal_cfg_boolean
}
UnsupportedLiteralReason::DeprecatedString => { UnsupportedLiteralReason::DeprecatedString => {
fluent::attr_unsupported_literal_deprecated_string fluent::attr_parsing_unsupported_literal_deprecated_string
} }
UnsupportedLiteralReason::DeprecatedKvPair => { UnsupportedLiteralReason::DeprecatedKvPair => {
fluent::attr_unsupported_literal_deprecated_kv_pair fluent::attr_parsing_unsupported_literal_deprecated_kv_pair
} }
}); });
diag.span(self.span); diag.span(self.span);
@ -220,7 +224,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral {
if self.is_bytestr { if self.is_bytestr {
diag.span_suggestion( diag.span_suggestion(
self.start_point_span, self.start_point_span,
fluent::attr_unsupported_literal_suggestion, fluent::attr_parsing_unsupported_literal_suggestion,
"", "",
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
@ -230,7 +234,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_invalid_repr_align_need_arg, code = E0589)] #[diag(attr_parsing_invalid_repr_align_need_arg, code = E0589)]
pub(crate) struct InvalidReprAlignNeedArg { pub(crate) struct InvalidReprAlignNeedArg {
#[primary_span] #[primary_span]
#[suggestion(code = "align(...)", applicability = "has-placeholders")] #[suggestion(code = "align(...)", applicability = "has-placeholders")]
@ -238,7 +242,7 @@ pub(crate) struct InvalidReprAlignNeedArg {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_invalid_repr_generic, code = E0589)] #[diag(attr_parsing_invalid_repr_generic, code = E0589)]
pub(crate) struct InvalidReprGeneric<'a> { pub(crate) struct InvalidReprGeneric<'a> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -248,21 +252,21 @@ pub(crate) struct InvalidReprGeneric<'a> {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_incorrect_repr_format_align_one_arg, code = E0693)] #[diag(attr_parsing_incorrect_repr_format_align_one_arg, code = E0693)]
pub(crate) struct IncorrectReprFormatAlignOneArg { pub(crate) struct IncorrectReprFormatAlignOneArg {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_incorrect_repr_format_expect_literal_integer, code = E0693)] #[diag(attr_parsing_incorrect_repr_format_expect_literal_integer, code = E0693)]
pub(crate) struct IncorrectReprFormatExpectInteger { pub(crate) struct IncorrectReprFormatExpectInteger {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_incorrect_repr_format_generic, code = E0693)] #[diag(attr_parsing_incorrect_repr_format_generic, code = E0693)]
pub(crate) struct IncorrectReprFormatGeneric<'a> { pub(crate) struct IncorrectReprFormatGeneric<'a> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -275,7 +279,11 @@ pub(crate) struct IncorrectReprFormatGeneric<'a> {
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]
pub(crate) enum IncorrectReprFormatGenericCause<'a> { pub(crate) enum IncorrectReprFormatGenericCause<'a> {
#[suggestion(attr_suggestion, code = "{name}({int})", applicability = "machine-applicable")] #[suggestion(
attr_parsing_suggestion,
code = "{name}({int})",
applicability = "machine-applicable"
)]
Int { Int {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -287,7 +295,11 @@ pub(crate) enum IncorrectReprFormatGenericCause<'a> {
int: u128, int: u128,
}, },
#[suggestion(attr_suggestion, code = "{name}({symbol})", applicability = "machine-applicable")] #[suggestion(
attr_parsing_suggestion,
code = "{name}({symbol})",
applicability = "machine-applicable"
)]
Symbol { Symbol {
#[primary_span] #[primary_span]
span: Span, span: Span,
@ -313,35 +325,35 @@ impl<'a> IncorrectReprFormatGenericCause<'a> {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_rustc_promotable_pairing, code = E0717)] #[diag(attr_parsing_rustc_promotable_pairing, code = E0717)]
pub(crate) struct RustcPromotablePairing { pub(crate) struct RustcPromotablePairing {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_rustc_const_stable_indirect_pairing)] #[diag(attr_parsing_rustc_const_stable_indirect_pairing)]
pub(crate) struct RustcConstStableIndirectPairing { pub(crate) struct RustcConstStableIndirectPairing {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_rustc_allowed_unstable_pairing, code = E0789)] #[diag(attr_parsing_rustc_allowed_unstable_pairing, code = E0789)]
pub(crate) struct RustcAllowedUnstablePairing { pub(crate) struct RustcAllowedUnstablePairing {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_cfg_predicate_identifier)] #[diag(attr_parsing_cfg_predicate_identifier)]
pub(crate) struct CfgPredicateIdentifier { pub(crate) struct CfgPredicateIdentifier {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_deprecated_item_suggestion)] #[diag(attr_parsing_deprecated_item_suggestion)]
pub(crate) struct DeprecatedItemSuggestion { pub(crate) struct DeprecatedItemSuggestion {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -354,21 +366,21 @@ pub(crate) struct DeprecatedItemSuggestion {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_expected_single_version_literal)] #[diag(attr_parsing_expected_single_version_literal)]
pub(crate) struct ExpectedSingleVersionLiteral { pub(crate) struct ExpectedSingleVersionLiteral {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_expected_version_literal)] #[diag(attr_parsing_expected_version_literal)]
pub(crate) struct ExpectedVersionLiteral { pub(crate) struct ExpectedVersionLiteral {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_expects_feature_list)] #[diag(attr_parsing_expects_feature_list)]
pub(crate) struct ExpectsFeatureList { pub(crate) struct ExpectsFeatureList {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -377,7 +389,7 @@ pub(crate) struct ExpectsFeatureList {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_expects_features)] #[diag(attr_parsing_expects_features)]
pub(crate) struct ExpectsFeatures { pub(crate) struct ExpectsFeatures {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
@ -386,21 +398,21 @@ pub(crate) struct ExpectsFeatures {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_invalid_since)] #[diag(attr_parsing_invalid_since)]
pub(crate) struct InvalidSince { pub(crate) struct InvalidSince {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_soft_no_args)] #[diag(attr_parsing_soft_no_args)]
pub(crate) struct SoftNoArgs { pub(crate) struct SoftNoArgs {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_unknown_version_literal)] #[diag(attr_parsing_unknown_version_literal)]
pub(crate) struct UnknownVersionLiteral { pub(crate) struct UnknownVersionLiteral {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,

View file

@ -14,7 +14,7 @@ doctest = false
# tidy-alphabetical-start # tidy-alphabetical-start
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_expand = { path = "../rustc_expand" } rustc_expand = { path = "../rustc_expand" }

View file

@ -7,7 +7,7 @@ use rustc_ast::tokenstream::TokenStream;
use rustc_errors::PResult; use rustc_errors::PResult;
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult}; use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_span::Span; use rustc_span::Span;
use {rustc_ast as ast, rustc_attr as attr}; use {rustc_ast as ast, rustc_attr_parsing as attr};
use crate::errors; use crate::errors;

View file

@ -6,7 +6,7 @@ use rustc_ast::{
self as ast, GenericArg, GenericBound, GenericParamKind, ItemKind, MetaItem, self as ast, GenericArg, GenericBound, GenericParamKind, ItemKind, MetaItem,
TraitBoundModifiers, VariantData, WherePredicate, TraitBoundModifiers, VariantData, WherePredicate,
}; };
use rustc_attr as attr; use rustc_attr_parsing as attr;
use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_macros::Diagnostic; use rustc_macros::Diagnostic;

View file

@ -185,7 +185,7 @@ use rustc_ast::{
self as ast, AnonConst, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind, self as ast, AnonConst, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind,
Generics, Mutability, PatKind, VariantData, Generics, Mutability, PatKind, VariantData,
}; };
use rustc_attr as attr; use rustc_attr_parsing as attr;
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{Ident, Symbol, kw, sym}; use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, Span}; use rustc_span::{DUMMY_SP, Span};

View file

@ -2,8 +2,8 @@
use gccjit::FnAttribute; use gccjit::FnAttribute;
use gccjit::Function; use gccjit::Function;
#[cfg(feature = "master")] #[cfg(feature = "master")]
use rustc_attr::InlineAttr; use rustc_attr_parsing::InlineAttr;
use rustc_attr::InstructionSetAttr; use rustc_attr_parsing::InstructionSetAttr;
#[cfg(feature = "master")] #[cfg(feature = "master")]
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::ty; use rustc_middle::ty;

View file

@ -35,7 +35,7 @@ extern crate tracing;
extern crate rustc_abi; extern crate rustc_abi;
extern crate rustc_apfloat; extern crate rustc_apfloat;
extern crate rustc_ast; extern crate rustc_ast;
extern crate rustc_attr; extern crate rustc_attr_parsing;
extern crate rustc_codegen_ssa; extern crate rustc_codegen_ssa;
extern crate rustc_data_structures; extern crate rustc_data_structures;
extern crate rustc_errors; extern crate rustc_errors;

View file

@ -16,7 +16,7 @@ object = { version = "0.36.3", default-features = false, features = ["std", "rea
rustc-demangle = "0.1.21" rustc-demangle = "0.1.21"
rustc_abi = { path = "../rustc_abi" } rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" } rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }

View file

@ -1,6 +1,6 @@
//! Set and unset common attributes on LLVM values. //! Set and unset common attributes on LLVM values.
use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr}; use rustc_attr_parsing::{InlineAttr, InstructionSetAttr, OptimizeAttr};
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFunctionEntry}; use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFunctionEntry};

View file

@ -106,7 +106,7 @@ pub(crate) fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'t
// This is a monomorphization of a generic function. // This is a monomorphization of a generic function.
if !(cx.tcx.sess.opts.share_generics() if !(cx.tcx.sess.opts.share_generics()
|| tcx.codegen_fn_attrs(instance_def_id).inline || tcx.codegen_fn_attrs(instance_def_id).inline
== rustc_attr::InlineAttr::Never) == rustc_attr_parsing::InlineAttr::Never)
{ {
// When not sharing generics, all instances are in the same // When not sharing generics, all instances are in the same
// crate and have hidden visibility. // crate and have hidden visibility.

View file

@ -17,7 +17,7 @@ rustc_abi = { path = "../rustc_abi" }
rustc_arena = { path = "../rustc_arena" } rustc_arena = { path = "../rustc_arena" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }

View file

@ -2982,7 +2982,7 @@ fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) {
fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool { fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
match lib.cfg { match lib.cfg {
Some(ref cfg) => rustc_attr::cfg_matches(cfg, sess, CRATE_NODE_ID, None), Some(ref cfg) => rustc_attr_parsing::cfg_matches(cfg, sess, CRATE_NODE_ID, None),
None => true, None => true,
} }
} }

View file

@ -311,7 +311,8 @@ fn exported_symbols_provider_local(
} }
if !tcx.sess.opts.share_generics() { if !tcx.sess.opts.share_generics() {
if tcx.codegen_fn_attrs(mono_item.def_id()).inline == rustc_attr::InlineAttr::Never if tcx.codegen_fn_attrs(mono_item.def_id()).inline
== rustc_attr_parsing::InlineAttr::Never
{ {
// this is OK, we explicitly allow sharing inline(never) across crates even // this is OK, we explicitly allow sharing inline(never) across crates even
// without share-generics. // without share-generics.

View file

@ -30,7 +30,7 @@ use rustc_trait_selection::infer::at::ToTrace;
use rustc_trait_selection::infer::{BoundRegionConversionTime, TyCtxtInferExt}; use rustc_trait_selection::infer::{BoundRegionConversionTime, TyCtxtInferExt};
use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt}; use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt};
use tracing::{debug, info}; use tracing::{debug, info};
use {rustc_ast as ast, rustc_attr as attr}; use {rustc_ast as ast, rustc_attr_parsing as attr};
use crate::assert_module_sources::CguReuse; use crate::assert_module_sources::CguReuse;
use crate::back::link::are_upstream_rust_objects_already_included; use crate::back::link::are_upstream_rust_objects_already_included;

View file

@ -1,6 +1,6 @@
use rustc_ast::attr::list_contains_name; use rustc_ast::attr::list_contains_name;
use rustc_ast::{MetaItemInner, attr}; use rustc_ast::{MetaItemInner, attr};
use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr}; use rustc_attr_parsing::{InlineAttr, InstructionSetAttr, OptimizeAttr};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_errors::codes::*; use rustc_errors::codes::*;
use rustc_errors::{DiagMessage, SubdiagMessage, struct_span_code_err}; use rustc_errors::{DiagMessage, SubdiagMessage, struct_span_code_err};
@ -426,7 +426,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
&& let [item] = items.as_slice() && let [item] = items.as_slice()
&& let Some((sym::align, literal)) = item.singleton_lit_list() && let Some((sym::align, literal)) = item.singleton_lit_list()
{ {
rustc_attr::parse_alignment(&literal.kind) rustc_attr_parsing::parse_alignment(&literal.kind)
.map_err(|msg| { .map_err(|msg| {
struct_span_code_err!( struct_span_code_err!(
tcx.dcx(), tcx.dcx(),

View file

@ -1,4 +1,4 @@
use rustc_attr::InstructionSetAttr; use rustc_attr_parsing::InstructionSetAttr;
use rustc_middle::mir::mono::{Linkage, MonoItem, MonoItemData, Visibility}; use rustc_middle::mir::mono::{Linkage, MonoItem, MonoItemData, Visibility};
use rustc_middle::mir::{Body, InlineAsmOperand}; use rustc_middle::mir::{Body, InlineAsmOperand};
use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutOf}; use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutOf};

View file

@ -1,4 +1,4 @@
use rustc_attr::InstructionSetAttr; use rustc_attr_parsing::InstructionSetAttr;
use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_data_structures::unord::{UnordMap, UnordSet};
use rustc_errors::Applicability; use rustc_errors::Applicability;

View file

@ -9,7 +9,7 @@ either = "1"
rustc_abi = { path = "../rustc_abi" } rustc_abi = { path = "../rustc_abi" }
rustc_apfloat = "0.2.0" rustc_apfloat = "0.2.0"
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }

View file

@ -6,7 +6,7 @@ use std::mem;
use std::num::NonZero; use std::num::NonZero;
use std::ops::Deref; use std::ops::Deref;
use rustc_attr::{ConstStability, StabilityLevel}; use rustc_attr_parsing::{ConstStability, StabilityLevel};
use rustc_errors::{Diag, ErrorGuaranteed}; use rustc_errors::{Diag, ErrorGuaranteed};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::{self as hir, LangItem}; use rustc_hir::{self as hir, LangItem};

View file

@ -9,7 +9,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::ty::{self, PolyFnSig, TyCtxt}; use rustc_middle::ty::{self, PolyFnSig, TyCtxt};
use rustc_middle::{bug, mir}; use rustc_middle::{bug, mir};
use rustc_span::Symbol; use rustc_span::Symbol;
use {rustc_attr as attr, rustc_hir as hir}; use {rustc_attr_parsing as attr, rustc_hir as hir};
pub use self::qualifs::Qualif; pub use self::qualifs::Qualif;

View file

@ -9,7 +9,7 @@ rustc_ast = { path = "../rustc_ast" }
rustc_ast_lowering = { path = "../rustc_ast_lowering" } rustc_ast_lowering = { path = "../rustc_ast_lowering" }
rustc_ast_passes = { path = "../rustc_ast_passes" } rustc_ast_passes = { path = "../rustc_ast_passes" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_borrowck = { path = "../rustc_borrowck" } rustc_borrowck = { path = "../rustc_borrowck" }
rustc_builtin_macros = { path = "../rustc_builtin_macros" } rustc_builtin_macros = { path = "../rustc_builtin_macros" }
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" } rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }

View file

@ -112,7 +112,7 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
crate::DEFAULT_LOCALE_RESOURCE, crate::DEFAULT_LOCALE_RESOURCE,
rustc_ast_lowering::DEFAULT_LOCALE_RESOURCE, rustc_ast_lowering::DEFAULT_LOCALE_RESOURCE,
rustc_ast_passes::DEFAULT_LOCALE_RESOURCE, rustc_ast_passes::DEFAULT_LOCALE_RESOURCE,
rustc_attr::DEFAULT_LOCALE_RESOURCE, rustc_attr_parsing::DEFAULT_LOCALE_RESOURCE,
rustc_borrowck::DEFAULT_LOCALE_RESOURCE, rustc_borrowck::DEFAULT_LOCALE_RESOURCE,
rustc_builtin_macros::DEFAULT_LOCALE_RESOURCE, rustc_builtin_macros::DEFAULT_LOCALE_RESOURCE,
rustc_codegen_ssa::DEFAULT_LOCALE_RESOURCE, rustc_codegen_ssa::DEFAULT_LOCALE_RESOURCE,

View file

@ -12,7 +12,7 @@ doctest = false
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_ast_passes = { path = "../rustc_ast_passes" } rustc_ast_passes = { path = "../rustc_ast_passes" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" } rustc_feature = { path = "../rustc_feature" }

View file

@ -10,7 +10,7 @@ use rustc_ast::token::Nonterminal;
use rustc_ast::tokenstream::TokenStream; use rustc_ast::tokenstream::TokenStream;
use rustc_ast::visit::{AssocCtxt, Visitor}; use rustc_ast::visit::{AssocCtxt, Visitor};
use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, Item, NodeId, PatKind}; use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, Item, NodeId, PatKind};
use rustc_attr::{self as attr, Deprecation, Stability}; use rustc_attr_parsing::{self as attr, Deprecation, Stability};
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::sync::{self, Lrc}; use rustc_data_structures::sync::{self, Lrc};
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, PResult}; use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, PResult};
@ -848,7 +848,7 @@ impl SyntaxExtension {
is_local: bool, is_local: bool,
) -> SyntaxExtension { ) -> SyntaxExtension {
let allow_internal_unstable = let allow_internal_unstable =
rustc_attr::allow_internal_unstable(sess, attrs).collect::<Vec<Symbol>>(); rustc_attr_parsing::allow_internal_unstable(sess, attrs).collect::<Vec<Symbol>>();
let allow_internal_unsafe = ast::attr::contains_name(attrs, sym::allow_internal_unsafe); let allow_internal_unsafe = ast::attr::contains_name(attrs, sym::allow_internal_unsafe);
let local_inner_macros = ast::attr::find_by_name(attrs, sym::macro_export) let local_inner_macros = ast::attr::find_by_name(attrs, sym::macro_export)

View file

@ -8,7 +8,7 @@ use rustc_ast::tokenstream::{
use rustc_ast::{ use rustc_ast::{
self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem, MetaItemInner, NodeId, self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem, MetaItemInner, NodeId,
}; };
use rustc_attr as attr; use rustc_attr_parsing as attr;
use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
use rustc_feature::{ use rustc_feature::{
ACCEPTED_LANG_FEATURES, AttributeSafety, EnabledLangFeature, EnabledLibFeature, Features, ACCEPTED_LANG_FEATURES, AttributeSafety, EnabledLangFeature, EnabledLibFeature, Features,

View file

@ -1913,7 +1913,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
self.cx.current_expansion.lint_node_id, self.cx.current_expansion.lint_node_id,
BuiltinLintDiag::UnusedDocComment(attr.span), BuiltinLintDiag::UnusedDocComment(attr.span),
); );
} else if rustc_attr::is_builtin_attr(attr) { } else if rustc_attr_parsing::is_builtin_attr(attr) {
let attr_name = attr.ident().unwrap().name; let attr_name = attr.ident().unwrap().name;
// `#[cfg]` and `#[cfg_attr]` are special - they are // `#[cfg]` and `#[cfg_attr]` are special - they are
// eagerly evaluated. // eagerly evaluated.

View file

@ -10,7 +10,7 @@ use rustc_ast::token::{self, Delimiter, NonterminalKind, Token, TokenKind};
use rustc_ast::tokenstream::{DelimSpan, TokenStream}; use rustc_ast::tokenstream::{DelimSpan, TokenStream};
use rustc_ast::{self as ast, DUMMY_NODE_ID, NodeId}; use rustc_ast::{self as ast, DUMMY_NODE_ID, NodeId};
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_attr::{self as attr, TransparencyError}; use rustc_attr_parsing::{self as attr, TransparencyError};
use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_errors::{Applicability, ErrorGuaranteed}; use rustc_errors::{Applicability, ErrorGuaranteed};
use rustc_feature::Features; use rustc_feature::Features;

View file

@ -13,7 +13,7 @@ itertools = "0.12"
rustc_abi = { path = "../rustc_abi" } rustc_abi = { path = "../rustc_abi" }
rustc_arena = { path = "../rustc_arena" } rustc_arena = { path = "../rustc_arena" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" } rustc_feature = { path = "../rustc_feature" }

View file

@ -31,7 +31,7 @@ use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
use rustc_type_ir::fold::TypeFoldable; use rustc_type_ir::fold::TypeFoldable;
use tracing::{debug, instrument}; use tracing::{debug, instrument};
use ty::TypingMode; use ty::TypingMode;
use {rustc_attr as attr, rustc_hir as hir}; use {rustc_attr_parsing as attr, rustc_hir as hir};
use super::compare_impl_item::check_type_bounds; use super::compare_impl_item::check_type_bounds;
use super::*; use super::*;

View file

@ -9,7 +9,7 @@ itertools = "0.12"
rustc_abi = { path = "../rustc_abi" } rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_ast_ir = { path = "../rustc_ast_ir" } rustc_ast_ir = { path = "../rustc_ast_ir" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }

View file

@ -8,7 +8,7 @@ use std::borrow::Cow;
use hir::Expr; use hir::Expr;
use rustc_ast::ast::Mutability; use rustc_ast::ast::Mutability;
use rustc_attr::parse_confusables; use rustc_attr_parsing::parse_confusables;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::sorted_map::SortedMap; use rustc_data_structures::sorted_map::SortedMap;
use rustc_data_structures::unord::UnordSet; use rustc_data_structures::unord::UnordSet;

View file

@ -11,7 +11,7 @@ rustc_ast = { path = "../rustc_ast" }
rustc_ast_lowering = { path = "../rustc_ast_lowering" } rustc_ast_lowering = { path = "../rustc_ast_lowering" }
rustc_ast_passes = { path = "../rustc_ast_passes" } rustc_ast_passes = { path = "../rustc_ast_passes" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_borrowck = { path = "../rustc_borrowck" } rustc_borrowck = { path = "../rustc_borrowck" }
rustc_builtin_macros = { path = "../rustc_builtin_macros" } rustc_builtin_macros = { path = "../rustc_builtin_macros" }
rustc_codegen_llvm = { path = "../rustc_codegen_llvm", optional = true } rustc_codegen_llvm = { path = "../rustc_codegen_llvm", optional = true }

View file

@ -453,7 +453,7 @@ pub fn build_output_filenames(attrs: &[ast::Attribute], sess: &Session) -> Outpu
.opts .opts
.crate_name .crate_name
.clone() .clone()
.or_else(|| rustc_attr::find_crate_name(attrs).map(|n| n.to_string())); .or_else(|| rustc_attr_parsing::find_crate_name(attrs).map(|n| n.to_string()));
match sess.io.output_file { match sess.io.output_file {
None => { None => {

View file

@ -8,7 +8,7 @@ edition = "2021"
rustc_abi = { path = "../rustc_abi" } rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" } rustc_feature = { path = "../rustc_feature" }

View file

@ -8,7 +8,7 @@ use rustc_session::{declare_lint, declare_lint_pass};
use rustc_span::def_id::LocalDefId; use rustc_span::def_id::LocalDefId;
use rustc_span::symbol::{Ident, sym}; use rustc_span::symbol::{Ident, sym};
use rustc_span::{BytePos, Span}; use rustc_span::{BytePos, Span};
use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; use {rustc_ast as ast, rustc_attr_parsing as attr, rustc_hir as hir};
use crate::lints::{ use crate::lints::{
NonCamelCaseType, NonCamelCaseTypeSub, NonSnakeCaseDiag, NonSnakeCaseDiagSub, NonCamelCaseType, NonCamelCaseTypeSub, NonSnakeCaseDiag, NonSnakeCaseDiagSub,

View file

@ -3,7 +3,7 @@ use rustc_abi::{Integer, Size};
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;
use rustc_middle::ty::layout::IntegerExt; use rustc_middle::ty::layout::IntegerExt;
use rustc_middle::{bug, ty}; use rustc_middle::{bug, ty};
use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; use {rustc_ast as ast, rustc_attr_parsing as attr, rustc_hir as hir};
use crate::LateContext; use crate::LateContext;
use crate::context::LintContext; use crate::context::LintContext;

View file

@ -11,7 +11,7 @@ libloading = "0.8.0"
odht = { version = "0.3.1", features = ["nightly"] } odht = { version = "0.3.1", features = ["nightly"] }
rustc_abi = { path = "../rustc_abi" } rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_expand = { path = "../rustc_expand" } rustc_expand = { path = "../rustc_expand" }

View file

@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
use rustc_abi::ExternAbi; use rustc_abi::ExternAbi;
use rustc_ast::CRATE_NODE_ID; use rustc_ast::CRATE_NODE_ID;
use rustc_attr as attr; use rustc_attr_parsing as attr;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_middle::query::LocalCrate; use rustc_middle::query::LocalCrate;
use rustc_middle::ty::{self, List, Ty, TyCtxt}; use rustc_middle::ty::{self, List, Ty, TyCtxt};

View file

@ -1,7 +1,7 @@
use std::any::Any; use std::any::Any;
use std::mem; use std::mem;
use rustc_attr::Deprecation; use rustc_attr_parsing::Deprecation;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE};

View file

@ -40,7 +40,7 @@ use rustc_span::symbol::{Ident, Symbol};
use rustc_span::{self, ExpnData, ExpnHash, ExpnId, Span}; use rustc_span::{self, ExpnData, ExpnHash, ExpnId, Span};
use rustc_target::spec::{PanicStrategy, TargetTuple}; use rustc_target::spec::{PanicStrategy, TargetTuple};
use table::TableBuilder; use table::TableBuilder;
use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; use {rustc_ast as ast, rustc_attr_parsing as attr, rustc_hir as hir};
use crate::creader::CrateMetadataRef; use crate::creader::CrateMetadataRef;

View file

@ -17,7 +17,7 @@ rustc_apfloat = "0.2.0"
rustc_arena = { path = "../rustc_arena" } rustc_arena = { path = "../rustc_arena" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_ast_ir = { path = "../rustc_ast_ir" } rustc_ast_ir = { path = "../rustc_ast_ir" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_error_messages = { path = "../rustc_error_messages" } # Used for intra-doc links rustc_error_messages = { path = "../rustc_error_messages" } # Used for intra-doc links
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }

View file

@ -1,5 +1,5 @@
use rustc_abi::Align; use rustc_abi::Align;
use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr}; use rustc_attr_parsing::{InlineAttr, InstructionSetAttr, OptimizeAttr};
use rustc_macros::{HashStable, TyDecodable, TyEncodable}; use rustc_macros::{HashStable, TyDecodable, TyEncodable};
use rustc_span::symbol::Symbol; use rustc_span::symbol::Symbol;
use rustc_target::spec::SanitizerSet; use rustc_target::spec::SanitizerSet;

View file

@ -4,7 +4,7 @@
use std::num::NonZero; use std::num::NonZero;
use rustc_ast::NodeId; use rustc_ast::NodeId;
use rustc_attr::{ use rustc_attr_parsing::{
self as attr, ConstStability, DefaultBodyStability, DeprecatedSince, Deprecation, Stability, self as attr, ConstStability, DefaultBodyStability, DeprecatedSince, Deprecation, Stability,
}; };
use rustc_data_structures::unord::UnordMap; use rustc_data_structures::unord::UnordMap;

View file

@ -1,7 +1,7 @@
use std::fmt; use std::fmt;
use std::hash::Hash; use std::hash::Hash;
use rustc_attr::InlineAttr; use rustc_attr_parsing::InlineAttr;
use rustc_data_structures::base_n::{BaseNString, CASE_INSENSITIVE, ToBaseN}; use rustc_data_structures::base_n::{BaseNString, CASE_INSENSITIVE, ToBaseN};
use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;

View file

@ -239,9 +239,9 @@ trivial! {
bool, bool,
Option<(rustc_span::def_id::DefId, rustc_session::config::EntryFnType)>, Option<(rustc_span::def_id::DefId, rustc_session::config::EntryFnType)>,
Option<rustc_ast::expand::allocator::AllocatorKind>, Option<rustc_ast::expand::allocator::AllocatorKind>,
Option<rustc_attr::ConstStability>, Option<rustc_attr_parsing::ConstStability>,
Option<rustc_attr::DefaultBodyStability>, Option<rustc_attr_parsing::DefaultBodyStability>,
Option<rustc_attr::Stability>, Option<rustc_attr_parsing::Stability>,
Option<rustc_data_structures::svh::Svh>, Option<rustc_data_structures::svh::Svh>,
Option<rustc_hir::def::DefKind>, Option<rustc_hir::def::DefKind>,
Option<rustc_hir::CoroutineKind>, Option<rustc_hir::CoroutineKind>,
@ -264,10 +264,10 @@ trivial! {
Result<rustc_middle::traits::EvaluationResult, rustc_middle::traits::OverflowError>, Result<rustc_middle::traits::EvaluationResult, rustc_middle::traits::OverflowError>,
rustc_abi::ReprOptions, rustc_abi::ReprOptions,
rustc_ast::expand::allocator::AllocatorKind, rustc_ast::expand::allocator::AllocatorKind,
rustc_attr::ConstStability, rustc_attr_parsing::ConstStability,
rustc_attr::DefaultBodyStability, rustc_attr_parsing::DefaultBodyStability,
rustc_attr::Deprecation, rustc_attr_parsing::Deprecation,
rustc_attr::Stability, rustc_attr_parsing::Stability,
rustc_data_structures::svh::Svh, rustc_data_structures::svh::Svh,
rustc_errors::ErrorGuaranteed, rustc_errors::ErrorGuaranteed,
rustc_hir::Constness, rustc_hir::Constness,

View file

@ -44,7 +44,7 @@ use rustc_span::source_map::Spanned;
use rustc_span::symbol::Symbol; use rustc_span::symbol::Symbol;
use rustc_span::{DUMMY_SP, Span}; use rustc_span::{DUMMY_SP, Span};
use rustc_target::spec::PanicStrategy; use rustc_target::spec::PanicStrategy;
use {rustc_abi as abi, rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; use {rustc_abi as abi, rustc_ast as ast, rustc_attr_parsing as attr, rustc_hir as hir};
use crate::infer::canonical::{self, Canonical}; use crate::infer::canonical::{self, Canonical};
use crate::lint::LintExpectation; use crate::lint::LintExpectation;

View file

@ -202,7 +202,7 @@ impl<'tcx> Instance<'tcx> {
if !tcx.sess.opts.share_generics() if !tcx.sess.opts.share_generics()
// However, if the def_id is marked inline(never), then it's fine to just reuse the // However, if the def_id is marked inline(never), then it's fine to just reuse the
// upstream monomorphization. // upstream monomorphization.
&& tcx.codegen_fn_attrs(self.def_id()).inline != rustc_attr::InlineAttr::Never && tcx.codegen_fn_attrs(self.def_id()).inline != rustc_attr_parsing::InlineAttr::Never
{ {
return None; return None;
} }

View file

@ -52,7 +52,7 @@ pub use rustc_type_ir::relate::VarianceDiagInfo;
pub use rustc_type_ir::*; pub use rustc_type_ir::*;
use tracing::{debug, instrument}; use tracing::{debug, instrument};
pub use vtable::*; pub use vtable::*;
use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; use {rustc_ast as ast, rustc_attr_parsing as attr, rustc_hir as hir};
pub use self::closure::{ pub use self::closure::{
BorrowKind, CAPTURE_STRUCT_LOCAL, CaptureInfo, CapturedPlace, ClosureTypeInfo, BorrowKind, CAPTURE_STRUCT_LOCAL, CaptureInfo, CapturedPlace, ClosureTypeInfo,

View file

@ -80,10 +80,10 @@ trivially_parameterized_over_tcx! {
rustc_ast::Attribute, rustc_ast::Attribute,
rustc_ast::DelimArgs, rustc_ast::DelimArgs,
rustc_ast::expand::StrippedCfgItem<rustc_hir::def_id::DefIndex>, rustc_ast::expand::StrippedCfgItem<rustc_hir::def_id::DefIndex>,
rustc_attr::ConstStability, rustc_attr_parsing::ConstStability,
rustc_attr::DefaultBodyStability, rustc_attr_parsing::DefaultBodyStability,
rustc_attr::Deprecation, rustc_attr_parsing::Deprecation,
rustc_attr::Stability, rustc_attr_parsing::Stability,
rustc_hir::Constness, rustc_hir::Constness,
rustc_hir::Defaultness, rustc_hir::Defaultness,
rustc_hir::Safety, rustc_hir::Safety,

View file

@ -10,7 +10,7 @@ itertools = "0.12"
rustc_abi = { path = "../rustc_abi" } rustc_abi = { path = "../rustc_abi" }
rustc_arena = { path = "../rustc_arena" } rustc_arena = { path = "../rustc_arena" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_const_eval = { path = "../rustc_const_eval" } rustc_const_eval = { path = "../rustc_const_eval" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }

View file

@ -1,4 +1,4 @@
use rustc_attr::InlineAttr; use rustc_attr_parsing::InlineAttr;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_hir::def_id::LocalDefId; use rustc_hir::def_id::LocalDefId;
use rustc_middle::mir::visit::Visitor; use rustc_middle::mir::visit::Visitor;

View file

@ -4,7 +4,7 @@ use std::iter;
use std::ops::{Range, RangeFrom}; use std::ops::{Range, RangeFrom};
use rustc_abi::{ExternAbi, FieldIdx}; use rustc_abi::{ExternAbi, FieldIdx};
use rustc_attr::InlineAttr; use rustc_attr_parsing::InlineAttr;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_index::Idx; use rustc_index::Idx;

View file

@ -6,7 +6,7 @@ edition = "2021"
[dependencies] [dependencies]
# tidy-alphabetical-start # tidy-alphabetical-start
rustc_abi = { path = "../rustc_abi" } rustc_abi = { path = "../rustc_abi" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }

View file

@ -833,7 +833,8 @@ fn mono_item_visibility<'tcx>(
return if is_generic return if is_generic
&& (always_export_generics && (always_export_generics
|| (can_export_generics || (can_export_generics
&& tcx.codegen_fn_attrs(def_id).inline == rustc_attr::InlineAttr::Never)) && tcx.codegen_fn_attrs(def_id).inline
== rustc_attr_parsing::InlineAttr::Never))
{ {
// If it is an upstream monomorphization and we export generics, we must make // If it is an upstream monomorphization and we export generics, we must make
// it available to downstream crates. // it available to downstream crates.
@ -847,7 +848,7 @@ fn mono_item_visibility<'tcx>(
if is_generic { if is_generic {
if always_export_generics if always_export_generics
|| (can_export_generics || (can_export_generics
&& tcx.codegen_fn_attrs(def_id).inline == rustc_attr::InlineAttr::Never) && tcx.codegen_fn_attrs(def_id).inline == rustc_attr_parsing::InlineAttr::Never)
{ {
if tcx.is_unreachable_local_definition(def_id) { if tcx.is_unreachable_local_definition(def_id) {
// This instance cannot be used from another crate. // This instance cannot be used from another crate.

View file

@ -8,7 +8,7 @@ edition = "2021"
rustc_abi = { path = "../rustc_abi" } rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_expand = { path = "../rustc_expand" } rustc_expand = { path = "../rustc_expand" }

View file

@ -4,7 +4,7 @@
//! but are not declared in one single location (unlike lang features), which means we need to //! but are not declared in one single location (unlike lang features), which means we need to
//! collect them instead. //! collect them instead.
use rustc_attr::VERSION_PLACEHOLDER; use rustc_attr_parsing::VERSION_PLACEHOLDER;
use rustc_hir::Attribute; use rustc_hir::Attribute;
use rustc_hir::intravisit::Visitor; use rustc_hir::intravisit::Visitor;
use rustc_middle::hir::nested_filter; use rustc_middle::hir::nested_filter;

View file

@ -4,7 +4,7 @@
use std::mem::replace; use std::mem::replace;
use std::num::NonZero; use std::num::NonZero;
use rustc_attr::{ use rustc_attr_parsing::{
self as attr, ConstStability, DeprecatedSince, Stability, StabilityLevel, StableSince, self as attr, ConstStability, DeprecatedSince, Stability, StabilityLevel, StableSince,
UnstableReason, VERSION_PLACEHOLDER, UnstableReason, VERSION_PLACEHOLDER,
}; };

View file

@ -6,7 +6,7 @@ edition = "2021"
[dependencies] [dependencies]
# tidy-alphabetical-start # tidy-alphabetical-start
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }

View file

@ -41,7 +41,7 @@ use rustc_span::Span;
use rustc_span::hygiene::Transparency; use rustc_span::hygiene::Transparency;
use rustc_span::symbol::{Ident, kw, sym}; use rustc_span::symbol::{Ident, kw, sym};
use tracing::debug; use tracing::debug;
use {rustc_attr as attr, rustc_hir as hir}; use {rustc_attr_parsing as attr, rustc_hir as hir};
rustc_fluent_macro::fluent_messages! { "../messages.ftl" } rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View file

@ -10,7 +10,7 @@ pulldown-cmark = { version = "0.11", features = ["html"], default-features = fal
rustc_arena = { path = "../rustc_arena" } rustc_arena = { path = "../rustc_arena" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_expand = { path = "../rustc_expand" } rustc_expand = { path = "../rustc_expand" }

View file

@ -12,7 +12,7 @@ use rustc_ast::{
self as ast, AssocItem, AssocItemKind, Block, ForeignItem, ForeignItemKind, Impl, Item, self as ast, AssocItem, AssocItemKind, Block, ForeignItem, ForeignItemKind, Impl, Item,
ItemKind, MetaItemKind, NodeId, StmtKind, ItemKind, MetaItemKind, NodeId, StmtKind,
}; };
use rustc_attr as attr; use rustc_attr_parsing as attr;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_expand::base::ResolverExpand; use rustc_expand::base::ResolverExpand;
use rustc_expand::expand::AstFragment; use rustc_expand::expand::AstFragment;

View file

@ -8,7 +8,7 @@ use rustc_ast::attr::AttributeExt;
use rustc_ast::expand::StrippedCfgItem; use rustc_ast::expand::StrippedCfgItem;
use rustc_ast::{self as ast, Crate, Inline, ItemKind, ModKind, NodeId, attr}; use rustc_ast::{self as ast, Crate, Inline, ItemKind, ModKind, NodeId, attr};
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_attr::StabilityLevel; use rustc_attr_parsing::StabilityLevel;
use rustc_data_structures::intern::Interned; use rustc_data_structures::intern::Interned;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_errors::{Applicability, StashKey}; use rustc_errors::{Applicability, StashKey};

View file

@ -29,9 +29,6 @@ pub mod output;
pub use getopts; pub use getopts;
mod version;
pub use version::RustcVersion;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" } rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
/// Requirements for a `StableHashingContext` to be used in this crate. /// Requirements for a `StableHashingContext` to be used in this crate.

View file

@ -9,7 +9,7 @@ itertools = "0.12"
rustc_abi = { path = "../rustc_abi" } rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_ast_ir = { path = "../rustc_ast_ir" } rustc_ast_ir = { path = "../rustc_ast_ir" }
rustc_attr = { path = "../rustc_attr" } rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }

View file

@ -16,7 +16,7 @@ use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Symbol, kw, sym}; use rustc_span::symbol::{Symbol, kw, sym};
use tracing::{debug, info}; use tracing::{debug, info};
use {rustc_attr as attr, rustc_hir as hir}; use {rustc_attr_parsing as attr, rustc_hir as hir};
use super::{ObligationCauseCode, PredicateObligation}; use super::{ObligationCauseCode, PredicateObligation};
use crate::error_reporting::TypeErrCtxt; use crate::error_reporting::TypeErrCtxt;

View file

@ -6,7 +6,7 @@ use std::{fmt, iter};
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use rustc_abi::{ExternAbi, VariantIdx}; use rustc_abi::{ExternAbi, VariantIdx};
use rustc_attr::{ConstStability, Deprecation, Stability, StableSince}; use rustc_attr_parsing::{ConstStability, Deprecation, Stability, StableSince};
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId}; use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId};

View file

@ -15,7 +15,7 @@ use std::iter::{self, once};
use itertools::Itertools; use itertools::Itertools;
use rustc_abi::ExternAbi; use rustc_abi::ExternAbi;
use rustc_attr::{ConstStability, StabilityLevel, StableSince}; use rustc_attr_parsing::{ConstStability, StabilityLevel, StableSince};
use rustc_data_structures::captures::Captures; use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir; use rustc_hir as hir;

View file

@ -44,14 +44,15 @@ use std::path::PathBuf;
use std::{fs, str}; use std::{fs, str};
use rinja::Template; use rinja::Template;
use rustc_attr::{ConstStability, DeprecatedSince, Deprecation, StabilityLevel, StableSince}; use rustc_attr_parsing::{
ConstStability, DeprecatedSince, Deprecation, RustcVersion, StabilityLevel, StableSince,
};
use rustc_data_structures::captures::Captures; use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
use rustc_hir::Mutability; use rustc_hir::Mutability;
use rustc_hir::def_id::{DefId, DefIdSet}; use rustc_hir::def_id::{DefId, DefIdSet};
use rustc_middle::ty::print::PrintTraitRefExt; use rustc_middle::ty::print::PrintTraitRefExt;
use rustc_middle::ty::{self, TyCtxt}; use rustc_middle::ty::{self, TyCtxt};
use rustc_session::RustcVersion;
use rustc_span::symbol::{Symbol, sym}; use rustc_span::symbol::{Symbol, sym};
use rustc_span::{BytePos, DUMMY_SP, FileName, RealFileName}; use rustc_span::{BytePos, DUMMY_SP, FileName, RealFileName};
use serde::ser::SerializeMap; use serde::ser::SerializeMap;

View file

@ -6,7 +6,7 @@
use rustc_abi::ExternAbi; use rustc_abi::ExternAbi;
use rustc_ast::ast; use rustc_ast::ast;
use rustc_attr::DeprecatedSince; use rustc_attr_parsing::DeprecatedSince;
use rustc_hir::def::{CtorKind, DefKind}; use rustc_hir::def::{CtorKind, DefKind};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_metadata::rendered_const; use rustc_metadata::rendered_const;
@ -215,8 +215,8 @@ where
} }
} }
pub(crate) fn from_deprecation(deprecation: rustc_attr::Deprecation) -> Deprecation { pub(crate) fn from_deprecation(deprecation: rustc_attr_parsing::Deprecation) -> Deprecation {
let rustc_attr::Deprecation { since, note, suggestion: _ } = deprecation; let rustc_attr_parsing::Deprecation { since, note, suggestion: _ } = deprecation;
let since = match since { let since = match since {
DeprecatedSince::RustcVersion(version) => Some(version.to_string()), DeprecatedSince::RustcVersion(version) => Some(version.to_string()),
DeprecatedSince::Future => Some("TBD".to_owned()), DeprecatedSince::Future => Some("TBD".to_owned()),

View file

@ -36,7 +36,7 @@ extern crate pulldown_cmark;
extern crate rustc_abi; extern crate rustc_abi;
extern crate rustc_ast; extern crate rustc_ast;
extern crate rustc_ast_pretty; extern crate rustc_ast_pretty;
extern crate rustc_attr; extern crate rustc_attr_parsing;
extern crate rustc_data_structures; extern crate rustc_data_structures;
extern crate rustc_driver; extern crate rustc_driver;
extern crate rustc_errors; extern crate rustc_errors;

View file

@ -6,7 +6,7 @@
//! [`core::error`] module is marked as stable since 1.81.0, so we want to show //! [`core::error`] module is marked as stable since 1.81.0, so we want to show
//! [`core::error::Error`] as stable since 1.81.0 as well. //! [`core::error::Error`] as stable since 1.81.0 as well.
use rustc_attr::{Stability, StabilityLevel}; use rustc_attr_parsing::{Stability, StabilityLevel};
use rustc_hir::def_id::CRATE_DEF_ID; use rustc_hir::def_id::CRATE_DEF_ID;
use crate::clean::{Crate, Item, ItemId, ItemKind}; use crate::clean::{Crate, Item, ItemId, ItemKind};

View file

@ -2,9 +2,10 @@ use clippy_config::Conf;
use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::msrvs::{self, Msrv}; use clippy_utils::msrvs::{self, Msrv};
use rustc_ast::ast::{FloatTy, LitFloatType, LitKind}; use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
use rustc_attr_parsing::RustcVersion;
use rustc_hir::{Expr, ExprKind}; use rustc_hir::{Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{RustcVersion, impl_lint_pass}; use rustc_session::impl_lint_pass;
use rustc_span::symbol; use rustc_span::symbol;
use std::f64::consts as f64; use std::f64::consts as f64;

View file

@ -9,7 +9,8 @@ use rustc_errors::Applicability;
use rustc_hir::intravisit::{FnKind, Visitor, walk_expr}; use rustc_hir::intravisit::{FnKind, Visitor, walk_expr};
use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, UnOp}; use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, UnOp};
use rustc_lint::{LateContext, LateLintPass, Level}; use rustc_lint::{LateContext, LateLintPass, Level};
use rustc_session::{RustcVersion, impl_lint_pass}; use rustc_attr_parsing::RustcVersion;
use rustc_session::impl_lint_pass;
use rustc_span::def_id::LocalDefId; use rustc_span::def_id::LocalDefId;
use rustc_span::{Span, sym}; use rustc_span::{Span, sym};

View file

@ -2,12 +2,12 @@ use clippy_config::Conf;
use clippy_utils::diagnostics::span_lint; use clippy_utils::diagnostics::span_lint;
use clippy_utils::is_in_test; use clippy_utils::is_in_test;
use clippy_utils::msrvs::Msrv; use clippy_utils::msrvs::Msrv;
use rustc_attr::{StabilityLevel, StableSince}; use rustc_attr_parsing::{StabilityLevel, StableSince, RustcVersion};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_hir::{Expr, ExprKind, HirId}; use rustc_hir::{Expr, ExprKind, HirId};
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
use rustc_session::{RustcVersion, impl_lint_pass}; use rustc_session::impl_lint_pass;
use rustc_span::def_id::DefId; use rustc_span::def_id::DefId;
use rustc_span::{ExpnKind, Span}; use rustc_span::{ExpnKind, Span};

View file

@ -35,7 +35,7 @@ extern crate rustc_abi;
extern crate rustc_arena; extern crate rustc_arena;
extern crate rustc_ast; extern crate rustc_ast;
extern crate rustc_ast_pretty; extern crate rustc_ast_pretty;
extern crate rustc_attr; extern crate rustc_attr_parsing;
extern crate rustc_data_structures; extern crate rustc_data_structures;
extern crate rustc_driver; extern crate rustc_driver;
extern crate rustc_errors; extern crate rustc_errors;

View file

@ -2,7 +2,7 @@ use clippy_config::Conf;
use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::is_from_proc_macro; use clippy_utils::is_from_proc_macro;
use clippy_utils::msrvs::Msrv; use clippy_utils::msrvs::Msrv;
use rustc_attr::{StabilityLevel, StableSince}; use rustc_attr_parsing::{StabilityLevel, StableSince};
use rustc_errors::Applicability; use rustc_errors::Applicability;
use rustc_hir::def::Res; use rustc_hir::def::Res;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;

View file

@ -222,7 +222,7 @@ fn check_invalid_clippy_version_attribute(cx: &LateContext<'_>, item: &'_ Item<'
return; return;
} }
if rustc_attr::parse_version(value).is_none() { if rustc_attr_parsing::parse_version(value).is_none() {
span_lint_and_help( span_lint_and_help(
cx, cx,
INVALID_CLIPPY_VERSION_ATTRIBUTE, INVALID_CLIPPY_VERSION_ATTRIBUTE,

View file

@ -31,7 +31,7 @@
// (Currently there is no way to opt into sysroot crates without `extern crate`.) // (Currently there is no way to opt into sysroot crates without `extern crate`.)
extern crate rustc_ast; extern crate rustc_ast;
extern crate rustc_ast_pretty; extern crate rustc_ast_pretty;
extern crate rustc_attr; extern crate rustc_attr_parsing;
extern crate rustc_const_eval; extern crate rustc_const_eval;
extern crate rustc_data_structures; extern crate rustc_data_structures;
// The `rustc_driver` crate seems to be required in order to use the `rust_ast` crate. // The `rustc_driver` crate seems to be required in order to use the `rust_ast` crate.

View file

@ -1,6 +1,6 @@
use rustc_ast::attr::AttributeExt; use rustc_ast::attr::AttributeExt;
use rustc_attr::parse_version; use rustc_attr_parsing::{parse_version, RustcVersion};
use rustc_session::{RustcVersion, Session}; use rustc_session::Session;
use rustc_span::{Symbol, sym}; use rustc_span::{Symbol, sym};
use serde::Deserialize; use serde::Deserialize;
use smallvec::{SmallVec, smallvec}; use smallvec::{SmallVec, smallvec};

Some files were not shown because too many files have changed in this diff Show more