Method calls with custom receiver types "forget" their type arguments #8100
Labels
A-ty
type system / type inference / traits / method resolution
S-actionable
Someone could pick this issue up and work on it right now
Methods with custom receiver types (that is, of the shape
fn foo(self: Box<Self>)
rather thanfn foo(&self)
) "forget"Self
's type arguments, when inferring the return type. However, this only happens when using the method call syntax (foo.bar()
), UFCS calls (Foo::bar(foo)
) work fine.This makes it quite a bit more annoying to interact with things that use
Pin
, such asFuture
s.Repro
Open https://gitlab.com/teozkr/repros/-/blob/rust-analyzer/receiver-confusion/src/main.rs in an editor with RA variable type inlays enabled, or view https://teozkr.gitlab.io/repros/rust-analyzer/receiver-confusion/main.rs.html.
You'd expect every pair of variables to be inferred to have the same type (
&i32
,&i32
, and&Foo<i32>
respectively), but currently the method call variants are instead inferred as&i32
,&{unknown}
, and&Foo<{unknown}>
.I'm using d0805c6
The text was updated successfully, but these errors were encountered: