tests/ui: prepare some tests for --check-cfg by default

This commit is contained in:
Urgau 2024-04-24 22:06:54 +02:00
parent d6d3b342e8
commit ed81578820
9 changed files with 33 additions and 38 deletions

View File

@ -1,22 +1,19 @@
// Test that `-Cinstrument-coverage=off` does not add coverage instrumentation to LLVM IR.
//@ needs-profiler-support
//@ revisions: n no off false zero
//@ revisions: n no off false_ zero
//@ [n] compile-flags: -Cinstrument-coverage=n
//@ [no] compile-flags: -Cinstrument-coverage=no
//@ [off] compile-flags: -Cinstrument-coverage=off
//@ [false] compile-flags: -Cinstrument-coverage=false
//@ [false_] compile-flags: -Cinstrument-coverage=false
//@ [zero] compile-flags: -Cinstrument-coverage=0
// CHECK-NOT: __llvm_profile_filename
// CHECK-NOT: __llvm_coverage_mapping
#![crate_type="lib"]
#![crate_type = "lib"]
#[inline(never)]
fn some_function() {
}
fn some_function() {}
pub fn some_other_function() {
some_function();

View File

@ -1,12 +1,12 @@
// Test that `-Cinstrument-coverage` creates expected __llvm_profile_filename symbol in LLVM IR.
//@ needs-profiler-support
//@ revisions: default y yes on true all
//@ revisions: default y yes on true_ all
//@ [default] compile-flags: -Cinstrument-coverage
//@ [y] compile-flags: -Cinstrument-coverage=y
//@ [yes] compile-flags: -Cinstrument-coverage=yes
//@ [on] compile-flags: -Cinstrument-coverage=on
//@ [true] compile-flags: -Cinstrument-coverage=true
//@ [true_] compile-flags: -Cinstrument-coverage=true
//@ [all] compile-flags: -Cinstrument-coverage=all
// CHECK: @__llvm_profile_filename = {{.*}}"default_%m_%p.profraw\00"{{.*}}

View File

@ -1,13 +1,13 @@
#[cfg(target(os = "x"))] //~ ERROR compact `cfg(target(..))` is experimental
#[cfg(target(os = "linux"))] //~ ERROR compact `cfg(target(..))` is experimental
struct Foo(u64, u64);
#[cfg_attr(target(os = "x"), x)] //~ ERROR compact `cfg(target(..))` is experimental
#[cfg_attr(target(os = "linux"), non_exhaustive)] //~ ERROR compact `cfg(target(..))` is experimental
struct Bar(u64, u64);
#[cfg(not(any(all(target(os = "x")))))] //~ ERROR compact `cfg(target(..))` is experimental
#[cfg(not(any(all(target(os = "linux")))))] //~ ERROR compact `cfg(target(..))` is experimental
fn foo() {}
fn main() {
cfg!(target(os = "x"));
cfg!(target(os = "linux"));
//~^ ERROR compact `cfg(target(..))` is experimental and subject to change
}

View File

@ -1,8 +1,8 @@
error[E0658]: compact `cfg(target(..))` is experimental and subject to change
--> $DIR/feature-gate-cfg-target-compact.rs:1:7
|
LL | #[cfg(target(os = "x"))]
| ^^^^^^^^^^^^^^^^
LL | #[cfg(target(os = "linux"))]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information
= help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable
@ -11,8 +11,8 @@ LL | #[cfg(target(os = "x"))]
error[E0658]: compact `cfg(target(..))` is experimental and subject to change
--> $DIR/feature-gate-cfg-target-compact.rs:4:12
|
LL | #[cfg_attr(target(os = "x"), x)]
| ^^^^^^^^^^^^^^^^
LL | #[cfg_attr(target(os = "linux"), non_exhaustive)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information
= help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable
@ -21,8 +21,8 @@ LL | #[cfg_attr(target(os = "x"), x)]
error[E0658]: compact `cfg(target(..))` is experimental and subject to change
--> $DIR/feature-gate-cfg-target-compact.rs:7:19
|
LL | #[cfg(not(any(all(target(os = "x")))))]
| ^^^^^^^^^^^^^^^^
LL | #[cfg(not(any(all(target(os = "linux")))))]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information
= help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable
@ -31,8 +31,8 @@ LL | #[cfg(not(any(all(target(os = "x")))))]
error[E0658]: compact `cfg(target(..))` is experimental and subject to change
--> $DIR/feature-gate-cfg-target-compact.rs:11:10
|
LL | cfg!(target(os = "x"));
| ^^^^^^^^^^^^^^^^
LL | cfg!(target(os = "linux"));
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information
= help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable

View File

@ -1,11 +1,11 @@
//@ check-pass
//@ needs-profiler-support
//@ revisions: default y yes on true all
//@ revisions: default y yes on true_ all
//@ [default] compile-flags: -Cinstrument-coverage
//@ [y] compile-flags: -Cinstrument-coverage=y
//@ [yes] compile-flags: -Cinstrument-coverage=yes
//@ [on] compile-flags: -Cinstrument-coverage=on
//@ [true] compile-flags: -Cinstrument-coverage=true
//@ [true_] compile-flags: -Cinstrument-coverage=true
//@ [all] compile-flags: -Cinstrument-coverage=all
fn main() {}

View File

@ -1,9 +1,8 @@
//@ run-pass
#![allow(dead_code)]
//@ compile-flags: --cfg foo
//@ pretty-expanded FIXME #23616
#![allow(dead_code)]
struct Foo {
#[cfg(FALSE)]
bar: baz,
@ -11,7 +10,7 @@ struct Foo {
}
struct Foo2 {
#[cfg(foo)]
#[cfg(all())]
foo: isize,
}

View File

@ -1,7 +1,6 @@
//@ check-pass
//@ compile-flags:--cfg set1
#![cfg_attr(set1, feature(rustc_attrs))]
#![cfg_attr(all(), feature(rustc_attrs))]
#![rustc_dummy]
fn main() {}

View File

@ -16,7 +16,7 @@ macro_rules! emit {
}
// item
compiles_fine!(bar);
compiles_fine!(FALSE);
emit!(foo);
fn foo() {
@ -25,7 +25,7 @@ fn foo() {
pub fn main() {
// statement
compiles_fine!(baz);
emit!(baz);
compiles_fine!(FALSE);
emit!(FALSE);
println!("{}", MISTYPED);
}

View File

@ -14,11 +14,11 @@ pub fn main() {
if cfg!(not(all(foo, qux="foo"))) { panic!() }
if cfg!(all(not(all(foo, qux="foo")))) { panic!() }
if cfg!(not_a_cfg) { panic!() }
if cfg!(all(not_a_cfg, foo, qux="foo")) { panic!() }
if cfg!(all(not_a_cfg, foo, qux="foo")) { panic!() }
if ! cfg!(any(not_a_cfg, foo)) { panic!() }
if cfg!(FALSE) { panic!() }
if cfg!(all(FALSE, foo, qux="foo")) { panic!() }
if cfg!(all(FALSE, foo, qux="foo")) { panic!() }
if ! cfg!(any(FALSE, foo)) { panic!() }
if ! cfg!(not(not_a_cfg)) { panic!() }
if ! cfg!(all(not(not_a_cfg), foo, qux="foo")) { panic!() }
if ! cfg!(not(FALSE)) { panic!() }
if ! cfg!(all(not(FALSE), foo, qux="foo")) { panic!() }
}