mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-22 03:44:24 +00:00
compiletest: add enable-by-default check-cfg
This commit is contained in:
parent
517374150c
commit
d4e26fbb53
@ -1028,12 +1028,31 @@ impl<'test> TestCx<'test> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_revision_flags(&self, cmd: &mut Command) {
|
fn set_revision_flags(&self, cmd: &mut Command) {
|
||||||
|
// Normalize revisions to be lowercase and replace `-`s with `_`s.
|
||||||
|
// Otherwise the `--cfg` flag is not valid.
|
||||||
|
let normalize_revision = |revision: &str| revision.to_lowercase().replace("-", "_");
|
||||||
|
|
||||||
if let Some(revision) = self.revision {
|
if let Some(revision) = self.revision {
|
||||||
// Normalize revisions to be lowercase and replace `-`s with `_`s.
|
let normalized_revision = normalize_revision(revision);
|
||||||
// Otherwise the `--cfg` flag is not valid.
|
|
||||||
let normalized_revision = revision.to_lowercase().replace("-", "_");
|
|
||||||
cmd.args(&["--cfg", &normalized_revision]);
|
cmd.args(&["--cfg", &normalized_revision]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.props.no_auto_check_cfg {
|
||||||
|
let mut check_cfg = String::with_capacity(25);
|
||||||
|
|
||||||
|
// Generate `cfg(FALSE, REV1, ..., REVN)` (for all possible revisions)
|
||||||
|
//
|
||||||
|
// For compatibility reason we consider the `FALSE` cfg to be expected
|
||||||
|
// since it is extensively used in the testsuite.
|
||||||
|
check_cfg.push_str("cfg(FALSE");
|
||||||
|
for revision in &self.props.revisions {
|
||||||
|
check_cfg.push_str(",");
|
||||||
|
check_cfg.push_str(&normalize_revision(&revision));
|
||||||
|
}
|
||||||
|
check_cfg.push_str(")");
|
||||||
|
|
||||||
|
cmd.args(&["--check-cfg", &check_cfg]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn typecheck_source(&self, src: String) -> ProcRes {
|
fn typecheck_source(&self, src: String) -> ProcRes {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// Check to see if we can get parameters from an @argsfile file
|
// Check to see if we can get parameters from an @argsfile file
|
||||||
//
|
//
|
||||||
//@ check-pass
|
//@ check-pass
|
||||||
//@ compile-flags: --cfg cmdline_set @{{src-base}}/argfile/commandline-argfile.args
|
//@ compile-flags: --cfg cmdline_set --check-cfg=cfg(cmdline_set,unbroken)
|
||||||
|
//@ compile-flags: @{{src-base}}/argfile/commandline-argfile.args
|
||||||
|
|
||||||
#[cfg(not(cmdline_set))]
|
#[cfg(not(cmdline_set))]
|
||||||
compile_error!("cmdline_set not set");
|
compile_error!("cmdline_set not set");
|
||||||
@ -9,5 +10,4 @@ compile_error!("cmdline_set not set");
|
|||||||
#[cfg(not(unbroken))]
|
#[cfg(not(unbroken))]
|
||||||
compile_error!("unbroken not set");
|
compile_error!("unbroken not set");
|
||||||
|
|
||||||
fn main() {
|
fn main() {}
|
||||||
}
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// Check to see if we can get parameters from an @argsfile file
|
// Check to see if we can get parameters from an @argsfile file
|
||||||
//
|
//
|
||||||
//@ build-pass
|
//@ build-pass
|
||||||
//@ compile-flags: --cfg cmdline_set @{{src-base}}/argfile/commandline-argfile.args
|
//@ compile-flags: --cfg cmdline_set --check-cfg=cfg(cmdline_set,unbroken)
|
||||||
|
//@ compile-flags: @{{src-base}}/argfile/commandline-argfile.args
|
||||||
|
|
||||||
#[cfg(not(cmdline_set))]
|
#[cfg(not(cmdline_set))]
|
||||||
compile_error!("cmdline_set not set");
|
compile_error!("cmdline_set not set");
|
||||||
@ -9,5 +10,4 @@ compile_error!("cmdline_set not set");
|
|||||||
#[cfg(not(unbroken))]
|
#[cfg(not(unbroken))]
|
||||||
compile_error!("unbroken not set");
|
compile_error!("unbroken not set");
|
||||||
|
|
||||||
fn main() {
|
fn main() {}
|
||||||
}
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
//@ compile-flags: --cfg bar -D warnings
|
//@ compile-flags: --cfg bar --check-cfg=cfg(bar) -D warnings
|
||||||
|
|
||||||
#![cfg(bar)]
|
#![cfg(bar)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
//@ compile-flags: --cfg foo
|
//@ compile-flags: --cfg foo --check-cfg=cfg(foo)
|
||||||
|
|
||||||
// check that cfg correctly chooses between the macro impls (see also
|
// check that cfg correctly chooses between the macro impls (see also
|
||||||
// cfg-macros-notfoo.rs)
|
// cfg-macros-notfoo.rs)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
//@ check-fail
|
//@ check-fail
|
||||||
|
|
||||||
|
#![allow(unexpected_cfgs)] // invalid cfgs
|
||||||
|
|
||||||
#[cfg(any(foo, foo::bar))]
|
#[cfg(any(foo, foo::bar))]
|
||||||
//~^ERROR `cfg` predicate key must be an identifier
|
//~^ERROR `cfg` predicate key must be an identifier
|
||||||
fn foo1() {}
|
fn foo1() {}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
error: `cfg` predicate key must be an identifier
|
error: `cfg` predicate key must be an identifier
|
||||||
--> $DIR/cfg-path-error.rs:3:16
|
--> $DIR/cfg-path-error.rs:5:16
|
||||||
|
|
|
|
||||||
LL | #[cfg(any(foo, foo::bar))]
|
LL | #[cfg(any(foo, foo::bar))]
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: `cfg` predicate key must be an identifier
|
error: `cfg` predicate key must be an identifier
|
||||||
--> $DIR/cfg-path-error.rs:7:11
|
--> $DIR/cfg-path-error.rs:9:11
|
||||||
|
|
|
|
||||||
LL | #[cfg(any(foo::bar, foo))]
|
LL | #[cfg(any(foo::bar, foo))]
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: `cfg` predicate key must be an identifier
|
error: `cfg` predicate key must be an identifier
|
||||||
--> $DIR/cfg-path-error.rs:11:16
|
--> $DIR/cfg-path-error.rs:13:16
|
||||||
|
|
|
|
||||||
LL | #[cfg(all(foo, foo::bar))]
|
LL | #[cfg(all(foo, foo::bar))]
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: `cfg` predicate key must be an identifier
|
error: `cfg` predicate key must be an identifier
|
||||||
--> $DIR/cfg-path-error.rs:15:11
|
--> $DIR/cfg-path-error.rs:17:11
|
||||||
|
|
|
|
||||||
LL | #[cfg(all(foo::bar, foo))]
|
LL | #[cfg(all(foo::bar, foo))]
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
//@ compile-flags:--cfg set1 --cfg set2
|
//@ compile-flags:--cfg set1 --cfg set2
|
||||||
#![allow(dead_code)]
|
|
||||||
|
#![allow(dead_code, unexpected_cfgs)]
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
struct NotDebugable;
|
struct NotDebugable;
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
//@ compile-flags: --cfg fooA --cfg fooB
|
//@ compile-flags: --cfg fooA --cfg fooB --check-cfg=cfg(fooA,fooB,fooC,bar)
|
||||||
|
|
||||||
// fooA AND !bar
|
// fooA AND !bar
|
||||||
|
|
||||||
#[cfg(all(fooA, not(bar)))]
|
#[cfg(all(fooA, not(bar)))]
|
||||||
fn foo1() -> isize { 1 }
|
fn foo1() -> isize { 1 }
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
|
#![feature(lint_reasons)]
|
||||||
|
|
||||||
pub mod inner {
|
pub mod inner {
|
||||||
|
#[expect(unexpected_cfgs)]
|
||||||
pub fn i_am_here() {
|
pub fn i_am_here() {
|
||||||
#[cfg(feature = "another one that doesn't exist")]
|
#[cfg(feature = "another one that doesn't exist")]
|
||||||
loop {}
|
loop {}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error[E0425]: cannot find function `i_am_not` in module `inner`
|
error[E0425]: cannot find function `i_am_not` in module `inner`
|
||||||
--> $DIR/diagnostics-not-a-def.rs:11:12
|
--> $DIR/diagnostics-not-a-def.rs:14:12
|
||||||
|
|
|
|
||||||
LL | inner::i_am_not();
|
LL | inner::i_am_not();
|
||||||
| ^^^^^^^^ not found in `inner`
|
| ^^^^^^^^ not found in `inner`
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#![allow(unexpected_cfgs)] // since we want to recognize them as unexpected
|
||||||
|
|
||||||
pub mod inner {
|
pub mod inner {
|
||||||
#[cfg(FALSE)]
|
#[cfg(FALSE)]
|
||||||
pub fn uwu() {}
|
pub fn uwu() {}
|
||||||
|
@ -1,72 +1,72 @@
|
|||||||
error[E0432]: unresolved import `super::inner::doesnt_exist`
|
error[E0432]: unresolved import `super::inner::doesnt_exist`
|
||||||
--> $DIR/diagnostics-same-crate.rs:28:9
|
--> $DIR/diagnostics-same-crate.rs:30:9
|
||||||
|
|
|
|
||||||
LL | use super::inner::doesnt_exist;
|
LL | use super::inner::doesnt_exist;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `doesnt_exist` in `inner`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `doesnt_exist` in `inner`
|
||||||
|
|
|
|
||||||
note: found an item that was configured out
|
note: found an item that was configured out
|
||||||
--> $DIR/diagnostics-same-crate.rs:7:13
|
--> $DIR/diagnostics-same-crate.rs:9:13
|
||||||
|
|
|
|
||||||
LL | pub mod doesnt_exist {
|
LL | pub mod doesnt_exist {
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0432]: unresolved import `super::inner::doesnt_exist`
|
error[E0432]: unresolved import `super::inner::doesnt_exist`
|
||||||
--> $DIR/diagnostics-same-crate.rs:31:23
|
--> $DIR/diagnostics-same-crate.rs:33:23
|
||||||
|
|
|
|
||||||
LL | use super::inner::doesnt_exist::hi;
|
LL | use super::inner::doesnt_exist::hi;
|
||||||
| ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner`
|
| ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner`
|
||||||
|
|
|
|
||||||
note: found an item that was configured out
|
note: found an item that was configured out
|
||||||
--> $DIR/diagnostics-same-crate.rs:7:13
|
--> $DIR/diagnostics-same-crate.rs:9:13
|
||||||
|
|
|
|
||||||
LL | pub mod doesnt_exist {
|
LL | pub mod doesnt_exist {
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner`
|
error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner`
|
||||||
--> $DIR/diagnostics-same-crate.rs:50:12
|
--> $DIR/diagnostics-same-crate.rs:52:12
|
||||||
|
|
|
|
||||||
LL | inner::doesnt_exist::hello();
|
LL | inner::doesnt_exist::hello();
|
||||||
| ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner`
|
| ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner`
|
||||||
|
|
|
|
||||||
note: found an item that was configured out
|
note: found an item that was configured out
|
||||||
--> $DIR/diagnostics-same-crate.rs:7:13
|
--> $DIR/diagnostics-same-crate.rs:9:13
|
||||||
|
|
|
|
||||||
LL | pub mod doesnt_exist {
|
LL | pub mod doesnt_exist {
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0425]: cannot find function `uwu` in module `inner`
|
error[E0425]: cannot find function `uwu` in module `inner`
|
||||||
--> $DIR/diagnostics-same-crate.rs:45:12
|
--> $DIR/diagnostics-same-crate.rs:47:12
|
||||||
|
|
|
|
||||||
LL | inner::uwu();
|
LL | inner::uwu();
|
||||||
| ^^^ not found in `inner`
|
| ^^^ not found in `inner`
|
||||||
|
|
|
|
||||||
note: found an item that was configured out
|
note: found an item that was configured out
|
||||||
--> $DIR/diagnostics-same-crate.rs:3:12
|
--> $DIR/diagnostics-same-crate.rs:5:12
|
||||||
|
|
|
|
||||||
LL | pub fn uwu() {}
|
LL | pub fn uwu() {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error[E0425]: cannot find function `meow` in module `inner::right`
|
error[E0425]: cannot find function `meow` in module `inner::right`
|
||||||
--> $DIR/diagnostics-same-crate.rs:54:19
|
--> $DIR/diagnostics-same-crate.rs:56:19
|
||||||
|
|
|
|
||||||
LL | inner::right::meow();
|
LL | inner::right::meow();
|
||||||
| ^^^^ not found in `inner::right`
|
| ^^^^ not found in `inner::right`
|
||||||
|
|
|
|
||||||
note: found an item that was configured out
|
note: found an item that was configured out
|
||||||
--> $DIR/diagnostics-same-crate.rs:22:16
|
--> $DIR/diagnostics-same-crate.rs:24:16
|
||||||
|
|
|
|
||||||
LL | pub fn meow() {}
|
LL | pub fn meow() {}
|
||||||
| ^^^^
|
| ^^^^
|
||||||
= note: the item is gated behind the `what-a-cool-feature` feature
|
= note: the item is gated behind the `what-a-cool-feature` feature
|
||||||
|
|
||||||
error[E0425]: cannot find function `uwu` in this scope
|
error[E0425]: cannot find function `uwu` in this scope
|
||||||
--> $DIR/diagnostics-same-crate.rs:41:5
|
--> $DIR/diagnostics-same-crate.rs:43:5
|
||||||
|
|
|
|
||||||
LL | uwu();
|
LL | uwu();
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
||||||
error[E0425]: cannot find function `vanished` in this scope
|
error[E0425]: cannot find function `vanished` in this scope
|
||||||
--> $DIR/diagnostics-same-crate.rs:61:5
|
--> $DIR/diagnostics-same-crate.rs:63:5
|
||||||
|
|
|
|
||||||
LL | vanished();
|
LL | vanished();
|
||||||
| ^^^^^^^^ not found in this scope
|
| ^^^^^^^^ not found in this scope
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
//@ check-pass
|
//@ check-pass
|
||||||
|
|
||||||
|
#![allow(unexpected_cfgs)] // since we different cfgs
|
||||||
|
|
||||||
macro_rules! mac {
|
macro_rules! mac {
|
||||||
{} => {
|
{} => {
|
||||||
#[cfg(attr)]
|
#[cfg(attr)]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//@ check-fail
|
//@ check-fail
|
||||||
//@ compile-flags:--cfg foo
|
//@ compile-flags:--cfg foo --check-cfg=cfg(foo)
|
||||||
|
|
||||||
#![cfg_attr(foo, crate_type="bin")]
|
#![cfg_attr(foo, crate_type="bin")]
|
||||||
//~^ERROR `crate_type` within
|
//~^ERROR `crate_type` within
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
//
|
|
||||||
//@ error-pattern: `main` function not found
|
//@ error-pattern: `main` function not found
|
||||||
//@ compile-flags: --cfg foo
|
//@ compile-flags: --cfg foo --check-cfg=cfg(foo,bar)
|
||||||
|
|
||||||
// main is conditionally compiled, but the conditional compilation
|
// main is conditionally compiled, but the conditional compilation
|
||||||
// is conditional too!
|
// is conditional too!
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error[E0601]: `main` function not found in crate `cfg_attr_cfg_2`
|
error[E0601]: `main` function not found in crate `cfg_attr_cfg_2`
|
||||||
--> $DIR/cfg-attr-cfg-2.rs:9:14
|
--> $DIR/cfg-attr-cfg-2.rs:8:14
|
||||||
|
|
|
|
||||||
LL | fn main() { }
|
LL | fn main() { }
|
||||||
| ^ consider adding a `main` function to `$DIR/cfg-attr-cfg-2.rs`
|
| ^ consider adding a `main` function to `$DIR/cfg-attr-cfg-2.rs`
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044
|
// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044
|
||||||
|
|
||||||
//@ compile-flags: --cfg broken
|
//@ compile-flags: --cfg broken --check-cfg=cfg(broken)
|
||||||
|
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
#![cfg_attr(broken, no_core)] //~ ERROR the `#[no_core]` attribute is an experimental feature
|
#![cfg_attr(broken, no_core)] //~ ERROR the `#[no_core]` attribute is an experimental feature
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//@ compile-flags: --cfg broken
|
//@ compile-flags: --cfg broken --check-cfg=cfg(broken)
|
||||||
|
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
#![cfg_attr(broken, no_core, no_std)]
|
#![cfg_attr(broken, no_core, no_std)]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//@ compile-flags: --cfg broken
|
//@ compile-flags: --cfg broken --check-cfg=cfg(broken)
|
||||||
|
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
#![cfg_attr(broken, no_std, no_core)]
|
#![cfg_attr(broken, no_std, no_core)]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//@ compile-flags:--cfg yes
|
//@ compile-flags:--cfg yes --check-cfg=cfg(yes,no)
|
||||||
|
|
||||||
fn f_lt<#[cfg(yes)] 'a: 'a, #[cfg(FALSE)] T>() {}
|
fn f_lt<#[cfg(yes)] 'a: 'a, #[cfg(FALSE)] T>() {}
|
||||||
fn f_ty<#[cfg(FALSE)] 'a: 'a, #[cfg(yes)] T>() {}
|
fn f_ty<#[cfg(FALSE)] 'a: 'a, #[cfg(yes)] T>() {}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//@ compile-flags: --cfg foo
|
//@ compile-flags: --cfg foo --check-cfg=cfg(foo,bar)
|
||||||
|
|
||||||
#[cfg(all(foo, bar))] // foo AND bar
|
#[cfg(all(foo, bar))] // foo AND bar
|
||||||
fn foo() {}
|
fn foo() {}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//@ build-pass (FIXME(62277): could be check-pass?)
|
//@ build-pass (FIXME(62277): could be check-pass?)
|
||||||
//@ compile-flags:--cfg my_feature
|
//@ compile-flags:--cfg my_feature --check-cfg=cfg(my_feature)
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ fn assert_ne() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(unexpected_cfgs)]
|
||||||
fn cfg() {
|
fn cfg() {
|
||||||
let _ = cfg!(pants);
|
let _ = cfg!(pants);
|
||||||
let _ = cfg!(pants,);
|
let _ = cfg!(pants,);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
|
//@ compile-flags: --cfg foo --check-cfg=cfg(foo)
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
//@ compile-flags: --cfg foo
|
|
||||||
|
|
||||||
macro_rules! compiles_fine {
|
macro_rules! compiles_fine {
|
||||||
($at:meta) => {
|
($at:meta) => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
//@ compile-flags: --cfg foo
|
//@ compile-flags: --cfg foo --check-cfg=cfg(foo)
|
||||||
|
|
||||||
|
|
||||||
#[cfg(foo)]
|
#[cfg(foo)]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
//@ compile-flags: --cfg foo --cfg qux="foo"
|
//@ compile-flags: --cfg foo --cfg qux="foo"
|
||||||
|
//@ compile-flags: --check-cfg=cfg(foo) --check-cfg=cfg(qux,values("foo"))
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
// check
|
// check
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
//@ revisions: b00001 b00010 b00011 b00100 b00101 b00110 b00111 b01000 b01001 b01100 b01101 b10000 b10001 b10010 b10011 b10101 b10111 b11000 b11001 b11101
|
//@ revisions: b00001 b00010 b00011 b00100 b00101 b00110 b00111 b01000 b01001 b01100 b01101 b10000 b10001 b10010 b10011 b10101 b10111 b11000 b11001 b11101
|
||||||
|
|
||||||
|
//@ compile-flags: --check-cfg=cfg(inherent_mut,bar_for_foo,mutbar_for_foo)
|
||||||
|
//@ compile-flags: --check-cfg=cfg(valbar_for_et_foo,valbar_for_etmut_foo)
|
||||||
|
|
||||||
//@[b00001]compile-flags: --cfg inherent_mut
|
//@[b00001]compile-flags: --cfg inherent_mut
|
||||||
//@[b00010]compile-flags: --cfg bar_for_foo
|
//@[b00010]compile-flags: --cfg bar_for_foo
|
||||||
//@[b00011]compile-flags: --cfg inherent_mut --cfg bar_for_foo
|
//@[b00011]compile-flags: --cfg inherent_mut --cfg bar_for_foo
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
//@ compile-flags: -Zdeduplicate-diagnostics=yes
|
//@ compile-flags: -Zdeduplicate-diagnostics=yes
|
||||||
//@ run-rustfix
|
//@ run-rustfix
|
||||||
|
|
||||||
|
#![allow(unexpected_cfgs)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(key="foo")]
|
#[cfg(key="foo")]
|
||||||
//~^ ERROR expected unsuffixed literal, found `foo`
|
//~^ ERROR expected unsuffixed literal, found `foo`
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
//@ compile-flags: -Zdeduplicate-diagnostics=yes
|
//@ compile-flags: -Zdeduplicate-diagnostics=yes
|
||||||
//@ run-rustfix
|
//@ run-rustfix
|
||||||
|
|
||||||
|
#![allow(unexpected_cfgs)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(key=foo)]
|
#[cfg(key=foo)]
|
||||||
//~^ ERROR expected unsuffixed literal, found `foo`
|
//~^ ERROR expected unsuffixed literal, found `foo`
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error: expected unsuffixed literal, found `foo`
|
error: expected unsuffixed literal, found `foo`
|
||||||
--> $DIR/attr-unquoted-ident.rs:5:15
|
--> $DIR/attr-unquoted-ident.rs:7:15
|
||||||
|
|
|
|
||||||
LL | #[cfg(key=foo)]
|
LL | #[cfg(key=foo)]
|
||||||
| ^^^
|
| ^^^
|
||||||
@ -10,7 +10,7 @@ LL | #[cfg(key="foo")]
|
|||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: expected unsuffixed literal, found `foo`
|
error: expected unsuffixed literal, found `foo`
|
||||||
--> $DIR/attr-unquoted-ident.rs:11:15
|
--> $DIR/attr-unquoted-ident.rs:13:15
|
||||||
|
|
|
|
||||||
LL | #[cfg(key=foo bar baz)]
|
LL | #[cfg(key=foo bar baz)]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// attempting to bootstrap librustc with new destructor lifetime
|
// attempting to bootstrap librustc with new destructor lifetime
|
||||||
// semantics.
|
// semantics.
|
||||||
|
|
||||||
|
#![allow(unexpected_cfgs)] // for the cfg-as-descriptions
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
//@ run-rustfix
|
//@ run-rustfix
|
||||||
//@ compile-flags: --cfg=whatever -Aunused
|
//@ compile-flags: -Aunused
|
||||||
|
|
||||||
use y::z;
|
use y::z;
|
||||||
#[cfg(whatever)]
|
#[cfg(all())]
|
||||||
use y::Whatever;
|
use y::Whatever;
|
||||||
|
|
||||||
mod y {
|
mod y {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//@ run-rustfix
|
//@ run-rustfix
|
||||||
//@ compile-flags: --cfg=whatever -Aunused
|
//@ compile-flags: -Aunused
|
||||||
|
|
||||||
#[cfg(whatever)]
|
#[cfg(all())]
|
||||||
use y::Whatever;
|
use y::Whatever;
|
||||||
|
|
||||||
mod y {
|
mod y {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//@ check-pass
|
//@ check-pass
|
||||||
//@ compile-flags: --cfg something
|
//@ compile-flags: --cfg something --check-cfg=cfg(nothing,something)
|
||||||
|
|
||||||
#![deny(unused_mut)]
|
#![deny(unused_mut)]
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//@ compile-flags: --cfg something
|
//@ compile-flags: --cfg something --check-cfg=cfg(nothing,something)
|
||||||
//@ edition:2018
|
//@ edition:2018
|
||||||
|
|
||||||
#![feature(async_closure)]
|
#![feature(async_closure)]
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
//@ edition:2018
|
//@ edition:2018
|
||||||
|
|
||||||
#![deny(rust_2018_idioms)]
|
#![deny(rust_2018_idioms)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code, unexpected_cfgs)]
|
||||||
|
|
||||||
// The suggestion span should include the attribute.
|
// The suggestion span should include the attribute.
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
//@ edition:2018
|
//@ edition:2018
|
||||||
|
|
||||||
#![deny(rust_2018_idioms)]
|
#![deny(rust_2018_idioms)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code, unexpected_cfgs)]
|
||||||
|
|
||||||
// The suggestion span should include the attribute.
|
// The suggestion span should include the attribute.
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Check to see if we can get parameters from an @argsfile file
|
// Check to see if we can get parameters from an @argsfile file
|
||||||
//
|
//
|
||||||
//@ build-pass
|
//@ build-pass
|
||||||
|
//@ no-auto-check-cfg
|
||||||
//@ compile-flags: @{{src-base}}/shell-argfiles/shell-argfiles-via-argfile.args @shell:{{src-base}}/shell-argfiles/shell-argfiles-via-argfile-shell.args
|
//@ compile-flags: @{{src-base}}/shell-argfiles/shell-argfiles-via-argfile.args @shell:{{src-base}}/shell-argfiles/shell-argfiles-via-argfile-shell.args
|
||||||
|
|
||||||
#[cfg(not(shell_args_set))]
|
#[cfg(not(shell_args_set))]
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
--cfg unquoted_set
|
--cfg unquoted_set
|
||||||
'--cfg' 'single_quoted_set'
|
'--cfg' 'single_quoted_set'
|
||||||
"--cfg" "double_quoted_set"
|
"--cfg" "double_quoted_set"
|
||||||
|
--check-cfg 'cfg(cmdline_set, unquoted_set, single_quoted_set, double_quoted_set)'
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#![allow(stable_features)]
|
#![allow(stable_features)]
|
||||||
#![feature(cfg_target_feature)]
|
#![feature(cfg_target_feature)]
|
||||||
|
#![feature(lint_reasons)]
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ fn main() {
|
|||||||
"SSE2 was not detected as available on an x86 platform");
|
"SSE2 was not detected as available on an x86 platform");
|
||||||
}
|
}
|
||||||
// check a negative case too -- certainly not enabled by default
|
// check a negative case too -- certainly not enabled by default
|
||||||
assert!(cfg!(not(target_feature = "ferris_wheel")),
|
#[expect(unexpected_cfgs)]
|
||||||
"🎡 shouldn't be detected as available by default on any platform");
|
{ assert!(cfg!(not(target_feature = "ferris_wheel")),
|
||||||
|
"🎡 shouldn't be detected as available by default on any platform") };
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
//@ build-pass
|
//@ build-pass
|
||||||
#![no_core]
|
#![no_core]
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![feature(intrinsics, rustc_attrs, no_core, lang_items, staged_api)]
|
#![feature(intrinsics, rustc_attrs, no_core, lang_items, staged_api, lint_reasons)]
|
||||||
#![stable(feature = "test", since = "1.0.0")]
|
#![stable(feature = "test", since = "1.0.0")]
|
||||||
|
|
||||||
// Supporting minimal rust core code
|
// Supporting minimal rust core code
|
||||||
@ -43,22 +43,30 @@ macro_rules! assert {
|
|||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
fn check_aarch64() {
|
fn check_aarch64() {
|
||||||
// This checks that the rustc feature name is used, not the LLVM feature.
|
// These checks that the rustc feature name is used, not the LLVM feature.
|
||||||
|
|
||||||
assert!(cfg!(target_feature = "neon"));
|
assert!(cfg!(target_feature = "neon"));
|
||||||
assert!(cfg!(not(target_feature = "fp-armv8")));
|
// #[expect(unexpected_cfgs)] except that 32-bit arm actually use fp-armv8
|
||||||
|
{ assert!(cfg!(not(target_feature = "fp-armv8"))); }
|
||||||
|
|
||||||
assert!(cfg!(target_feature = "fhm"));
|
assert!(cfg!(target_feature = "fhm"));
|
||||||
assert!(cfg!(not(target_feature = "fp16fml")));
|
#[expect(unexpected_cfgs)]
|
||||||
|
{ assert!(cfg!(not(target_feature = "fp16fml"))); }
|
||||||
|
|
||||||
assert!(cfg!(target_feature = "fp16"));
|
assert!(cfg!(target_feature = "fp16"));
|
||||||
assert!(cfg!(not(target_feature = "fullfp16")));
|
#[expect(unexpected_cfgs)]
|
||||||
|
{ assert!(cfg!(not(target_feature = "fullfp16"))); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn check_x86_64() {
|
fn check_x86_64() {
|
||||||
// This checks that the rustc feature name is used, not the LLVM feature.
|
// This checks that the rustc feature name is used, not the LLVM feature.
|
||||||
assert!(cfg!(target_feature = "rdrand"));
|
assert!(cfg!(target_feature = "rdrand"));
|
||||||
assert!(cfg!(not(target_feature = "rdrnd")));
|
#[expect(unexpected_cfgs)]
|
||||||
|
{ assert!(cfg!(not(target_feature = "rdrnd"))); }
|
||||||
|
|
||||||
// Likewise: We enable LLVM's crc32 feature with SSE4.2, but Rust says it's just SSE4.2
|
// Likewise: We enable LLVM's crc32 feature with SSE4.2, but Rust says it's just SSE4.2
|
||||||
assert!(cfg!(target_feature = "sse4.2"));
|
assert!(cfg!(target_feature = "sse4.2"));
|
||||||
assert!(cfg!(not(target_feature = "crc32")));
|
#[expect(unexpected_cfgs)]
|
||||||
|
{ assert!(cfg!(not(target_feature = "crc32"))); }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user