You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a particular context, type inference fails and RA does not show the type of a variable assigned to a function's return value. This is caused by the presence of a use statement in a function.
Steps to reproduce
Inside an outer function definition...
Define one struct, S1
And give S1 a method get_pair(self) that returns a 2-tuple
Define a second struct, S2, that contains an instance of S1
And give S2 a method that both 1. has a use statement and 2. calls s1.get_pair()
Bug
The presence of the use statement causes type inference of the return type of s1.get_pair() to fail
Code snippet
As far as I know this snippet is minimal.
fnf(){structS1;implS1{fnget_one(self) -> i32{0}fnget_pair(self) -> (i32,i32){(0,0)}}structS2{s1:S1,}implS2{fnno_fail_1(self) -> i32{use std::path;let x = self.s1.get_one();// let x: i32
x
}fnno_fail_2(self) -> i32{let pair = self.s1.get_pair();// let pair: (i32, i32)
pair.0}fnfail(self) -> i32{use std::path;let pair = self.s1.get_pair();// let pair: {unknown}
pair.0}}}
Screenshots
The text was updated successfully, but these errors were encountered:
rust-analyzer version: 0.3.1334-standalone (74ae2dd 2022-12-25)
rustc version: rustc 1.67.0-nightly
relevant settings: None?
Description
In a particular context, type inference fails and RA does not show the type of a variable assigned to a function's return value. This is caused by the presence of a
use
statement in a function.Steps to reproduce
S1
S1
a methodget_pair(self)
that returns a 2-tupleS2
, that contains an instance ofS1
S2
a method that both 1. has ause
statement and 2. callss1.get_pair()
Bug
The presence of the
use
statement causes type inference of the return type ofs1.get_pair()
to failCode snippet
As far as I know this snippet is minimal.
Screenshots
The text was updated successfully, but these errors were encountered: