11use std:: collections:: HashSet ;
2+ use std:: sync:: LazyLock ;
23
34use crate :: common:: { CompareMode , Config , Debugger } ;
45use crate :: directives:: { DirectiveLine , IgnoreDecision } ;
56
67const EXTRA_ARCHS : & [ & str ] = & [ "spirv" ] ;
78
9+ const EXTERNAL_IGNORES_LIST : & [ & str ] = & [
10+ // tidy-alphabetical-start
11+ "ignore-backends" ,
12+ "ignore-gdb-version" ,
13+ "ignore-llvm-version" ,
14+ "ignore-pass" ,
15+ // tidy-alphabetical-end
16+ ] ;
17+
18+ /// Directive names that begin with `ignore-`, but are disregarded by this
19+ /// module because they are handled elsewhere.
20+ pub ( crate ) static EXTERNAL_IGNORES_SET : LazyLock < HashSet < & str > > =
21+ LazyLock :: new ( || EXTERNAL_IGNORES_LIST . iter ( ) . copied ( ) . collect ( ) ) ;
22+
823pub ( super ) fn handle_ignore ( config : & Config , line : & DirectiveLine < ' _ > ) -> IgnoreDecision {
924 let parsed = parse_cfg_name_directive ( config, line, "ignore-" ) ;
1025 let line = line. display ( ) ;
@@ -18,8 +33,7 @@ pub(super) fn handle_ignore(config: &Config, line: &DirectiveLine<'_>) -> Ignore
1833 } ,
1934 } ,
2035 MatchOutcome :: Invalid => IgnoreDecision :: Error { message : format ! ( "invalid line: {line}" ) } ,
21- MatchOutcome :: External => IgnoreDecision :: Continue ,
22- MatchOutcome :: NotADirective => IgnoreDecision :: Continue ,
36+ MatchOutcome :: NotHandledHere => IgnoreDecision :: Continue ,
2337 }
2438}
2539
@@ -38,8 +52,7 @@ pub(super) fn handle_only(config: &Config, line: &DirectiveLine<'_>) -> IgnoreDe
3852 } ,
3953 } ,
4054 MatchOutcome :: Invalid => IgnoreDecision :: Error { message : format ! ( "invalid line: {line}" ) } ,
41- MatchOutcome :: External => IgnoreDecision :: Continue ,
42- MatchOutcome :: NotADirective => IgnoreDecision :: Continue ,
55+ MatchOutcome :: NotHandledHere => IgnoreDecision :: Continue ,
4356 }
4457}
4558
@@ -51,9 +64,13 @@ fn parse_cfg_name_directive<'a>(
5164 prefix : & str ,
5265) -> ParsedNameDirective < ' a > {
5366 let Some ( name) = line. name . strip_prefix ( prefix) else {
54- return ParsedNameDirective :: not_a_directive ( ) ;
67+ return ParsedNameDirective :: not_handled_here ( ) ;
5568 } ;
5669
70+ if prefix == "ignore-" && EXTERNAL_IGNORES_SET . contains ( line. name ) {
71+ return ParsedNameDirective :: not_handled_here ( ) ;
72+ }
73+
5774 // FIXME(Zalathar): This currently allows either a space or a colon, and
5875 // treats any "value" after a colon as though it were a remark.
5976 // We should instead forbid the colon syntax for these directives.
@@ -62,7 +79,7 @@ fn parse_cfg_name_directive<'a>(
6279 // Some of the matchers might be "" depending on what the target information is. To avoid
6380 // problems we outright reject empty directives.
6481 if name. is_empty ( ) {
65- return ParsedNameDirective :: not_a_directive ( ) ;
82+ return ParsedNameDirective :: not_handled_here ( ) ;
6683 }
6784
6885 let mut outcome = MatchOutcome :: Invalid ;
@@ -256,35 +273,6 @@ fn parse_cfg_name_directive<'a>(
256273 message: "when performing tests on dist toolchain"
257274 }
258275
259- if prefix == "ignore-" && outcome == MatchOutcome :: Invalid {
260- // Don't error out for ignore-tidy-* diretives, as those are not handled by compiletest.
261- if name. starts_with ( "tidy-" ) {
262- outcome = MatchOutcome :: External ;
263- }
264-
265- // Don't error out for ignore-pass, as that is handled elsewhere.
266- if name == "pass" {
267- outcome = MatchOutcome :: External ;
268- }
269-
270- // Don't error out for ignore-llvm-version, that has a custom syntax and is handled
271- // elsewhere.
272- if name == "llvm-version" {
273- outcome = MatchOutcome :: External ;
274- }
275-
276- // Don't error out for ignore-llvm-version, that has a custom syntax and is handled
277- // elsewhere.
278- if name == "gdb-version" {
279- outcome = MatchOutcome :: External ;
280- }
281-
282- // Don't error out for ignore-backends,as it is handled elsewhere.
283- if name == "backends" {
284- outcome = MatchOutcome :: External ;
285- }
286- }
287-
288276 ParsedNameDirective {
289277 name : Some ( name) ,
290278 comment : comment. map ( |c| c. trim ( ) . trim_start_matches ( '-' ) . trim ( ) ) ,
@@ -303,12 +291,12 @@ pub(super) struct ParsedNameDirective<'a> {
303291}
304292
305293impl ParsedNameDirective < ' _ > {
306- fn not_a_directive ( ) -> Self {
294+ fn not_handled_here ( ) -> Self {
307295 Self {
308296 name : None ,
309297 pretty_reason : None ,
310298 comment : None ,
311- outcome : MatchOutcome :: NotADirective ,
299+ outcome : MatchOutcome :: NotHandledHere ,
312300 }
313301 }
314302}
@@ -321,10 +309,8 @@ pub(super) enum MatchOutcome {
321309 Match ,
322310 /// The directive was invalid.
323311 Invalid ,
324- /// The directive is handled by other parts of our tooling.
325- External ,
326- /// The line is not actually a directive.
327- NotADirective ,
312+ /// The directive should be ignored by this module, because it is handled elsewhere.
313+ NotHandledHere ,
328314}
329315
330316trait CustomContains {
0 commit comments