diff options
Diffstat (limited to 'crates/ra_proc_macro_srv')
-rw-r--r-- | crates/ra_proc_macro_srv/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/dylib.rs | 2 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/proc_macro/bridge/client.rs | 14 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/proc_macro/bridge/closure.rs | 3 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/proc_macro/bridge/mod.rs | 8 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/rustc_server.rs | 13 |
6 files changed, 31 insertions, 10 deletions
diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml index 582102945..12ce497f8 100644 --- a/crates/ra_proc_macro_srv/Cargo.toml +++ b/crates/ra_proc_macro_srv/Cargo.toml | |||
@@ -4,6 +4,7 @@ name = "ra_proc_macro_srv" | |||
4 | version = "0.1.0" | 4 | version = "0.1.0" |
5 | authors = ["rust-analyzer developers"] | 5 | authors = ["rust-analyzer developers"] |
6 | publish = false | 6 | publish = false |
7 | license = "MIT OR Apache-2.0" | ||
7 | 8 | ||
8 | [lib] | 9 | [lib] |
9 | doctest = false | 10 | doctest = false |
diff --git a/crates/ra_proc_macro_srv/src/dylib.rs b/crates/ra_proc_macro_srv/src/dylib.rs index aa84e951c..1addbbd54 100644 --- a/crates/ra_proc_macro_srv/src/dylib.rs +++ b/crates/ra_proc_macro_srv/src/dylib.rs | |||
@@ -45,7 +45,7 @@ fn find_registrar_symbol(file: &Path) -> io::Result<Option<String>> { | |||
45 | // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dlsym.3.html | 45 | // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dlsym.3.html |
46 | // Unlike other dyld API's, the symbol name passed to dlsym() must NOT be | 46 | // Unlike other dyld API's, the symbol name passed to dlsym() must NOT be |
47 | // prepended with an underscore. | 47 | // prepended with an underscore. |
48 | if s.name.starts_with("_") { | 48 | if s.name.starts_with('_') { |
49 | &s.name[1..] | 49 | &s.name[1..] |
50 | } else { | 50 | } else { |
51 | &s.name | 51 | &s.name |
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. | ||
209 | impl fmt::Debug for Literal { | 208 | impl 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)] |
341 | pub struct Client<F> { | 347 | pub 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 | ||
12 | struct Env; | 12 | struct 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 | |||
14 | impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> { | 17 | impl<'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)] |
227 | mod api_tags { | 231 | mod api_tags { |
diff --git a/crates/ra_proc_macro_srv/src/rustc_server.rs b/crates/ra_proc_macro_srv/src/rustc_server.rs index f481d70b2..cc32d5a6d 100644 --- a/crates/ra_proc_macro_srv/src/rustc_server.rs +++ b/crates/ra_proc_macro_srv/src/rustc_server.rs | |||
@@ -463,9 +463,16 @@ impl server::Ident for Rustc { | |||
463 | } | 463 | } |
464 | 464 | ||
465 | impl server::Literal for Rustc { | 465 | impl server::Literal for Rustc { |
466 | // FIXME(eddyb) `Literal` should not expose internal `Debug` impls. | 466 | fn debug_kind(&mut self, _literal: &Self::Literal) -> String { |
467 | fn debug(&mut self, literal: &Self::Literal) -> String { | 467 | // r-a: debug_kind and suffix are unsupported; corresponding client code has been changed to not call these. |
468 | format!("{:?}", literal) | 468 | // They must still be present to be ABI-compatible and work with upstream proc_macro. |
469 | "".to_owned() | ||
470 | } | ||
471 | fn symbol(&mut self, literal: &Self::Literal) -> String { | ||
472 | literal.text.to_string() | ||
473 | } | ||
474 | fn suffix(&mut self, _literal: &Self::Literal) -> Option<String> { | ||
475 | None | ||
469 | } | 476 | } |
470 | 477 | ||
471 | fn integer(&mut self, n: &str) -> Self::Literal { | 478 | fn integer(&mut self, n: &str) -> Self::Literal { |