Skip to content
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

Order of extern crate/pub mod matters suddenly #34212

Closed
shahn opened this issue Jun 11, 2016 · 4 comments
Closed

Order of extern crate/pub mod matters suddenly #34212

shahn opened this issue Jun 11, 2016 · 4 comments

Comments

@shahn
Copy link
Contributor

shahn commented Jun 11, 2016

I have code that uses this (works on beta and stable):

pub mod module1;
#[macro_use]
extern crate lazy_static;

On nightly, this fails with an error about lazy_static not being found inside module1. When I switch around the order stuff starts working again. Seems like a regression?

@TimNN
Copy link
Contributor

TimNN commented Jun 11, 2016

This was probably caused by #34032 (which is also tagged as a [breaking-change]).

cc @jseyfried

@jseyfried
Copy link
Contributor

@TimNN Yeah, this was caused by #34032 -- thanks for the cc!

@shahn #34032 changed the behavior of #[macro_use] on extern crates to match the behavior of #[macro_use] on modules. For example, if the lazy_static macro were defined in a module foo,

pub mod module1; // it would not be available in this module on stable
#[macro_use] mod foo; // unless this were moved above `module1`

This change could be viewed as a regression or a bug-fix, depending on your point of view.

Regardless, I thought the change would be unlikely to cause breakage in practice. I reverted the change (fixing the breakage) in #34239.

cc @nrc

@shahn
Copy link
Contributor Author

shahn commented Jun 12, 2016

@jseyfried, I'm fine with this being a breaking change if it is deemed worth it! No problem at all. Maybe this should be discussed before #34239 gets applied?

@jseyfried
Copy link
Contributor

@shahn

Maybe this should be discussed before #34239 gets applied?

Agreed. I think I prefer the original behavior since it means the order of items doesn't matter as much, even though the change makes #[macro_use] more consistent. The change was more of a side effect of #34032 than a goal.

bors added a commit that referenced this issue Jun 16, 2016
Revert a change in the scope of macros imported from crates to fix a regression

Fixes #34212.
The regression was caused by #34032, which changed the scope of macros imported from extern crates to match the scope of macros imported from modules.
r? @nrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants