Open y86-dev opened 2 months ago
Each doctest is put in it's own function, and since super
always refer to a module, it's expected that it won't find what's inside the doctest function, whenever that behaviour is something we want or not and can be fix is another thing.
fn doctest() {
type Y = ();
mod m {
use super::Y; // unresolved import `super::Y`
fn f() -> Y {}
}
}
cc #79260 the underlying rustc issue
Even if this is intended behavior, is there any chance we could include a note in the error explaining this?
BTW, you can add fn main() {}
to your doctest to make it work:
/// ```
/// type Y = ();
/// mod m {
/// use super::Y;
/// fn f() -> Y {}
/// }
/// # fn main() {}
/// ```
pub struct X;
I posted a question about this:
https://users.rust-lang.org/t/private-fields-in-macro-generated-structs/120052
I tried this code:
in
lib.rs
.I expected to see this happen: successful
cargo test
Instead, this happened:
The same error happens when using
super::Y
directly in the return type.Meta
rustc --version --verbose
: