Skip to content

Allow #[rustc_builtin_macro = "name"] #80850

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

Merged
merged 3 commits into from
Jan 10, 2021

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Jan 9, 2021

This adds the option of specifying the name of a builtin macro in the #[rustc_builtin_macro] attribute: #[rustc_builtin_macro = "name"].

This makes it possible to have both std::panic! and core::panic! as a builtin macro, by using different builtin macro names for each. This is needed to implement the edition-specific behaviour of the panic macros of RFC 3007.

Also removes SyntaxExtension::is_derive_copy, as the macro name (e.g. sym::Copy) is now tracked and provides that information directly.

r? @petrochenkov

This makes it possible to have both std::panic and core::panic as a
builtin macro, by using different builtin macro names for each.

Also removes SyntaxExtension::is_derive_copy, as the macro name (e.g.
sym::Copy) is now tracked and provides that information directly.
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 9, 2021
@petrochenkov
Copy link
Contributor

r=me with the comment addressed.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 9, 2021
This used to be necessary for `is_builtin` in the past, but is no longer required.

Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
@m-ou-se m-ou-se force-pushed the rustc-builtin-macro-name branch from c53548b to b293bba Compare January 9, 2021 19:27
@m-ou-se
Copy link
Member Author

m-ou-se commented Jan 9, 2021

Thanks for the quick review!

@bors r=petrochenkov

@bors
Copy link
Collaborator

bors commented Jan 9, 2021

📌 Commit b293bba has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 9, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jan 10, 2021
…=petrochenkov

Allow #[rustc_builtin_macro = "name"]

This adds the option of specifying the name of a builtin macro in the `#[rustc_builtin_macro]` attribute: `#[rustc_builtin_macro = "name"]`.

This makes it possible to have both `std::panic!` and `core::panic!` as a builtin macro, by using different builtin macro names for each. This is needed to implement the edition-specific behaviour of the panic macros of RFC 3007.

Also removes `SyntaxExtension::is_derive_copy`, as the macro name (e.g. `sym::Copy`) is now tracked and provides that information directly.

r? `@petrochenkov`
This was referenced Jan 10, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 10, 2021
Rollup of 9 pull requests

Successful merges:

 - rust-lang#79502 (Implement From<char> for u64 and u128.)
 - rust-lang#79968 (Improve core::ptr::drop_in_place debuginfo)
 - rust-lang#80774 (Fix safety comment)
 - rust-lang#80801 (Use correct span for structured suggestion)
 - rust-lang#80803 (Remove useless `fill_in` function)
 - rust-lang#80820 (Support `download-ci-llvm` on NixOS)
 - rust-lang#80825 (Remove under-used ImplPolarity enum)
 - rust-lang#80850 (Allow #[rustc_builtin_macro = "name"])
 - rust-lang#80857 (Add comment to `Vec::truncate` explaining `>` vs `>=`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3e735c6 into rust-lang:master Jan 10, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 10, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jan 11, 2021
resolve: Simplify built-in macro table

We don't use full `SyntaxExtension`s from the table, only `SyntaxExtensionKind`s, and `Ident` in `register_builtin_macro` always had dummy span. This PR removes unnecessary data from the table and related function signatures.

Noticed when reviewing rust-lang#80850.
@m-ou-se m-ou-se deleted the rustc-builtin-macro-name branch January 12, 2021 18:13
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants