proc_macro::bridge: simplify and remove ExecutionStrategy and DispatcherTrait#152531
proc_macro::bridge: simplify and remove ExecutionStrategy and DispatcherTrait#152531cyrgani wants to merge 5 commits intorust-lang:mainfrom
proc_macro::bridge: simplify and remove ExecutionStrategy and DispatcherTrait#152531Conversation
|
rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
|
rustbot has assigned @petrochenkov. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| fn run_bridge_and_client<S: Server>( | ||
| &self, | ||
| dispatcher: &mut impl DispatcherTrait, | ||
| dispatcher: &mut Dispatcher<S>, |
There was a problem hiding this comment.
| dispatcher: &mut Dispatcher<S>, | |
| dispatcher: &mut Dispatcher<impl Server>, |
(But this depends on the taste.)
| /// A message pipe used for communicating between server and client threads. | ||
| pub trait MessagePipe<T>: Sized { | ||
| struct MessagePipe<T> { | ||
| tx: std::sync::mpsc::SyncSender<T>, |
There was a problem hiding this comment.
| tx: std::sync::mpsc::SyncSender<T>, | |
| tx: mpsc::SyncSender<T>, |
Here and in 3 places below.
|
r=me after addressing comments. |
|
Reminder, once the PR becomes ready for a review, use |
| pub enum ExecutionStrategy { | ||
| CrossThread, | ||
| SameThread, | ||
| } |
There was a problem hiding this comment.
I don't think this is going to work if we want to support wasm proc macros. The ExecutionStrategy implementation for that has to be in rustc, not libproc_macro. The latter can't use arbitrary dependencies for providing a wasm runtime, nor should we want to link a wasm runtime in every proc macro.
| MaybeCrossThread { cross_thread } | ||
| } | ||
| } | ||
| pub struct MaybeCrossThread(pub bool); |
There was a problem hiding this comment.
I think it is a bit clearer to keep the field name.
| pub struct MaybeCrossThread(pub bool); | |
| pub struct MaybeCrossThread { | |
| pub cross_thread: bool, | |
| } |
Also includes another tiny cleanup (functions can only have one return type).