Warn on redundant --cfg
directive when revisions are used · rust-lang/rust@d82a21f (original) (raw)
File tree
6 files changed
lines changed
- src/tools/compiletest/src
6 files changed
lines changed
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
@@ -468,7 +468,19 @@ impl<'test> TestCx<'test> { | |||
468 | 468 | ||
469 | 469 | if let Some(revision) = self.revision { | |
470 | 470 | let normalized_revision = normalize_revision(revision); | |
471 | - cmd.args(&["--cfg", &normalized_revision]); | ||
471 | +let cfg_arg = ["--cfg", &normalized_revision]; | ||
472 | +let arg = format!("--cfg={normalized_revision}"); | ||
473 | +if self | ||
474 | +.props | ||
475 | +.compile_flags | ||
476 | +.windows(2) | ||
477 | +.any(|args | args == cfg_arg | |
478 | +{ | ||
479 | +panic!( | ||
480 | +"error: redundant cfg argument `{normalized_revision}` is already created by the revision" | ||
481 | +); | ||
482 | +} | ||
483 | + cmd.args(cfg_arg); | ||
472 | 484 | } | |
473 | 485 | ||
474 | 486 | if !self.props.no_auto_check_cfg { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,8 +2,6 @@ | ||
2 | 2 | //@ compile-flags: -Copt-level=3 -Cdebug-assertions=no -Zub-checks=yes |
3 | 3 | //@ error-pattern: unsafe precondition(s) violated: Layout::from_size_align_unchecked requires |
4 | 4 | //@ revisions: toolarge badalign |
5 | -//@[toolarge] compile-flags: --cfg toolarge | |
6 | -//@[badalign] compile-flags: --cfg badalign | |
7 | 5 | |
8 | 6 | fn main() { |
9 | 7 | unsafe { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -5,19 +5,19 @@ | ||
5 | 5 | //@ revisions: address cfi kcfi leak memory thread |
6 | 6 | //@compile-flags: -Ctarget-feature=-crt-static |
7 | 7 | //@[address]needs-sanitizer-address |
8 | -//@[address]compile-flags: -Zsanitizer=address --cfg address | |
8 | +//@[address]compile-flags: -Zsanitizer=address | |
9 | 9 | //@[cfi]needs-sanitizer-cfi |
10 | -//@[cfi]compile-flags: -Zsanitizer=cfi --cfg cfi | |
10 | +//@[cfi]compile-flags: -Zsanitizer=cfi | |
11 | 11 | //@[cfi]compile-flags: -Clto -Ccodegen-units=1 |
12 | 12 | //@[kcfi]needs-llvm-components: x86 |
13 | -//@[kcfi]compile-flags: -Zsanitizer=kcfi --cfg kcfi --target x86_64-unknown-none | |
13 | +//@[kcfi]compile-flags: -Zsanitizer=kcfi --target x86_64-unknown-none | |
14 | 14 | //@[kcfi]compile-flags: -C panic=abort |
15 | 15 | //@[leak]needs-sanitizer-leak |
16 | -//@[leak]compile-flags: -Zsanitizer=leak --cfg leak | |
16 | +//@[leak]compile-flags: -Zsanitizer=leak | |
17 | 17 | //@[memory]needs-sanitizer-memory |
18 | -//@[memory]compile-flags: -Zsanitizer=memory --cfg memory | |
18 | +//@[memory]compile-flags: -Zsanitizer=memory | |
19 | 19 | //@[thread]needs-sanitizer-thread |
20 | -//@[thread]compile-flags: -Zsanitizer=thread --cfg thread | |
20 | +//@[thread]compile-flags: -Zsanitizer=thread | |
21 | 21 | |
22 | 22 | #![feature(cfg_sanitize, no_core, lang_items)] |
23 | 23 | #![crate_type="lib"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,7 +4,7 @@ | ||
4 | 4 | // For some reason, Rust 2018 or higher is required to reproduce the bug. |
5 | 5 | //@ run-rustfix |
6 | 6 | //@ revisions: no_std std |
7 | -//@ [no_std]compile-flags: --cfg=no_std -C panic=abort | |
7 | +//@ [no_std]compile-flags: -C panic=abort | |
8 | 8 | #![cfg_attr(no_std, no_std)] |
9 | 9 | |
10 | 10 | use core::num::NonZero; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,7 +4,7 @@ | ||
4 | 4 | // For some reason, Rust 2018 or higher is required to reproduce the bug. |
5 | 5 | //@ run-rustfix |
6 | 6 | //@ revisions: no_std std |
7 | -//@ [no_std]compile-flags: --cfg=no_std -C panic=abort | |
7 | +//@ [no_std]compile-flags: -C panic=abort | |
8 | 8 | #![cfg_attr(no_std, no_std)] |
9 | 9 | |
10 | 10 | fn main() { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,7 +4,7 @@ | ||
4 | 4 | // For some reason, Rust 2018 or higher is required to reproduce the bug. |
5 | 5 | //@ run-rustfix |
6 | 6 | //@ revisions: no_std std |
7 | -//@ [no_std]compile-flags: --cfg=no_std -C panic=abort | |
7 | +//@ [no_std]compile-flags: -C panic=abort | |
8 | 8 | #![cfg_attr(no_std, no_std)] |
9 | 9 | |
10 | 10 | use std::num::NonZero; |