Uh oh!
There was an error while loading. Please reload this page.
proc_macro::is_available() - #71400
Conversation
dtolnay
commented
Apr 22, 2020
Reassigning per #71268 (comment) because @eddyb is occupied. |
petrochenkov
commented
Apr 22, 2020
LGTM, but it needs a tracking issue. FCP and official team approval can be done during stabilization. |
dtolnay
commented
Apr 22, 2020
@bors r=petrochenkov |
bors
commented
Apr 22, 2020
📌 Commit 3bd742f has been approved by |
Rollup of 5 pull requests Successful merges: - rust-lang#71256 (Lint must_use on mem::replace) - rust-lang#71350 (Error code explanation extra check) - rust-lang#71369 (allow wasm32 compilation of librustc_data_structures/profiling.rs) - rust-lang#71400 (proc_macro::is_available()) - rust-lang#71440 (Implement `Copy` for `AllocErr`) Failed merges: r? @ghost
eddyb
commented
Apr 27, 2020
Seems fine, the panic=abort situation leaves us no other options. cc @mystor, who, IIRC, wanted a "default server" which would eliminate the need for |
mystor
commented
Apr 30, 2020
Something like a fallback server could make |
This PR adds
proc_macro::is_available() -> boolto determine whether proc_macro has been made accessible to the currently running program.The proc_macro crate is only intended for use inside the implementation of procedural macros. All the functions in the crate panic if invoked from outside of a procedural macro, such as from a build script or unit test or ordinary Rust binary.
Unfortunately those panics made it impossible for libraries that are designed to support both macro and non-macro use cases (e.g. Syn) to be used from binaries that are compiled with panic=abort. In panic=unwind mode we're able to attempt a proc macro call inside catch_unwind and use libproc_macro's result if it succeeds, otherwise fall back to a non-macro alternative implementation. But in panic=abort there was no way to determine which implementation needs to be used.
r? @eddyb
attn: @petrochenkov@adetaylor
ref: dtolnay/cxx#130