-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using super
in doctests errors
#130274
Comments
Each doctest is put in it's own function, and since 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 /// ```
/// 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 have been having the same issue, and @ehuss's solution did not work for me, but simply wrapping my doctest in its own module did: /// ```
/// mod wrapping_mod {
/// type Y = ();
/// mod m {
/// use super::Y;
/// fn f() -> Y {}
/// }
/// }
/// ```
pub struct X; |
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
:The text was updated successfully, but these errors were encountered: