summary refs log tree commit diff
path: root/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs
blob: 225891e390ff5c63bbcd89ca8333f883508269b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
struct Website {
    url: String,
    title: Option<String>,
}

fn main() {
    let website = Website {
        url: "http://www.example.com".into(),
        title: Some("Example Domain".into()),
    };

    if let Website { url, Some(title) } = website { //~ ERROR expected `,`
        //~^ NOTE while parsing the fields for this pattern
        println!("[{}]({})", title, url); // we hide the errors for `title` and `url`
    }

    if let Website { url, .. } = website { //~ NOTE this pattern
        println!("[{}]({})", title, url); //~ ERROR cannot find value `title` in this scope
        //~^ NOTE not found in this scope
    }
}