Given the following code (playground):
//! ```
//! use playground::S;
//! S.method()
//! ```
pub struct S;
pub use m::Tr as _;
mod m {
pub trait Tr { fn method(&self); }
impl Tr for crate::S { fn method(&self) {} }
}
The current output for compiling the doctest is:
error[E0599]: no method named `method` found for struct `S` in the current scope
--> src/lib.rs:3:3
|
5 | S.method()
| ^^^^^^ method not found in `S`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
3 | use crate::playground::_;
|
I'm not sure what the output should be. Originally I hit this issue with tracing, which re-exports one trait (soon multiple) as _ in its prelude module. They are of course reachable in another path, so that one could be prefered¹, but I realized that this issue could also crop up with a situation such as what I've constructed above, where the trait is actually unnamable. In that case, either the compiler has to suggest as * import, or it has to not emit the help item at all.
¹ probably needs an annotation like #[doc(canonical)] (rust-lang/rfcs#3011)
Given the following code (playground):
The current output for compiling the doctest is:
I'm not sure what the output should be. Originally I hit this issue with
tracing, which re-exports one trait (soon multiple)as _in its prelude module. They are of course reachable in another path, so that one could be prefered¹, but I realized that this issue could also crop up with a situation such as what I've constructed above, where the trait is actually unnamable. In that case, either the compiler has to suggest as*import, or it has to not emit the help item at all.¹ probably needs an annotation like
#[doc(canonical)](rust-lang/rfcs#3011)