-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add deprecation lint for duplicated macro_export
s
#50143
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
cc @rust-lang/lang Needs check-only crater run before proceeding. |
@bors try |
Prohibit duplicated `macro_export`s cc #35896 (comment)
☀️ Test successful - status-travis |
Crater run commenced, check-only, ETA ~3 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me from the technical perspective. I'm not 100% sure about the policy decision, but I guess let's see what the crater run has to say.
@@ -887,14 +887,24 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { | |||
// Since import resolution is finished, globs will not define any more names. | |||
*module.globs.borrow_mut() = Vec::new(); | |||
|
|||
let report_already_exported = |this: &mut Self, ident, span, prev_span| { | |||
let msg = format!("a macro named `{}` has already been exported", ident); | |||
this.session.struct_span_err(span, &msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with a hard error, but it seems like there is a defined semantics, right? (Shadowing) We could always issue warnings, in other words.
Crater results: http://cargobomb-reports.s3.amazonaws.com/pr-50143/index.html |
Legitimate regressions
The Sounds like this may want to start out as a warning? |
What would be the motivation for a break here? The whole |
The exact problem is that there's no defined semantics. @durka Since there's breakage, I'd prefer to turn this into a preferably deny-by-default lint so dependent crates are not affected and send PRs to crates with root regressions. |
I realize that it got accidentally "defined" to work the way it does, but since it does work and it's not unsound or anything, it seems unfortunate to do the breaking change. |
@petrochenkov I would have expected the order to be DFS, since that is significant to other parts of macro expansion. I'm surprised that is complex to achieve, but I'm probably not thinking especially clearly about it. Do you have an example where a problem might arise, or just a bad feeling? I see you wrote this:
Can you point at the relevant code? (This walk is occurring at the end of expansion.) |
(At minimum, some kind of active deprecation definitely makes sense -- and perhaps a hard error in Edition 2018.) |
Here, for example, macro_rules! generate_foo {
() => {
#[macro_export]
macro_rules! foo { (1) => {} }
}
}
generate_foo!();
#[macro_export]
macro_rules! foo { (2) => {} }
foo!(2); // Local use, OK |
I've replaced the error with a deprecation lint. |
☔ The latest upstream changes (presumably #50763) made this pull request unmergeable. Please resolve the merge conflicts. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Rebased. |
The final comment period, with a disposition to merge, as per the review above, is now complete. |
@bors r+ |
📌 Commit 11c283c has been approved by |
🌲 The tree is currently closed for pull requests below priority 1, this pull request will be tested once the tree is reopened |
Add deprecation lint for duplicated `macro_export`s cc rust-lang#35896 (comment)
🔒 Merge conflict |
Rollup of 13 pull requests Successful merges: - #50143 (Add deprecation lint for duplicated `macro_export`s) - #51099 (Fix Issue 38777) - #51276 (Dedup auto traits in trait objects.) - #51298 (Stabilize unit tests with non-`()` return type) - #51360 (Suggest parentheses when a struct literal needs them) - #51391 (Use spans pointing at the inside of a rustdoc attribute) - #51394 (Use scope tree depths to speed up `nearest_common_ancestor`.) - #51396 (Make the size of Option<NonZero*> a documented guarantee.) - #51401 (Warn on `repr` without hints) - #51412 (Avoid useless Vec clones in pending_obligations().) - #51427 (compiletest: autoremove duplicate .nll.* files (#51204)) - #51436 (Do not require stage 2 compiler for rustdoc) - #51437 (rustbuild: generate full list of dependencies for metadata) Failed merges:
cc #35896 (comment)