rust/tests/ui/parser/method-call-on-struct-literal-in-if-condition.rs
León Orell Valerian Liehr 82796dd858
Brace-ident-colon can certainly no longer start a block
thanks to the removal of type ascription.
2025-03-25 15:15:21 +01:00

13 lines
254 B
Rust

pub struct Example { a: i32 }
impl Example {
fn is_pos(&self) -> bool { self.a > 0 }
}
fn one() -> i32 { 1 }
fn main() {
if Example { a: one(), }.is_pos() { //~ ERROR struct literals are not allowed here
println!("Positive!");
}
}