Rust: Rustc keeps suggesting std::iter::ZipImpl trait who has a "new" method.

Created on 5 Nov 2017  路  6Comments  路  Source: rust-lang/rust

This is not a real big deal, however rustc keeps suggesting "ZipImpl", which is a implementation detail and rarely is what people want.

Any chance to rename it somehow?

A-diagnostics C-bug

Most helpful comment

struct T;

fn main() {
    T::new();
}
   Compiling playground v0.0.1 (file:///playground)
error[E0599]: no function or associated item named `new` found for type `main::T` in the current scope
 --> src/main.rs:3:5
  |
3 |     T::new();
  |     ^^^^^^
  |
  = help: items from traits can only be used if the trait is implemented and in scope
  = note: the following trait defines an item `new`, perhaps you need to implement it:
          candidate #1: `std::iter::ZipImpl`

All 6 comments

Could you provide more context? A sample of the code and the error message suggesting ZipImpl would be helpful.

struct T;

fn main() {
    T::new();
}
   Compiling playground v0.0.1 (file:///playground)
error[E0599]: no function or associated item named `new` found for type `main::T` in the current scope
 --> src/main.rs:3:5
  |
3 |     T::new();
  |     ^^^^^^
  |
  = help: items from traits can only be used if the trait is implemented and in scope
  = note: the following trait defines an item `new`, perhaps you need to implement it:
          candidate #1: `std::iter::ZipImpl`

Maybe the suggestions should filter out #[doc(hidden)] items?

oddly enough, ZipImpl isn't just #[doc(hidden)], but it is, in fact, _private_.

Currently, we just check that at least one of the type and the trait is local, so indeed, this will false-positive for private traits:

https://github.com/rust-lang/rust/blob/565907fefb2a69c279b59bffa84c6d30129cafe9/src/librustc_typeck/check/method/suggest.rs#L445-L452

CC #25358, #26454.

Was this page helpful?
0 / 5 - 0 ratings