Skip to content

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

Closed
Closed
@digama0

Description

@digama0
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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolutionC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions