Skip to content

Commit 025c8b3

Browse files
committed
refactor target checking, move out of context.rs and rename MaybeWarn to Policy
1 parent 53a632e commit 025c8b3

Some content is hidden

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

53 files changed

+508
-432
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3480,7 +3480,6 @@ dependencies = [
34803480
name = "rustc_attr_parsing"
34813481
version = "0.0.0"
34823482
dependencies = [
3483-
"itertools",
34843483
"rustc_abi",
34853484
"rustc_ast",
34863485
"rustc_ast_pretty",

compiler/rustc_attr_parsing/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ edition = "2024"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
itertools = "0.12"
98
rustc_abi = { path = "../rustc_abi" }
109
rustc_ast = { path = "../rustc_ast" }
1110
rustc_ast_pretty = { path = "../rustc_ast_pretty" }

compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ use rustc_hir::{MethodKind, Target};
66
use rustc_span::{Span, Symbol, sym};
77

88
use super::{CombineAttributeParser, ConvertFn};
9-
use crate::context::MaybeWarn::{Allow, Warn};
10-
use crate::context::{AcceptContext, AllowedTargets, Stage};
9+
use crate::context::{AcceptContext, Stage};
1110
use crate::parser::ArgParser;
1211
use crate::session_diagnostics;
12+
use crate::target_checking::AllowedTargets;
13+
use crate::target_checking::Policy::{Allow, Warn};
1314

1415
pub(crate) struct AllowInternalUnstableParser;
1516
impl<S: Stage> CombineAttributeParser<S> for AllowInternalUnstableParser {

compiler/rustc_attr_parsing/src/attributes/body.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use rustc_hir::attrs::AttributeKind;
55
use rustc_span::{Symbol, sym};
66

77
use super::{NoArgsAttributeParser, OnDuplicate};
8-
use crate::context::MaybeWarn::Allow;
9-
use crate::context::{AllowedTargets, Stage};
8+
use crate::context::Stage;
9+
use crate::target_checking::AllowedTargets;
10+
use crate::target_checking::Policy::Allow;
1011

1112
pub(crate) struct CoroutineParser;
1213

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ use super::{
88
AcceptMapping, AttributeOrder, AttributeParser, CombineAttributeParser, ConvertFn,
99
NoArgsAttributeParser, OnDuplicate, SingleAttributeParser,
1010
};
11-
use crate::context::MaybeWarn::{Allow, Warn};
12-
use crate::context::{AcceptContext, AllowedTargets, FinalizeContext, Stage};
11+
use crate::context::{AcceptContext, FinalizeContext, Stage};
1312
use crate::parser::ArgParser;
1413
use crate::session_diagnostics::{NakedFunctionIncompatibleAttribute, NullOnExport};
14+
use crate::target_checking::AllowedTargets;
15+
use crate::target_checking::Policy::{Allow, Warn};
1516

1617
pub(crate) struct OptimizeParser;
1718

compiler/rustc_attr_parsing/src/attributes/confusables.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ use rustc_span::{Span, Symbol, sym};
55
use thin_vec::ThinVec;
66

77
use super::{AcceptMapping, AttributeParser};
8-
use crate::context::MaybeWarn::Allow;
9-
use crate::context::{AllowedTargets, FinalizeContext, Stage};
8+
use crate::context::{FinalizeContext, Stage};
109
use crate::session_diagnostics;
10+
use crate::target_checking::AllowedTargets;
11+
use crate::target_checking::Policy::Allow;
12+
1113
#[derive(Default)]
1214
pub(crate) struct ConfusablesParser {
1315
confusables: ThinVec<Symbol>,

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ use rustc_span::{Span, Symbol, sym};
55

66
use super::util::parse_version;
77
use super::{AttributeOrder, OnDuplicate, SingleAttributeParser};
8-
use crate::context::MaybeWarn::{Allow, Error};
9-
use crate::context::{AcceptContext, AllowedTargets, Stage};
8+
use crate::context::{AcceptContext, Stage};
109
use crate::parser::ArgParser;
1110
use crate::session_diagnostics;
11+
use crate::target_checking::AllowedTargets;
12+
use crate::target_checking::Policy::{Allow, Error};
13+
1214
pub(crate) struct DeprecationParser;
1315

1416
fn get<S: Stage>(

compiler/rustc_attr_parsing/src/attributes/dummy.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ use rustc_hir::attrs::AttributeKind;
33
use rustc_span::{Symbol, sym};
44

55
use crate::attributes::{AttributeOrder, OnDuplicate, SingleAttributeParser};
6-
use crate::context::{ALL_TARGETS, AcceptContext, AllowedTargets, Stage};
6+
use crate::context::{AcceptContext, Stage};
77
use crate::parser::ArgParser;
8+
use crate::target_checking::{ALL_TARGETS, AllowedTargets};
9+
810
pub(crate) struct DummyParser;
911
impl<S: Stage> SingleAttributeParser<S> for DummyParser {
1012
const PATH: &[Symbol] = &[sym::rustc_dummy];

compiler/rustc_attr_parsing/src/attributes/inline.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ use rustc_span::{Symbol, sym};
1010

1111
use super::{AcceptContext, AttributeOrder, OnDuplicate};
1212
use crate::attributes::SingleAttributeParser;
13-
use crate::context::MaybeWarn::{Allow, Warn};
14-
use crate::context::{AllowedTargets, Stage};
13+
use crate::context::Stage;
1514
use crate::parser::ArgParser;
15+
use crate::target_checking::AllowedTargets;
16+
use crate::target_checking::Policy::{Allow, Warn};
17+
1618
pub(crate) struct InlineParser;
1719

1820
impl<S: Stage> SingleAttributeParser<S> for InlineParser {

compiler/rustc_attr_parsing/src/attributes/link_attrs.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ use rustc_span::{Span, Symbol, sym};
77
use crate::attributes::{
88
AttributeOrder, NoArgsAttributeParser, OnDuplicate, SingleAttributeParser,
99
};
10-
use crate::context::MaybeWarn::Allow;
11-
use crate::context::{ALL_TARGETS, AcceptContext, AllowedTargets, Stage, parse_single_integer};
10+
use crate::context::{AcceptContext, Stage};
1211
use crate::parser::ArgParser;
1312
use crate::session_diagnostics::{LinkOrdinalOutOfRange, NullOnLinkSection};
13+
use crate::target_checking::Policy::Allow;
14+
use crate::target_checking::{ALL_TARGETS, AllowedTargets};
15+
16+
use super::util::parse_single_integer;
17+
1418
pub(crate) struct LinkNameParser;
1519

1620
impl<S: Stage> SingleAttributeParser<S> for LinkNameParser {

0 commit comments

Comments
 (0)