aboutsummaryrefslogtreecommitdiff
path: root/tests/ui/project/ambiguous-let.rs
blob: a7067494ecbb1576c9f5cb510c4cf975f51e1414 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use pin_project::{pin_project, project};

#[pin_project]
enum Enum<A, B> {
    A(#[pin] A),
    B(B),
}

struct Struct<T>(T);

#[project]
fn foo() {
    let mut foo: Enum<bool, bool> = Enum::A(true);

    #[project]
    let Struct(x) = match Pin::new(&mut foo).project() {
        //~^ ERROR Both initializer expression and pattern are replaceable, you need to split the initializer expression into separate let bindings to avoid ambiguity
        Enum::A(_) => Struct(true),
        Enum::B(_) => unreachable!(),
    };
    assert!(x);
}

fn main() {}