Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find <[T]>::iter #11910

Closed
digama0 opened this issue Apr 5, 2022 · 2 comments
Closed

Can't find <[T]>::iter #11910

digama0 opened this issue Apr 5, 2022 · 2 comments
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@digama0
Copy link
Contributor

digama0 commented Apr 5, 2022

fn main() {
  let x: &[u32] = &[];
  let _ = x.iter();
  //        ^ hover: {unknown}
  let _ = <[u32]>::iter(x);
  //               ^ hover: {unknown}
}

Using into_iter() works. In fact, completion on x doesn't show any of slice's intrinsic methods, only trait methods. I am not sure if this is a regression, I only started noticing it because it leads to false type errors in

fn main() {
  struct Foo(u32);
  let x: &[Foo] = &[];
  fn f(_: &u32) {}
  let _ = x.iter().map(|Foo(x)| f(x));
  //                              ^ type-mismatch: expected &u32, found u32
}

rust-analyzer version: 0fe7417 2022-04-02 nightly

rustc version: rustc 1.62.0-nightly (60e50fc1c 2022-04-04)

@Veykril Veykril added A-ty type system / type inference / traits / method resolution C-bug Category: bug labels Apr 5, 2022
@digama0 digama0 changed the title Can't find <&[T]>::iter Can't find <[T]>::iter Apr 5, 2022
@flodiebold
Copy link
Member

I can't reproduce this with the current nightly and RA built from source.

@flodiebold
Copy link
Member

Probably fixed by #11881, which your RA version didn't include yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants