File: recover-pat-issues.rs

package info (click to toggle)
rustc 1.87.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 925,564 kB
  • sloc: xml: 158,127; python: 36,039; javascript: 19,761; sh: 19,737; cpp: 18,981; ansic: 13,133; asm: 4,376; makefile: 710; perl: 29; lisp: 28; ruby: 19; sql: 11
file content (46 lines) | stat: -rw-r--r-- 1,026 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
struct Foo(String);
struct Bar { baz: String }

fn foo(foo: Foo) -> bool {
    match foo {
        Foo("hi".to_owned()) => true,
        //~^ error: expected a pattern, found an expression
        _ => false
    }
}

fn bar(bar: Bar) -> bool {
    match bar {
        Bar { baz: "hi".to_owned() } => true,
        //~^ error: expected a pattern, found an expression
        _ => false
    }
}

/// Issue #90121
fn baz() {
    let foo = vec!["foo".to_string()];

    match foo.as_slice() {
        &["foo".to_string()] => {}
        //~^ error: expected a pattern, found an expression
        _ => {}
    };
}

/// Issue #104996
fn qux() {
    struct Magic(pub u16);
    const MAGIC: Magic = Magic(42);

    if let Some(MAGIC.0 as usize) = None::<usize> {}
    //~^ error: expected a pattern, found an expression
}

fn main() {
    if let (-1.some(4)) = (0, Some(4)) {}
    //~^ error: expected a pattern, found an expression

    if let (-1.Some(4)) = (0, Some(4)) {}
    //~^ error: expected a pattern, found an expression
}