Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir-ty/src/tests/regression/new_solver.rs52
-rw-r--r--crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs23
-rw-r--r--crates/ide/src/goto_definition.rs64
3 files changed, 139 insertions, 0 deletions
diff --git a/crates/hir-ty/src/tests/regression/new_solver.rs b/crates/hir-ty/src/tests/regression/new_solver.rs
index 5983ec7647..f8b73cd505 100644
--- a/crates/hir-ty/src/tests/regression/new_solver.rs
+++ b/crates/hir-ty/src/tests/regression/new_solver.rs
@@ -472,3 +472,55 @@ where
"#,
);
}
+
+#[test]
+fn regression_16282() {
+ check_infer(
+ r#"
+//- minicore: coerce_unsized, dispatch_from_dyn
+trait MapLookup<Q> {
+ type MapValue;
+}
+
+impl<K> MapLookup<K> for K {
+ type MapValue = K;
+}
+
+trait Map: MapLookup<<Self as Map>::Key> {
+ type Key;
+}
+
+impl<K> Map for K {
+ type Key = K;
+}
+
+
+fn main() {
+ let _ = &()
+ as &dyn Map<Key=u32,MapValue=u32>;
+}
+"#,
+ expect![[r#"
+ 210..272 '{ ...32>; }': ()
+ 220..221 '_': &'? (dyn Map<MapValue = u32, Key = u32> + '?)
+ 224..227 '&()': &'? ()
+ 224..269 '&() ...e=u32>': &'? (dyn Map<MapValue = u32, Key = u32> + 'static)
+ 225..227 '()': ()
+ "#]],
+ );
+}
+
+#[test]
+fn regression_18692() {
+ check_no_mismatches(
+ r#"
+//- minicore: coerce_unsized, dispatch_from_dyn, send
+trait Trait: Send {}
+
+fn f(_: *const (dyn Trait + Send)) {}
+fn g(it: *const (dyn Trait)) {
+ f(it);
+}
+"#,
+ );
+}
diff --git a/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs b/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs
index 25c1e633ba..4ed71f0d3f 100644
--- a/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs
+++ b/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs
@@ -488,4 +488,27 @@ fn foo((): (), (): ()) {
"#,
);
}
+
+ #[test]
+ fn regression_17233() {
+ check_diagnostics(
+ r#"
+pub trait A {
+ type X: B;
+}
+pub trait B: A {
+ fn confused_name(self, _: i32);
+}
+
+pub struct Foo;
+impl Foo {
+ pub fn confused_name(&self) {}
+}
+
+pub fn repro<T: A>() {
+ Foo.confused_name();
+}
+"#,
+ );
+ }
}
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index e335989ab2..0ee9795af5 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/ide/src/goto_definition.rs
@@ -4015,4 +4015,68 @@ fn bar() {
"##,
);
}
+
+ #[test]
+ fn regression_20038() {
+ check(
+ r#"
+//- minicore: clone, fn
+struct Map<Fut, F>(Fut, F);
+
+struct InspectFn<F>(F);
+
+trait FnOnce1<A> {
+ type Output;
+}
+
+trait Future1 {
+ type Output;
+}
+
+trait FusedFuture1: Future1 {
+ fn is_terminated(&self) -> bool;
+ //^^^^^^^^^^^^^
+}
+
+impl<T, A, R> FnOnce1<A> for T
+where
+ T: FnOnce(A) -> R,
+{
+ type Output = R;
+}
+
+impl<F, A> FnOnce1<A> for InspectFn<F>
+where
+ F: for<'a> FnOnce1<&'a A, Output = ()>,
+{
+ type Output = A;
+}
+
+impl<Fut, F, T> Future1 for Map<Fut, F>
+where
+ Fut: Future1,
+ F: FnOnce1<Fut::Output, Output = T>,
+{
+ type Output = T;
+}
+
+impl<Fut, F, T> FusedFuture1 for Map<Fut, F>
+where
+ Fut: Future1,
+ F: FnOnce1<Fut::Output, Output = T>,
+{
+ fn is_terminated(&self) -> bool {
+ false
+ }
+}
+
+fn overflows<Fut, F>(inner: &Map<Fut, InspectFn<F>>)
+where
+ Map<Fut, InspectFn<F>>: FusedFuture1
+{
+ let _x = inner.is_terminated$0();
+}
+"#,
+ )
+ }
}