Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Consider compiling to pass-through implementation on new compilers #62

Closed
dtolnay opened this issue Jul 26, 2020 · 2 comments · Fixed by #66
Closed

Consider compiling to pass-through implementation on new compilers #62

dtolnay opened this issue Jul 26, 2020 · 2 comments · Fixed by #66

Comments

@dtolnay
Copy link
Owner

dtolnay commented Jul 26, 2020

On Rust versions 1.45 and newer (https://blog.rust-lang.org/2020/07/16/Rust-1.45.0.html#stabilizing-function-like-procedural-macros-in-expressions-patterns-and-statements) we can bypass all of proc-macro-hack and expand as follows:

#[proc_macro_hack]
pub use mymacro_impl::mymacro;

// expands to:
pub use mymacro_impl::mymacro;
#[proc_macro_hack]
pub fn mymacro(input: TokenStream) -> TokenStream {...}

// expands to:
#[proc_macro]
pub fn mymacro(input: TokenStream) -> TokenStream {...}

This will improve macro expansion performance for libraries that need to support a range of compiler versions including ones older than 1.45.

@Artoria2e5
Copy link

Artoria2e5 commented Oct 13, 2020

@Icenowy reports another use case: this crate somehow breaks LTO interop with Clang (missing symbol), but the new rust macro doesn't.

@taiki-e
Copy link
Contributor

taiki-e commented Oct 25, 2020

Filed #64

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants