summaryrefslogtreecommitdiffstats
path: root/tests/ui/implied-bounds
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
commita0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch)
treefc451898ccaf445814e26b46664d78702178101d /tests/ui/implied-bounds
parentAdding debian version 1.71.1+dfsg1-2. (diff)
downloadrustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.tar.xz
rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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`.