aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_proc_macro_srv/src/proc_macro
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_proc_macro_srv/src/proc_macro')
-rw-r--r--crates/ra_proc_macro_srv/src/proc_macro/bridge/client.rs14
-rw-r--r--crates/ra_proc_macro_srv/src/proc_macro/bridge/closure.rs3
-rw-r--r--crates/ra_proc_macro_srv/src/proc_macro/bridge/mod.rs8
3 files changed, 19 insertions, 6 deletions
diff --git a/crates/ra_proc_macro_srv/src/proc_macro/bridge/client.rs b/crates/ra_proc_macro_srv/src/proc_macro/bridge/client.rs
index 4b5dc7fd0..cb4b3bdb0 100644
--- a/crates/ra_proc_macro_srv/src/proc_macro/bridge/client.rs
+++ b/crates/ra_proc_macro_srv/src/proc_macro/bridge/client.rs
@@ -18,7 +18,7 @@ macro_rules! define_handles {
18 } 18 }
19 19
20 impl HandleCounters { 20 impl HandleCounters {
21 // FIXME(eddyb) use a reference to the `static COUNTERS`, intead of 21 // FIXME(eddyb) use a reference to the `static COUNTERS`, instead of
22 // a wrapper `fn` pointer, once `const fn` can reference `static`s. 22 // a wrapper `fn` pointer, once `const fn` can reference `static`s.
23 extern "C" fn get() -> &'static Self { 23 extern "C" fn get() -> &'static Self {
24 static COUNTERS: HandleCounters = HandleCounters { 24 static COUNTERS: HandleCounters = HandleCounters {
@@ -205,10 +205,16 @@ impl Clone for Literal {
205 } 205 }
206} 206}
207 207
208// FIXME(eddyb) `Literal` should not expose internal `Debug` impls.
209impl fmt::Debug for Literal { 208impl fmt::Debug for Literal {
210 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 209 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
211 f.write_str(&self.debug()) 210 f.debug_struct("Literal")
211 // format the kind without quotes, as in `kind: Float`
212 // .field("kind", &format_args!("{}", &self.debug_kind()))
213 .field("symbol", &self.symbol())
214 // format `Some("...")` on one line even in {:#?} mode
215 // .field("suffix", &format_args!("{:?}", &self.suffix()))
216 .field("span", &self.span())
217 .finish()
212 } 218 }
213} 219}
214 220
@@ -339,7 +345,7 @@ impl Bridge<'_> {
339#[repr(C)] 345#[repr(C)]
340#[derive(Copy, Clone)] 346#[derive(Copy, Clone)]
341pub struct Client<F> { 347pub struct Client<F> {
342 // FIXME(eddyb) use a reference to the `static COUNTERS`, intead of 348 // FIXME(eddyb) use a reference to the `static COUNTERS`, instead of
343 // a wrapper `fn` pointer, once `const fn` can reference `static`s. 349 // a wrapper `fn` pointer, once `const fn` can reference `static`s.
344 pub(super) get_handle_counters: extern "C" fn() -> &'static HandleCounters, 350 pub(super) get_handle_counters: extern "C" fn() -> &'static HandleCounters,
345 pub(super) run: extern "C" fn(Bridge<'_>, F) -> Buffer<u8>, 351 pub(super) run: extern "C" fn(Bridge<'_>, F) -> Buffer<u8>,
diff --git a/crates/ra_proc_macro_srv/src/proc_macro/bridge/closure.rs b/crates/ra_proc_macro_srv/src/proc_macro/bridge/closure.rs
index b8addff4a..273a97715 100644
--- a/crates/ra_proc_macro_srv/src/proc_macro/bridge/closure.rs
+++ b/crates/ra_proc_macro_srv/src/proc_macro/bridge/closure.rs
@@ -11,6 +11,9 @@ pub struct Closure<'a, A, R> {
11 11
12struct Env; 12struct Env;
13 13
14// impl<'a, A, R> !Sync for Closure<'a, A, R> {}
15// impl<'a, A, R> !Send for Closure<'a, A, R> {}
16
14impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> { 17impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> {
15 fn from(f: &'a mut F) -> Self { 18 fn from(f: &'a mut F) -> Self {
16 unsafe extern "C" fn call<A, R, F: FnMut(A) -> R>(env: &mut Env, arg: A) -> R { 19 unsafe extern "C" fn call<A, R, F: FnMut(A) -> R>(env: &mut Env, arg: A) -> R {
diff --git a/crates/ra_proc_macro_srv/src/proc_macro/bridge/mod.rs b/crates/ra_proc_macro_srv/src/proc_macro/bridge/mod.rs
index 6ae3926b2..aeb05aad4 100644
--- a/crates/ra_proc_macro_srv/src/proc_macro/bridge/mod.rs
+++ b/crates/ra_proc_macro_srv/src/proc_macro/bridge/mod.rs
@@ -108,8 +108,9 @@ macro_rules! with_api {
108 Literal { 108 Literal {
109 fn drop($self: $S::Literal); 109 fn drop($self: $S::Literal);
110 fn clone($self: &$S::Literal) -> $S::Literal; 110 fn clone($self: &$S::Literal) -> $S::Literal;
111 // FIXME(eddyb) `Literal` should not expose internal `Debug` impls. 111 fn debug_kind($self: &$S::Literal) -> String;
112 fn debug($self: &$S::Literal) -> String; 112 fn symbol($self: &$S::Literal) -> String;
113 fn suffix($self: &$S::Literal) -> Option<String>;
113 fn integer(n: &str) -> $S::Literal; 114 fn integer(n: &str) -> $S::Literal;
114 fn typed_integer(n: &str, kind: &str) -> $S::Literal; 115 fn typed_integer(n: &str, kind: &str) -> $S::Literal;
115 fn float(n: &str) -> $S::Literal; 116 fn float(n: &str) -> $S::Literal;
@@ -222,6 +223,9 @@ pub struct Bridge<'a> {
222 dispatch: closure::Closure<'a, Buffer<u8>, Buffer<u8>>, 223 dispatch: closure::Closure<'a, Buffer<u8>, Buffer<u8>>,
223} 224}
224 225
226// impl<'a> !Sync for Bridge<'a> {}
227// impl<'a> !Send for Bridge<'a> {}
228
225#[forbid(unsafe_code)] 229#[forbid(unsafe_code)]
226#[allow(non_camel_case_types)] 230#[allow(non_camel_case_types)]
227mod api_tags { 231mod api_tags {