diff options
Diffstat (limited to 'third_party/rust/pin-project/tests/ui/project/ambiguous-let.rs')
-rw-r--r-- | third_party/rust/pin-project/tests/ui/project/ambiguous-let.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/third_party/rust/pin-project/tests/ui/project/ambiguous-let.rs b/third_party/rust/pin-project/tests/ui/project/ambiguous-let.rs new file mode 100644 index 0000000000..a7067494ec --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/project/ambiguous-let.rs @@ -0,0 +1,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() {} |