Files
rust/tests/ui/parser/attribute/multiple-tail-expr-behind-cfg.rs
Nicholas Nethercote c6748782af Add a case to the multiple-tail-expr-behind-cfg.rs test
This demonstrates the `if cfg!(..)` suggestion being applied wrongly,
when a `cfg` attribute is followed by a non-`cfg` attribute.
2026-07-13 16:24:52 +10:00

27 lines
653 B
Rust

#![feature(stmt_expr_attributes)]
fn foo() -> String {
#[cfg(false)]
[1, 2, 3].iter().map(|c| c.to_string()).collect::<String>() //~ ERROR expected `;`, found `#`
#[cfg(not(FALSE))]
String::new()
}
fn bar() -> String {
#[attr]
[1, 2, 3].iter().map(|c| c.to_string()).collect::<String>() //~ ERROR expected `;`, found `#`
#[attr] //~ ERROR cannot find attribute `attr` in this scope
String::new()
}
fn baz() -> String {
#[cfg(false)]
[1, 2, 3].iter().map(|c| c.to_string()).collect::<String>() //~ ERROR expected `;`, found `#`
#[allow(unused)]
String::new()
}
fn main() {
println!("{}", foo());
}