mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-02 17:44:28 +00:00
This demonstrates the `if cfg!(..)` suggestion being applied wrongly, when a `cfg` attribute is followed by a non-`cfg` attribute.
27 lines
653 B
Rust
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());
|
|
}
|