rust/tests/ui/parser/method-call-on-struct-literal-in-if-condition.rs
2023-01-11 16:53:21 +00:00

14 lines
240 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 invalid struct literal
println!("Positive!");
}
}