Open
Description
fn main() {
A::run();
}
pub struct A;
pub trait Runnable<T> {
fn run();
}
mod hides_trait {
use crate::{Runnable, A};
struct DefinetlyNotPublic;
impl Runnable<DefinetlyNotPublic> for A {
fn run() {
println!("impl");
}
}
}
In the above, the rust complier is smart enough to figure out that the user wants to call <A as Runnable<DefinetlyNotPublic>>::run()
. It inferres that, and then notices that DefinetlyNotPublic is not public.
You then get this errors:
error: type `DefinetlyNotPublic` is private
--> src/main.rs:2:5
|
2 | A::run();
| ^^^^^^ private type
error: could not compile `playground` due to previous error
Why do I think this is not perfect: The type DefinetlyNotPublic is mentioned, even though there is nothing in the code referring to it. Mentioning the inferred Runnable<DefinetlyNotPublic>
would be enough. Something like
error: type `DefinetlyNotPublic` is private
--> src/main.rs:2:5
|
2 | A::run();
| ^^^^^^------ calls `Runnable<DefinetlyNotPublic>::run()` but type parameter `DefinetlyNotPublic` is private.
Is this important? Not really, I just felt like reporting it since it is a small improvement.
If it is a quick fix and someone is bored go for it.