-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
A-tytype system / type inference / traits / method resolutiontype system / type inference / traits / method resolutionC-bugCategory: bugCategory: bugS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right now
Description
The following produces a R-A error, but compiles just fine:
use smallvec::SmallVec;
const SIZE: usize = 1;
fn bug(ve: &SmallVec<[Option<()>; SIZE]>) -> Option<Option<&()>> {
ve.iter().next().map(|x| x.as_ref())
}
fn main() {}
I haven't been able to come up with a minimal example that does not use SmallVec. ve.iter()
is inferred as Iter<{unknown}>
by RA in that function. Note that this does not error if the array size is written in place: [Option<()>; 1].
This does not happen if I simply replace SmallVec with some type that implements Deref<Target=[Option<()>]>
or &[Option<()>; SIZE]
itself.
rust-analyzer version: rust-analyzer version: 24cf957 2022-04-11 stable
rustc version: rustc 1.62.0-nightly (878c783 2022-04-16)
Metadata
Metadata
Assignees
Labels
A-tytype system / type inference / traits / method resolutiontype system / type inference / traits / method resolutionC-bugCategory: bugCategory: bugS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right now