-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Unresolved import (E0432) when use'ing name that shadows a star-imported one #102855
Comments
It would be helpful to have complete code to reproduce the issue; my attempt at reproducing behaves the way I would expect it to - there is no error; the locally-defined type is what is imported. It's possible I'm misunderstanding your file/module tree - the fact that Note that if the problem in your code is being caused by an ambiguity, you should be getting E0659, not E0432. It is strange that the E0432 message you're getting is not telling you which part of the path |
Thanks for the pointer to E0659! If I understand correctly, this means that the ambiguity does exist and it's just the matter of rustc producing the wrong diagnostic. Also thanks for attempting to reproduce the issue. When I tried to prepare a minimal-ish example myself, I noticed that I missed another star-import of In any case, I extracted a minimal-ish repro of the problem and pushed it to https://github.com/Xion/rust-issue-102855 . Let me know if this helps! |
The repro was very helpful! I managed to reduce it to this: use self::animation::File;
mod animation {
mod plugins {
use std::fs::*;
#[derive(Default)]
pub struct File;
}
pub use self::plugins::*;
} I think this is the same thing as #56593. |
If the Thanks again for looking into this! |
I can confirm that in my actual code, removing So this is almost certainly the same issue as #56593. |
Let's say we have the following layout of files (simplified example with (hopefully) irrelevant details omitted):
common/animation/plugins.rs
common/animation/mod.rs
app.rs
This results in the following error:
At best, this is a confusing diagnostic message. The import isn't unresolved, though it might be ambiguous as to which
AnimationPlugin
we are referring to here. The message should highlight this fact, making it more clear what the possible solutions are (e.g. replacinguse bevy::prelude::*;
with more selective imports).However, I'm not entirely sure if this is even the correct behavior. At any point inside
common::animation::plugins
, it is perfectly unambiguous whichAnimationPlugin
we are referring to; the custom one shadows the one defined inbevy::prelude
. But for some reason, this doesn't carry over through a simple re-export incommon::animation
root module.I'm reluctant to flag this as a compiler bug because I don't claim to fully understand the expected language rules here, but hopefully someone from the Rust team can determine if this is intended. But even if it's correct for the compiler to reject this code, the resulting error message could definitely be more clear.
The text was updated successfully, but these errors were encountered: