Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do some preparation work for compiletest check-cfg #123577

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/ui/asm/inline-syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#![feature(no_core, lang_items, rustc_attrs)]
#![crate_type = "rlib"]
#![no_core]
#![cfg_attr(x86_64_allowed, allow(bad_asm_style))]


#[rustc_builtin_macro]
macro_rules! asm {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/cfg/cfg-attr-cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

//@ pretty-expanded FIXME #23616

#[cfg_attr(foo, cfg(bar))]
#[cfg_attr(FALSE, cfg(bar))]
fn main() { }
2 changes: 1 addition & 1 deletion tests/ui/cfg/cfg-attr-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

//@ pretty-expanded FIXME #23616

#![cfg_attr(not_used, no_core)]
#![cfg_attr(FALSE, no_core)]

fn main() { }
6 changes: 2 additions & 4 deletions tests/ui/cfg/cfg-macros-notfoo.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
//@ run-pass
//@ compile-flags:

// check that cfg correctly chooses between the macro impls (see also
// cfg-macros-foo.rs)


#[cfg(foo)]
#[cfg(FALSE)]
#[macro_use]
mod foo {
macro_rules! bar {
() => { true }
}
}

#[cfg(not(foo))]
#[cfg(not(FALSE))]
#[macro_use]
mod foo {
macro_rules! bar {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/cfg/cfg-match-arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ enum Foo {
fn foo(f: Foo) {
match f {
Foo::Bar => {},
#[cfg(not(asdfa))]
#[cfg(not(FALSE))]
Foo::Baz => {},
#[cfg(afsd)]
#[cfg(FALSE)]
Basdfwe => {}
}
}
Expand Down
4 changes: 0 additions & 4 deletions tests/ui/cfg/cfg-panic-abort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
//@ compile-flags: -C panic=abort
//@ no-prefer-dynamic


#[cfg(panic = "unwind")]
pub fn bad() -> i32 { }

#[cfg(not(panic = "abort"))]
pub fn bad() -> i32 { }

#[cfg(panic = "some_imaginary_future_panic_handler")]
pub fn bad() -> i32 { }

#[cfg(panic = "abort")]
pub fn main() { }
4 changes: 0 additions & 4 deletions tests/ui/cfg/cfg-panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
//@ compile-flags: -C panic=unwind
//@ needs-unwind


#[cfg(panic = "abort")]
pub fn bad() -> i32 { }

#[cfg(not(panic = "unwind"))]
pub fn bad() -> i32 { }

#[cfg(panic = "some_imaginary_future_panic_handler")]
pub fn bad() -> i32 { }

#[cfg(panic = "unwind")]
pub fn main() { }
34 changes: 17 additions & 17 deletions tests/ui/cfg/cfg_stmt_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,49 @@

fn main() {
let a = 413;
#[cfg(unset)]
#[cfg(FALSE)]
let a = ();
assert_eq!(a, 413);

let mut b = 612;
#[cfg(unset)]
#[cfg(FALSE)]
{
b = 1111;
}
assert_eq!(b, 612);

#[cfg(unset)]
#[cfg(FALSE)]
undefined_fn();

#[cfg(unset)]
#[cfg(FALSE)]
undefined_macro!();
#[cfg(unset)]
#[cfg(FALSE)]
undefined_macro![];
#[cfg(unset)]
#[cfg(FALSE)]
undefined_macro!{};

// pretty printer bug...
// #[cfg(unset)]
// #[cfg(FALSE)]
// undefined_macro!{}

let () = (#[cfg(unset)] 341,); // Should this also work on parens?
let t = (1, #[cfg(unset)] 3, 4);
let () = (#[cfg(FALSE)] 341,); // Should this also work on parens?
let t = (1, #[cfg(FALSE)] 3, 4);
assert_eq!(t, (1, 4));

let f = |_: u32, _: u32| ();
f(2, 1, #[cfg(unset)] 6);
f(2, 1, #[cfg(FALSE)] 6);

let _: u32 = a.clone(#[cfg(unset)] undefined);
let _: u32 = a.clone(#[cfg(FALSE)] undefined);

let _: [(); 0] = [#[cfg(unset)] 126];
let t = [#[cfg(unset)] 1, 2, 6];
let _: [(); 0] = [#[cfg(FALSE)] 126];
let t = [#[cfg(FALSE)] 1, 2, 6];
assert_eq!(t, [2, 6]);

{
let r;
#[cfg(unset)]
#[cfg(FALSE)]
(r = 5);
#[cfg(not(unset))]
#[cfg(not(FALSE))]
(r = 10);
assert_eq!(r, 10);
}
Expand All @@ -69,13 +69,13 @@ fn main() {
}
}

let n = if_cfg!(unset? {
let n = if_cfg!(FALSE? {
413
} else {
612
});

assert_eq!((#[cfg(unset)] 1, #[cfg(not(unset))] 2), (2,));
assert_eq!((#[cfg(FALSE)] 1, #[cfg(not(FALSE))] 2), (2,));
assert_eq!(n, 612);

// check that lints work
Expand Down
44 changes: 22 additions & 22 deletions tests/ui/cfg/conditional-compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@

// Crate use statements

#[cfg(bogus)]
#[cfg(FALSE)]
use flippity;

#[cfg(bogus)]
#[cfg(FALSE)]
static b: bool = false;

static b: bool = true;

mod rustrt {
#[cfg(bogus)]
#[cfg(FALSE)]
extern "C" {
// This symbol doesn't exist and would be a link error if this
// module was codegened
pub fn bogus();
pub fn FALSE();
}

extern "C" {}
}

#[cfg(bogus)]
#[cfg(FALSE)]
type t = isize;

type t = bool;

#[cfg(bogus)]
#[cfg(FALSE)]
enum tg {
foo,
}
Expand All @@ -39,12 +39,12 @@ enum tg {
bar,
}

#[cfg(bogus)]
#[cfg(FALSE)]
struct r {
i: isize,
}

#[cfg(bogus)]
#[cfg(FALSE)]
fn r(i: isize) -> r {
r { i: i }
}
Expand All @@ -57,34 +57,34 @@ fn r(i: isize) -> r {
r { i: i }
}

#[cfg(bogus)]
#[cfg(FALSE)]
mod m {
// This needs to parse but would fail in typeck. Since it's not in
// the current config it should not be typechecked.
pub fn bogus() {
pub fn FALSE() {
return 0;
}
}

mod m {
// Submodules have slightly different code paths than the top-level
// module, so let's make sure this jazz works here as well
#[cfg(bogus)]
#[cfg(FALSE)]
pub fn f() {}

pub fn f() {}
}

// Since the bogus configuration isn't defined main will just be
// Since the FALSE configuration isn't defined main will just be
// parsed, but nothing further will be done with it
#[cfg(bogus)]
#[cfg(FALSE)]
pub fn main() {
panic!()
}

pub fn main() {
// Exercise some of the configured items in ways that wouldn't be possible
// if they had the bogus definition
// if they had the FALSE definition
assert!((b));
let _x: t = true;
let _y: tg = tg::bar;
Expand All @@ -93,14 +93,14 @@ pub fn main() {
}

fn test_in_fn_ctxt() {
#[cfg(bogus)]
#[cfg(FALSE)]
fn f() {
panic!()
}
fn f() {}
f();

#[cfg(bogus)]
#[cfg(FALSE)]
static i: isize = 0;
static i: isize = 1;
assert_eq!(i, 1);
Expand All @@ -109,15 +109,15 @@ fn test_in_fn_ctxt() {
mod test_foreign_items {
pub mod rustrt {
extern "C" {
#[cfg(bogus)]
#[cfg(FALSE)]
pub fn write() -> String;
pub fn write() -> String;
}
}
}

mod test_use_statements {
#[cfg(bogus)]
#[cfg(FALSE)]
use flippity_foo;
}

Expand All @@ -127,24 +127,24 @@ mod test_methods {
}

impl Fooable for Foo {
#[cfg(bogus)]
#[cfg(FALSE)]
fn what(&self) {}

fn what(&self) {}

#[cfg(bogus)]
#[cfg(FALSE)]
fn the(&self) {}

fn the(&self) {}
}

trait Fooable {
#[cfg(bogus)]
#[cfg(FALSE)]
fn what(&self);

fn what(&self);

#[cfg(bogus)]
#[cfg(FALSE)]
fn the(&self);

fn the(&self);
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/cfg/diagnostics-reexport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub use a::x;
//~| NOTE no `x` in `a`

mod a {
#[cfg(no)]
#[cfg(FALSE)]
pub fn x() {}
//~^ NOTE found an item that was configured out
}
Expand All @@ -25,10 +25,10 @@ pub use b::{x, y};
//~| NOTE no `y` in `b`

mod b {
#[cfg(no)]
#[cfg(FALSE)]
pub fn x() {}
//~^ NOTE found an item that was configured out
#[cfg(no)]
#[cfg(FALSE)]
pub fn y() {}
//~^ NOTE found an item that was configured out
}
Expand Down
4 changes: 1 addition & 3 deletions tests/ui/conditional-compilation/cfg-attr-empty-is-unused.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Check that `#[cfg_attr($PREDICATE,)]` triggers the `unused_attribute` lint.

//@ compile-flags: --cfg TRUE

#![deny(unused)]

#[cfg_attr(FALSE,)] //~ ERROR `#[cfg_attr]` does not expand to any attributes
fn _f() {}

#[cfg_attr(TRUE,)] //~ ERROR `#[cfg_attr]` does not expand to any attributes
#[cfg_attr(not(FALSE),)] //~ ERROR `#[cfg_attr]` does not expand to any attributes
fn _g() {}

fn main() {}
10 changes: 5 additions & 5 deletions tests/ui/conditional-compilation/cfg-attr-empty-is-unused.stderr
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
error: `#[cfg_attr]` does not expand to any attributes
--> $DIR/cfg-attr-empty-is-unused.rs:7:1
--> $DIR/cfg-attr-empty-is-unused.rs:5:1
|
LL | #[cfg_attr(FALSE,)]
| ^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/cfg-attr-empty-is-unused.rs:5:9
--> $DIR/cfg-attr-empty-is-unused.rs:3:9
|
LL | #![deny(unused)]
| ^^^^^^
= note: `#[deny(unused_attributes)]` implied by `#[deny(unused)]`

error: `#[cfg_attr]` does not expand to any attributes
--> $DIR/cfg-attr-empty-is-unused.rs:10:1
--> $DIR/cfg-attr-empty-is-unused.rs:8:1
|
LL | #[cfg_attr(TRUE,)]
| ^^^^^^^^^^^^^^^^^^
LL | #[cfg_attr(not(FALSE),)]
| ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

2 changes: 1 addition & 1 deletion tests/ui/conditional-compilation/cfg-in-crate-1.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//@ error-pattern: `main` function not found

#![cfg(bar)]
#![cfg(FALSE)]
Loading
Loading