summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-26 13:05:59 +0000
committerbors <bors@rust-lang.org>2024-03-26 13:05:59 +0000
commit536606bc5df7e6045c6dbedc2f852ba3d38581f1 (patch)
tree877cdfd87be5919dd9e9bc8fdb1602002fc09af6 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent519d892f9523fe40cc11ec07323ffc2792614742 (diff)
parentac770f7bd57614e728980073a2a89702e78da2d8 (diff)
downloadrust-536606bc5df7e6045c6dbedc2f852ba3d38581f1.tar.gz
rust-536606bc5df7e6045c6dbedc2f852ba3d38581f1.zip
Auto merge of #122939 - joboet:proc_macro_bridge_state, r=petrochenkov
Simplify proc macro bridge state

Currently, `proc_macro` uses a `ScopedCell` to store the client-side proc-macro bridge. Unfortunately, this requires the `Bridge`, which has non-negligible size, to be copied out and back again on every access. In some cases, the optimizer might be able to elide these copies, but in general, this is suboptimal.

This PR removes `ScopedCell` and employs a similar trick as in [`scoped_tls`](https://crates.io/crates/scoped-tls), meaning that the only thing stored in TLS is a pointer to the state, which now is a `RefCell`. Access to the pointer is then scoped so that it is always within the lifetime of the reference to the state. Unfortunately, `scoped_tls` requires the referenced type to be `'static`, which `Bridge` is not, therefore we cannot simply copy that macro but have to reimplement its TLS trick.

This removes the `#[forbid(unsafe_code)]` on the `client` module so that we do not have to export `Bridge`, which currently is private, to the whole crate. I can change that, if necessary.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions