Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/tests/regression.rs')
-rw-r--r--crates/hir-ty/src/tests/regression.rs104
1 files changed, 93 insertions, 11 deletions
diff --git a/crates/hir-ty/src/tests/regression.rs b/crates/hir-ty/src/tests/regression.rs
index c805f03044..4f1480c393 100644
--- a/crates/hir-ty/src/tests/regression.rs
+++ b/crates/hir-ty/src/tests/regression.rs
@@ -891,13 +891,14 @@ use core::ops::Deref;
struct BufWriter {}
-struct Mutex<T> {}
-struct MutexGuard<'a, T> {}
+struct Mutex<T>(T);
+struct MutexGuard<'a, T>(&'a T);
impl<T> Mutex<T> {
fn lock(&self) -> MutexGuard<'_, T> {}
}
impl<'a, T: 'a> Deref for MutexGuard<'a, T> {
type Target = T;
+ fn deref(&self) -> &Self::Target { loop {} }
}
fn flush(&self) {
let w: &Mutex<BufWriter>;
@@ -905,14 +906,18 @@ fn flush(&self) {
}
"#,
expect![[r#"
- 123..127 'self': &'? Mutex<T>
- 150..152 '{}': MutexGuard<'?, T>
- 234..238 'self': &'? {unknown}
- 240..290 '{ ...()); }': ()
- 250..251 'w': &'? Mutex<BufWriter>
- 276..287 '*(w.lock())': BufWriter
- 278..279 'w': &'? Mutex<BufWriter>
- 278..286 'w.lock()': MutexGuard<'?, BufWriter>
+ 129..133 'self': &'? Mutex<T>
+ 156..158 '{}': MutexGuard<'?, T>
+ 242..246 'self': &'? MutexGuard<'a, T>
+ 265..276 '{ loop {} }': &'? T
+ 267..274 'loop {}': !
+ 272..274 '{}': ()
+ 289..293 'self': &'? {unknown}
+ 295..345 '{ ...()); }': ()
+ 305..306 'w': &'? Mutex<BufWriter>
+ 331..342 '*(w.lock())': BufWriter
+ 333..334 'w': &'? Mutex<BufWriter>
+ 333..341 'w.lock()': MutexGuard<'?, BufWriter>
"#]],
);
}
@@ -2230,7 +2235,6 @@ async fn f<A, B, C>() -> Bar {}
"#,
expect![[r#"
64..66 '{}': ()
- 64..66 '{}': impl Future<Output = ()>
"#]],
);
}
@@ -2563,3 +2567,81 @@ fn main() {
"#,
);
}
+
+#[test]
+fn regression_21429() {
+ check_no_mismatches(
+ r#"
+trait DatabaseLike {
+ type ForeignKey: ForeignKeyLike<DB = Self>;
+}
+
+trait ForeignKeyLike {
+ type DB: DatabaseLike;
+
+ fn host_columns(&self, database: &Self::DB);
+}
+
+trait ColumnLike {
+ type DB: DatabaseLike;
+
+ fn foo() -> &&<<Self as ColumnLike>::DB as DatabaseLike>::ForeignKey {
+ loop {}
+ }
+
+ fn foreign_keys(&self, database: &Self::DB) {
+ let fk = Self::foo();
+ fk.host_columns(database);
+ }
+}
+ "#,
+ );
+}
+
+#[test]
+fn issue_21006_generic_predicates_for_param_supertrait_cycle() {
+ check_no_mismatches(
+ r#"
+trait VCipherSuite {}
+
+trait CipherSuite
+where
+ OprfHash<Self>: Hash,
+{
+}
+
+type Bar<CS: CipherSuite> = <CS::Baz as VCipherSuite>::Hash;
+
+type OprfHash<CS: CipherSuite> = <CS::Baz as VCipherSuite>::Hash;
+
+impl<CS: CipherSuite> Foo<CS> {
+ fn seal() {}
+}
+ "#,
+ );
+}
+
+#[test]
+fn issue_21006_self_assoc_trait() {
+ check_types(
+ r#"
+trait Baz {
+ fn baz(&self);
+}
+
+trait Foo {
+ type Assoc;
+}
+
+trait Bar: Foo
+where
+ Self::Assoc: Baz,
+{
+ fn bar(v: Self::Assoc) {
+ let _ = v.baz();
+ // ^ ()
+ }
+}
+ "#,
+ );
+}