summaryrefslogtreecommitdiffstats
path: root/tests/ui/implied-bounds
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/implied-bounds')
-rw-r--r--tests/ui/implied-bounds/implied-bounds-unconstrained-1.rs28
-rw-r--r--tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs20
-rw-r--r--tests/ui/implied-bounds/references-err.rs22
-rw-r--r--tests/ui/implied-bounds/references-err.stderr9
4 files changed, 79 insertions, 0 deletions
diff --git a/tests/ui/implied-bounds/implied-bounds-unconstrained-1.rs b/tests/ui/implied-bounds/implied-bounds-unconstrained-1.rs
new file mode 100644
index 000000000..025e5176f
--- /dev/null
+++ b/tests/ui/implied-bounds/implied-bounds-unconstrained-1.rs
@@ -0,0 +1,28 @@
+// check-pass
+
+// Regression test for #112832.
+pub trait QueryDb {
+ type Db;
+}
+
+pub struct QueryTable<Q, DB> {
+ db: DB,
+ storage: Q,
+}
+
+// We normalize `<Q as QueryDb>::Db` to `<Q as AsyncQueryFunction<'d>>::SendDb`
+// using the where-bound. 'd is an unconstrained region variable which previously
+// triggered an assert.
+impl<Q> QueryTable<Q, <Q as QueryDb>::Db> where Q: for<'d> AsyncQueryFunction<'d> {}
+
+pub trait AsyncQueryFunction<'d>: QueryDb<Db = <Self as AsyncQueryFunction<'d>>::SendDb> {
+ type SendDb: 'd;
+}
+
+pub trait QueryStorageOpsAsync<Q>
+where
+ Q: for<'d> AsyncQueryFunction<'d>,
+{
+}
+
+fn main() {}
diff --git a/tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs b/tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs
new file mode 100644
index 000000000..976054fac
--- /dev/null
+++ b/tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs
@@ -0,0 +1,20 @@
+// check-pass
+
+// Another minimized regression test for #112832.
+trait Trait {
+ type Assoc;
+}
+
+trait Sub<'a>: Trait<Assoc = <Self as Sub<'a>>::SubAssoc> {
+ type SubAssoc;
+}
+
+// By using the where-clause we normalize `<T as Trait>::Assoc` to
+// `<T as Sub<'a>>::SubAssoc` where `'a` is an unconstrained region
+// variable.
+fn foo<T>(x: <T as Trait>::Assoc)
+where
+ for<'a> T: Sub<'a>,
+{}
+
+fn main() {}
diff --git a/tests/ui/implied-bounds/references-err.rs b/tests/ui/implied-bounds/references-err.rs
new file mode 100644
index 000000000..203d512e3
--- /dev/null
+++ b/tests/ui/implied-bounds/references-err.rs
@@ -0,0 +1,22 @@
+trait Identity {
+ type Identity;
+}
+impl<T> Identity for T {
+ type Identity = T;
+}
+
+trait Trait {
+ type Assoc: Identity;
+ fn tokenize(&self) -> <Self::Assoc as Identity>::Identity;
+}
+
+impl Trait for () {
+ type Assoc = DoesNotExist;
+ //~^ ERROR cannot find type `DoesNotExist` in this scope
+
+ fn tokenize(&self) -> <Self::Assoc as Identity>::Identity {
+ unimplemented!()
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/implied-bounds/references-err.stderr b/tests/ui/implied-bounds/references-err.stderr
new file mode 100644
index 000000000..6076eea3c
--- /dev/null
+++ b/tests/ui/implied-bounds/references-err.stderr
@@ -0,0 +1,9 @@
+error[E0412]: cannot find type `DoesNotExist` in this scope
+ --> $DIR/references-err.rs:14:18
+ |
+LL | type Assoc = DoesNotExist;
+ | ^^^^^^^^^^^^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0412`.