about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-03-22 08:27:14 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2024-03-22 08:27:14 +0100
commit2b5740371c42c632efb3dbe46150798baf56a8d1 (patch)
treeb42c8dbbee503fb194bc6135de95991257b73e68
parent4d9ce7a1a2f78e26b58c4464f43aab21100ea1f3 (diff)
downloadrust-2b5740371c42c632efb3dbe46150798baf56a8d1.tar.gz
rust-2b5740371c42c632efb3dbe46150798baf56a8d1.zip
add test for https://github.com/rust-lang/rust/issues/112823
Fixes #112823
-rw-r--r--tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs30
-rw-r--r--tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.stderr31
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs
new file mode 100644
index 00000000000..d6fa56663a3
--- /dev/null
+++ b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs
@@ -0,0 +1,30 @@
+// test for ICE #112823
+// Unexpected parameter Type(Repr) when substituting in region
+
+#![feature(impl_trait_in_assoc_type)]
+
+use std::future::Future;
+
+trait Stream {}
+
+trait X {
+    type LineStream<'a, Repr>
+    where
+        Self: 'a;
+    type LineStreamFut<'a, Repr>
+    where
+        Self: 'a;
+}
+
+struct Y;
+
+impl X for Y {
+    type LineStream<'c, 'd> = impl Stream;
+    //~^ ERROR type `LineStream` has 0 type parameters but its trait declaration has 1 type parameter
+    type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>>;
+    fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {}
+    //~^ ERROR `()` is not a future
+    //~^^ method `line_stream` is not a member of trait `X`
+}
+
+pub fn main() {}
diff --git a/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.stderr b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.stderr
new file mode 100644
index 00000000000..28a0f7461e2
--- /dev/null
+++ b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.stderr
@@ -0,0 +1,31 @@
+error[E0407]: method `line_stream` is not a member of trait `X`
+  --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:5
+   |
+LL |     fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {}
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `X`
+
+error[E0049]: type `LineStream` has 0 type parameters but its trait declaration has 1 type parameter
+  --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:22:21
+   |
+LL |     type LineStream<'a, Repr>
+   |                     --  ----
+   |                     |
+   |                     expected 1 type parameter
+...
+LL |     type LineStream<'c, 'd> = impl Stream;
+   |                     ^^  ^^
+   |                     |
+   |                     found 0 type parameters
+
+error[E0277]: `()` is not a future
+  --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:43
+   |
+LL |     fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {}
+   |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future
+   |
+   = help: the trait `Future` is not implemented for `()`
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0049, E0277, E0407.
+For more information about an error, try `rustc --explain E0049`.