2025-07-04 23:56:16 +02:00
|
|
|
#![feature(cfg_select)]
|
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
|
|
fn print() {
|
|
|
|
|
println!(cfg_select! {
|
|
|
|
|
unix => { "unix" }
|
|
|
|
|
_ => { "not unix" }
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-10 16:17:26 -07:00
|
|
|
fn print_2() {
|
|
|
|
|
println!(cfg_select! {
|
|
|
|
|
unix => "unix",
|
|
|
|
|
_ => "not unix",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn arm_rhs_expr_1() -> i32 {
|
2025-07-04 23:56:16 +02:00
|
|
|
cfg_select! {
|
|
|
|
|
true => 1
|
2025-08-10 16:17:26 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn arm_rhs_expr_2() -> i32 {
|
|
|
|
|
cfg_select! {
|
|
|
|
|
true => 1,
|
|
|
|
|
false => 2
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn arm_rhs_expr_3() -> i32 {
|
|
|
|
|
cfg_select! {
|
|
|
|
|
true => 1,
|
|
|
|
|
false => 2,
|
|
|
|
|
true => { 42 }
|
|
|
|
|
false => -1 as i32,
|
|
|
|
|
true => 2 + 2,
|
|
|
|
|
false => "",
|
|
|
|
|
true => if true { 42 } else { 84 }
|
|
|
|
|
false => if true { 42 } else { 84 },
|
|
|
|
|
true => return 42,
|
|
|
|
|
false => loop {}
|
|
|
|
|
true => (1, 2),
|
|
|
|
|
false => (1, 2,),
|
|
|
|
|
true => todo!(),
|
|
|
|
|
false => println!("hello"),
|
2025-07-04 23:56:16 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cfg_select! {
|
|
|
|
|
_ => {}
|
|
|
|
|
true => {}
|
2025-07-14 11:03:16 +02:00
|
|
|
//~^ WARN unreachable predicate
|
2025-07-04 23:56:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cfg_select! {
|
2025-07-14 11:03:16 +02:00
|
|
|
//~^ ERROR none of the predicates in this `cfg_select` evaluated to true
|
2025-07-04 23:56:16 +02:00
|
|
|
false => {}
|
|
|
|
|
}
|
2025-07-14 11:03:16 +02:00
|
|
|
|
|
|
|
|
cfg_select! {}
|
|
|
|
|
//~^ ERROR none of the predicates in this `cfg_select` evaluated to true
|