Closed
Description
When using a trait that would have been imported via *
except it is not declared pub
, the suggestion from rustc is to import the type.
testcase.rs:
fn main() {
use testmodule::*;
let foo = Foo {};
foo.hello();
}
pub mod testmodule {
struct Foo {
}
trait Bar {
fn hello() -> &'static str;
}
impl Bar for Foo {
fn hello() -> &'static str {
return "Hiya, stranger!";
}
}
}
Compiling returns this error:
error[E0422]: cannot find struct, variant or union type `Foo` in this scope
--> testcase.rs:4:15
|
4 | let foo = Foo {};
| ^^^ not found in this scope
|
= help: possible candidate is found in another module, you can import it into scope:
`use testmodule::Foo;`
error: aborting due to previous error
But the type can't be imported because it's private (and if it weren't, it would have already been imported).
The same error exists when calling a trait that is defined in a private type.