Skip to content

Commit efb98b6

Browse files
committed
rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structures
1 parent 1341366 commit efb98b6

File tree

103 files changed

+481
-395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+481
-395
lines changed

Cargo.lock

+39-20
Original file line numberDiff line numberDiff line change
@@ -3354,7 +3354,7 @@ dependencies = [
33543354
"itertools",
33553355
"rustc_ast",
33563356
"rustc_ast_pretty",
3357-
"rustc_attr",
3357+
"rustc_attr_parsing",
33583358
"rustc_data_structures",
33593359
"rustc_errors",
33603360
"rustc_feature",
@@ -3380,7 +3380,7 @@ dependencies = [
33803380
]
33813381

33823382
[[package]]
3383-
name = "rustc_attr"
3383+
name = "rustc_attr_data_structures"
33843384
version = "0.0.0"
33853385
dependencies = [
33863386
"rustc_abi",
@@ -3397,6 +3397,25 @@ dependencies = [
33973397
"rustc_span",
33983398
]
33993399

3400+
[[package]]
3401+
name = "rustc_attr_parsing"
3402+
version = "0.0.0"
3403+
dependencies = [
3404+
"rustc_abi",
3405+
"rustc_ast",
3406+
"rustc_ast_pretty",
3407+
"rustc_attr_data_structures",
3408+
"rustc_data_structures",
3409+
"rustc_errors",
3410+
"rustc_feature",
3411+
"rustc_fluent_macro",
3412+
"rustc_lexer",
3413+
"rustc_macros",
3414+
"rustc_serialize",
3415+
"rustc_session",
3416+
"rustc_span",
3417+
]
3418+
34003419
[[package]]
34013420
name = "rustc_baked_icu_data"
34023421
version = "0.0.0"
@@ -3441,7 +3460,7 @@ version = "0.0.0"
34413460
dependencies = [
34423461
"rustc_ast",
34433462
"rustc_ast_pretty",
3444-
"rustc_attr",
3463+
"rustc_attr_parsing",
34453464
"rustc_data_structures",
34463465
"rustc_errors",
34473466
"rustc_expand",
@@ -3473,7 +3492,7 @@ dependencies = [
34733492
"rustc-demangle",
34743493
"rustc_abi",
34753494
"rustc_ast",
3476-
"rustc_attr",
3495+
"rustc_attr_parsing",
34773496
"rustc_codegen_ssa",
34783497
"rustc_data_structures",
34793498
"rustc_errors",
@@ -3515,7 +3534,7 @@ dependencies = [
35153534
"rustc_arena",
35163535
"rustc_ast",
35173536
"rustc_ast_pretty",
3518-
"rustc_attr",
3537+
"rustc_attr_parsing",
35193538
"rustc_data_structures",
35203539
"rustc_errors",
35213540
"rustc_fluent_macro",
@@ -3553,7 +3572,7 @@ dependencies = [
35533572
"rustc_abi",
35543573
"rustc_apfloat",
35553574
"rustc_ast",
3556-
"rustc_attr",
3575+
"rustc_attr_parsing",
35573576
"rustc_data_structures",
35583577
"rustc_errors",
35593578
"rustc_fluent_macro",
@@ -3620,7 +3639,7 @@ dependencies = [
36203639
"rustc_ast_lowering",
36213640
"rustc_ast_passes",
36223641
"rustc_ast_pretty",
3623-
"rustc_attr",
3642+
"rustc_attr_parsing",
36243643
"rustc_borrowck",
36253644
"rustc_builtin_macros",
36263645
"rustc_codegen_ssa",
@@ -3724,7 +3743,7 @@ dependencies = [
37243743
"rustc_ast",
37253744
"rustc_ast_passes",
37263745
"rustc_ast_pretty",
3727-
"rustc_attr",
3746+
"rustc_attr_parsing",
37283747
"rustc_data_structures",
37293748
"rustc_errors",
37303749
"rustc_feature",
@@ -3799,7 +3818,7 @@ dependencies = [
37993818
"rustc_abi",
38003819
"rustc_arena",
38013820
"rustc_ast",
3802-
"rustc_attr",
3821+
"rustc_attr_parsing",
38033822
"rustc_data_structures",
38043823
"rustc_errors",
38053824
"rustc_feature",
@@ -3838,7 +3857,7 @@ dependencies = [
38383857
"rustc_abi",
38393858
"rustc_ast",
38403859
"rustc_ast_ir",
3841-
"rustc_attr",
3860+
"rustc_attr_parsing",
38423861
"rustc_data_structures",
38433862
"rustc_errors",
38443863
"rustc_fluent_macro",
@@ -3927,7 +3946,7 @@ dependencies = [
39273946
"rustc_ast_lowering",
39283947
"rustc_ast_passes",
39293948
"rustc_ast_pretty",
3930-
"rustc_attr",
3949+
"rustc_attr_parsing",
39313950
"rustc_borrowck",
39323951
"rustc_builtin_macros",
39333952
"rustc_codegen_llvm",
@@ -3983,7 +4002,7 @@ dependencies = [
39834002
"rustc_abi",
39844003
"rustc_ast",
39854004
"rustc_ast_pretty",
3986-
"rustc_attr",
4005+
"rustc_attr_parsing",
39874006
"rustc_data_structures",
39884007
"rustc_errors",
39894008
"rustc_feature",
@@ -4057,7 +4076,7 @@ dependencies = [
40574076
"odht",
40584077
"rustc_abi",
40594078
"rustc_ast",
4060-
"rustc_attr",
4079+
"rustc_attr_parsing",
40614080
"rustc_data_structures",
40624081
"rustc_errors",
40634082
"rustc_expand",
@@ -4094,7 +4113,7 @@ dependencies = [
40944113
"rustc_arena",
40954114
"rustc_ast",
40964115
"rustc_ast_ir",
4097-
"rustc_attr",
4116+
"rustc_attr_parsing",
40984117
"rustc_data_structures",
40994118
"rustc_error_messages",
41004119
"rustc_errors",
@@ -4173,7 +4192,7 @@ dependencies = [
41734192
"rustc_abi",
41744193
"rustc_arena",
41754194
"rustc_ast",
4176-
"rustc_attr",
4195+
"rustc_attr_parsing",
41774196
"rustc_const_eval",
41784197
"rustc_data_structures",
41794198
"rustc_errors",
@@ -4199,7 +4218,7 @@ name = "rustc_monomorphize"
41994218
version = "0.0.0"
42004219
dependencies = [
42014220
"rustc_abi",
4202-
"rustc_attr",
4221+
"rustc_attr_parsing",
42034222
"rustc_data_structures",
42044223
"rustc_errors",
42054224
"rustc_fluent_macro",
@@ -4267,7 +4286,7 @@ dependencies = [
42674286
"rustc_abi",
42684287
"rustc_ast",
42694288
"rustc_ast_pretty",
4270-
"rustc_attr",
4289+
"rustc_attr_parsing",
42714290
"rustc_data_structures",
42724291
"rustc_errors",
42734292
"rustc_expand",
@@ -4314,7 +4333,7 @@ name = "rustc_privacy"
43144333
version = "0.0.0"
43154334
dependencies = [
43164335
"rustc_ast",
4317-
"rustc_attr",
4336+
"rustc_attr_parsing",
43184337
"rustc_data_structures",
43194338
"rustc_errors",
43204339
"rustc_fluent_macro",
@@ -4378,7 +4397,7 @@ dependencies = [
43784397
"rustc_arena",
43794398
"rustc_ast",
43804399
"rustc_ast_pretty",
4381-
"rustc_attr",
4400+
"rustc_attr_parsing",
43824401
"rustc_data_structures",
43834402
"rustc_errors",
43844403
"rustc_expand",
@@ -4535,7 +4554,7 @@ dependencies = [
45354554
"rustc_abi",
45364555
"rustc_ast",
45374556
"rustc_ast_ir",
4538-
"rustc_attr",
4557+
"rustc_attr_parsing",
45394558
"rustc_data_structures",
45404559
"rustc_errors",
45414560
"rustc_fluent_macro",

compiler/rustc_ast_passes/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2021"
88
itertools = "0.12"
99
rustc_ast = { path = "../rustc_ast" }
1010
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
11-
rustc_attr = { path = "../rustc_attr" }
11+
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
1212
rustc_data_structures = { path = "../rustc_data_structures" }
1313
rustc_errors = { path = "../rustc_errors" }
1414
rustc_feature = { path = "../rustc_feature" }

compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl<'a> AstValidator<'a> {
342342
sym::forbid,
343343
sym::warn,
344344
];
345-
!arr.contains(&attr.name_or_empty()) && rustc_attr::is_builtin_attr(*attr)
345+
!arr.contains(&attr.name_or_empty()) && rustc_attr_parsing::is_builtin_attr(*attr)
346346
})
347347
.for_each(|attr| {
348348
if attr.is_doc_comment() {

compiler/rustc_attr/src/lib.rs

-40
This file was deleted.

compiler/rustc_attr/Cargo.toml compiler/rustc_attr_data_structures/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "rustc_attr"
2+
name = "rustc_attr_data_structures"
33
version = "0.0.0"
44
edition = "2021"
55

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
use rustc_abi::Align;
2+
use rustc_ast as ast;
3+
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
4+
use rustc_span::{Span, Symbol};
5+
6+
use crate::RustcVersion;
7+
8+
#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
9+
pub enum InlineAttr {
10+
None,
11+
Hint,
12+
Always,
13+
Never,
14+
}
15+
16+
#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq, HashStable_Generic)]
17+
pub enum InstructionSetAttr {
18+
ArmA32,
19+
ArmT32,
20+
}
21+
22+
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
23+
pub enum OptimizeAttr {
24+
None,
25+
Speed,
26+
Size,
27+
}
28+
29+
#[derive(Clone, Debug, Encodable, Decodable)]
30+
pub enum DiagnosticAttribute {
31+
// tidy-alphabetical-start
32+
DoNotRecommend,
33+
OnUnimplemented,
34+
// tidy-alphabetical-end
35+
}
36+
37+
#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone)]
38+
pub enum ReprAttr {
39+
ReprInt(IntType),
40+
ReprRust,
41+
ReprC,
42+
ReprPacked(Align),
43+
ReprSimd,
44+
ReprTransparent,
45+
ReprAlign(Align),
46+
}
47+
pub use ReprAttr::*;
48+
49+
pub enum TransparencyError {
50+
UnknownTransparency(Symbol, Span),
51+
MultipleTransparencyAttrs(Span, Span),
52+
}
53+
54+
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
55+
#[derive(Encodable, Decodable)]
56+
pub enum IntType {
57+
SignedInt(ast::IntTy),
58+
UnsignedInt(ast::UintTy),
59+
}
60+
61+
#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic)]
62+
pub struct Deprecation {
63+
pub since: DeprecatedSince,
64+
/// The note to issue a reason.
65+
pub note: Option<Symbol>,
66+
/// A text snippet used to completely replace any use of the deprecated item in an expression.
67+
///
68+
/// This is currently unstable.
69+
pub suggestion: Option<Symbol>,
70+
}
71+
72+
/// Release in which an API is deprecated.
73+
#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic)]
74+
pub enum DeprecatedSince {
75+
RustcVersion(RustcVersion),
76+
/// Deprecated in the future ("to be determined").
77+
Future,
78+
/// `feature(staged_api)` is off. Deprecation versions outside the standard
79+
/// library are allowed to be arbitrary strings, for better or worse.
80+
NonStandard(Symbol),
81+
/// Deprecation version is unspecified but optional.
82+
Unspecified,
83+
/// Failed to parse a deprecation version, or the deprecation version is
84+
/// unspecified and required. An error has already been emitted.
85+
Err,
86+
}
87+
88+
impl Deprecation {
89+
/// Whether an item marked with #[deprecated(since = "X")] is currently
90+
/// deprecated (i.e., whether X is not greater than the current rustc
91+
/// version).
92+
pub fn is_in_effect(&self) -> bool {
93+
match self.since {
94+
DeprecatedSince::RustcVersion(since) => since <= RustcVersion::CURRENT,
95+
DeprecatedSince::Future => false,
96+
// The `since` field doesn't have semantic purpose without `#![staged_api]`.
97+
DeprecatedSince::NonStandard(_) => true,
98+
// Assume deprecation is in effect if "since" field is absent or invalid.
99+
DeprecatedSince::Unspecified | DeprecatedSince::Err => true,
100+
}
101+
}
102+
103+
pub fn is_since_rustc_version(&self) -> bool {
104+
matches!(self.since, DeprecatedSince::RustcVersion(_))
105+
}
106+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// tidy-alphabetical-start
2+
#![allow(internal_features)]
3+
#![doc(rust_logo)]
4+
#![feature(let_chains)]
5+
#![feature(rustdoc_internals)]
6+
#![warn(unreachable_pub)]
7+
// tidy-alphabetical-end
8+
9+
mod attributes;
10+
mod stability;
11+
mod version;
12+
13+
pub use attributes::*;
14+
pub(crate) use rustc_session::HashStableContext;
15+
pub use stability::*;
16+
pub use version::*;

0 commit comments

Comments
 (0)