Closed
Description
If there is a private method implemented for a struct and a method with the same name from a trait impl for the struct, but the trait is not in scope, then there is no help section in the error message suggesting to add a use
for the trait.
I tried this code:
mod inner {
pub trait Bar {
fn method(&self);
}
pub struct Foo;
impl Foo {
fn method(&self) {}
}
impl Bar for Foo {
fn method(&self) {}
}
}
fn main() {
let foo = inner::Foo;
foo.method();
}
It fails with the following error:
error: method `method` is private
The error message can be improved by adding a section like this:
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
candidate #1: `use inner::Bar;`
Meta
Tried on rustc
versions 1.19.0 and 1.21.0-nightly