aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-16 15:29:57 +0100
committerGitHub <[email protected]>2020-07-16 15:29:57 +0100
commit9210fcc076808e53e9bde84be26307fc0dc7d688 (patch)
tree8fb1d73b29402ea279e670dffecb84279029dc3f
parent30245eabb438cc0f1bcb4f05000de8b771da752c (diff)
parent09ded918c492821d5b7a69004738c38ff4a0624d (diff)
Merge #4676
4676: proc_macro: fix current nightly/future stable ABI incompatibility r=matklad a=robojumper With rust-lang/rust#72233, the proc_macro ABI has changed, leading to the `test_derive_serialize_proc_macro` test believing that `serde` wants to pass the struct name as a byte string literal instead of a string literal. Fixes #4866. Co-authored-by: robojumper <[email protected]>
-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
-rw-r--r--crates/ra_proc_macro_srv/src/rustc_server.rs13
4 files changed, 29 insertions, 9 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 {
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
465impl server::Literal for Rustc { 465impl 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 {