-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Remove E0773 "A builtin-macro was defined more than once." #138613
Conversation
Some changes occurred in diagnostic error codes |
I reviewed the changes and they look reasonable to me. I just can't quite judge how important this check was. The check feels to me like just a sanity check, and there's now a good usecase for actually doing the thing the error tries to prevent. |
Originally, the macro was just removed from To avoid that confusion, #76143 added logic to keep track of the already used builtin macros to give a better error. I think the better/simpler strategy is to just use Arc instead of Box such that you don't have to remove or track anything, lifting the 'only one definition' limitation. |
right, so by making things an Arc, we solve the issue for which the error was initially added. Then I don't think there's much reason not to do this :) |
alright then, first @bors r+ rollup here we go! |
This comment has been minimized.
This comment has been minimized.
43ea8cf
to
c9eda62
Compare
i don't quite follow why it's useful to define a macro more than once, but as long as it works i have no objection. people shouldn't be using rustc_builtin_macro outside of std anyway. |
wait, you also removed the test? please don't do that, please test that duplicate macros work. |
this is useful when you want multiple macros with different names implemented by the same definition in |
It's also useful when making a quick test/example while working on rustc, to not get conflicts with core when testing something with rustc_builtin_macro. |
I don't see why it's useful to limit it to one use either. (Which caused some hard to debug issues in the past.) |
Is there a problem with having the other macros forward to that builtin one? |
That's not as easy for attribute and derive macros. |
Ooh, yeah. Doable but still, gotcha. |
@jyn514 's comment of adding a test sounds like a good one. After that I'm willing to r+ again :) |
could you also squash :) @bors r- |
The |
This comment has been minimized.
This comment has been minimized.
Remove E0773 "A builtin-macro was defined more than once." Error E0773 "A builtin-macro was defined more than once" is triggered when using the same `#[rustc_builtin_macro(..)]` twice. However, it can only be triggered in unstable code (using a `rustc_` attribute), and there doesn't seem to be any harm in using the same implementation from `compiler/rustc_builtin_macros/…` for multiple macro definitions. By changing the Box to an Arc in `SyntaxExtensionKind`, we can throw away the `BuiltinMacroState::{NotYetSeen, AlreadySeen}` logic, simplifying things.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (cfeb465): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary 2.5%, secondary -1.8%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 776.359s -> 775.772s (-0.08%) |
The change itself makes sense. |
This removes E0773 "A builtin-macro was defined more than once."
@bors r=jdonszelmann,petrochenkov then :) |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#135394 (`MaybeUninit` inherent slice methods part 2) - rust-lang#137051 (Implement default methods for `io::Empty` and `io::Sink`) - rust-lang#138001 (mir_build: consider privacy when checking for irrefutable patterns) - rust-lang#138540 (core/slice: Mark some `split_off` variants unstably const) - rust-lang#138589 (If a label is placed on the block of a loop instead of the header, suggest moving it to the header.) - rust-lang#138594 (Fix next solver handling of shallow trait impl check) - rust-lang#138613 (Remove E0773 "A builtin-macro was defined more than once.") Failed merges: - rust-lang#138602 (Slim `rustc_parse_format` dependencies down) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#135394 (`MaybeUninit` inherent slice methods part 2) - rust-lang#137051 (Implement default methods for `io::Empty` and `io::Sink`) - rust-lang#138001 (mir_build: consider privacy when checking for irrefutable patterns) - rust-lang#138540 (core/slice: Mark some `split_off` variants unstably const) - rust-lang#138589 (If a label is placed on the block of a loop instead of the header, suggest moving it to the header.) - rust-lang#138594 (Fix next solver handling of shallow trait impl check) - rust-lang#138613 (Remove E0773 "A builtin-macro was defined more than once.") Failed merges: - rust-lang#138602 (Slim `rustc_parse_format` dependencies down) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#138613 - m-ou-se:no-more-e0773, r=jdonszelmann,petrochenkov Remove E0773 "A builtin-macro was defined more than once." Error E0773 "A builtin-macro was defined more than once" is triggered when using the same `#[rustc_builtin_macro(..)]` twice. However, it can only be triggered in unstable code (using a `rustc_` attribute), and there doesn't seem to be any harm in using the same implementation from `compiler/rustc_builtin_macros/…` for multiple macro definitions. By changing the Box to an Arc in `SyntaxExtensionKind`, we can throw away the `BuiltinMacroState::{NotYetSeen, AlreadySeen}` logic, simplifying things.
Error E0773 "A builtin-macro was defined more than once" is triggered when using the same
#[rustc_builtin_macro(..)]
twice. However, it can only be triggered in unstable code (using arustc_
attribute), and there doesn't seem to be any harm in using the same implementation fromcompiler/rustc_builtin_macros/…
for multiple macro definitions.By changing the Box to an Arc in
SyntaxExtensionKind
, we can throw away theBuiltinMacroState::{NotYetSeen, AlreadySeen}
logic, simplifying things.