-
Notifications
You must be signed in to change notification settings - Fork 13.3k
use foo::{self, ...}
doesn't import macro foo!
#63842
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
According to #60941 (comment), this is working as intended. |
Hm. So considering a |
There is a precedent in stdlib with |
Closing as per #60941 (comment). Changes to this would likely require an RFC. |
I'm not sure, @petrochenkov will need to clarify. There is a sort of consistency. If path segments are processed in sequence, the resolver only needs to track which module has been resolved until the leaf. If it allowed It also has a consistency with I agree it is a bit surprising. My mental model used to be that |
@ehuss Thanks for the explanation! What is also confusing, if I want to import both the module and the macro, this doesn't work: use std::vec::{self, Vec};
use std::vec; // I want just the macro here It adds too much friction to using imports. I need to maintain two groups of imports: for macros and for other things. And I need to ensure they are not overlapping. |
|
Yeah, I had to add that I want to use rust-lang/rustfmt#3362. And there should be a blank line between those two imports, so they are not merged. |
When there is a macro and a module with the same name,
use foo::{self, Bar}
syntax imports the modulefoo
, but not the macrofoo!
. So you are forced to use this:It is especially annoying because rustfmt automatically merges it like this:
And the macro is no longer imported. Both procedural and declarative macros are affected. Here is the full example:
(Playground)
Errors:
The text was updated successfully, but these errors were encountered: