Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs')
-rw-r--r--crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs52
1 files changed, 52 insertions, 0 deletions
diff --git a/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs b/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs
index e31367f3b1..c86ecd2f03 100644
--- a/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs
+++ b/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs
@@ -155,4 +155,56 @@ fn test(x: Foo<(i32, bool)>) {
"#,
);
}
+
+ #[test]
+ fn uninhabited_variants() {
+ check_diagnostics(
+ r#"
+//- minicore: result
+enum Infallible {}
+
+trait Foo {
+ type Bar;
+}
+
+struct Wrapper<T> {
+ error: T,
+}
+
+struct FooWrapper<T: Foo> {
+ error: T::Bar,
+}
+
+fn foo<T: Foo<Bar = Infallible>>(result: Result<T, T::Bar>) -> T {
+ let Ok(ok) = result;
+ ok
+}
+
+fn bar<T: Foo<Bar = Infallible>>(result: Result<T, (T::Bar,)>) -> T {
+ let Ok(ok) = result;
+ ok
+}
+
+fn baz<T: Foo<Bar = Infallible>>(result: Result<T, Wrapper<T::Bar>>) -> T {
+ let Ok(ok) = result;
+ ok
+}
+
+fn qux<T: Foo<Bar = Infallible>>(result: Result<T, FooWrapper<T>>) -> T {
+ let Ok(ok) = result;
+ ok
+}
+
+fn quux<T: Foo<Bar = Infallible>>(result: Result<T, [T::Bar; 1]>) -> T {
+ let Ok(ok) = result;
+ ok
+}
+
+fn corge<T: Foo<Bar = Infallible>>(result: Result<T, (i32, T::Bar)>) -> T {
+ let Ok(ok) = result;
+ ok
+}
+"#,
+ );
+ }
}