Skip to content

proc macro returned error: Cannot perform expansion for Deserialize: error Unknown #6686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tomjakubowski opened this issue Dec 1, 2020 · 6 comments
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now

Comments

@tomjakubowski
Copy link

tomjakubowski commented Dec 1, 2020

It seems there's been a recent regression in derive proc macros on the nightly channel. I'm on v0.3.367-nightly
and see red squigglies on these entire structs (along with any comments), and a corresponding proc macro error.

Screen Shot 2020-11-30 at 6 04 37 PM

Sometimes the error message instead says "Empty result", or "Server closed".

Screen Shot 2020-11-30 at 6 11 46 PM

Unsure when this might have been introduced, but I have been on the nightly channel for some time, and wasn't seeing this last week Wednesday in a project that uses proc macros, but do see it today.

I have "rust-analyzer.procMacro.enable and rust-analyzer.cargo.loadOutDirsFromCheck both set to true.

I've attached the testcase I used for the screenshots: testcase.tar.gz

@tomjakubowski
Copy link
Author

tomjakubowski commented Dec 1, 2020

Downgrading the extension on my Mac to the latest stable version (v0.2.400) resolves the issue. Weirdly, on one Linux box, I needed to downgrade to v0.2.392; I still see rust-analyzer crashing on v0.2.400.

Attached are server trace logs, and here's the panic message, from the "output" tab:

thread 'main' panicked at 'internal error: entered unreachable code', crates/proc_macro_srv/src/proc_macro/bridge/mod.rs:256:5
stack backtrace:
   0: std::panicking::begin_panic
   1: <proc_macro_srv::proc_macro::bridge::api_tags::Method as proc_macro_srv::proc_macro::bridge::rpc::DecodeMut<S>>::decode
   2: <proc_macro_srv::proc_macro::bridge::server::Dispatcher<proc_macro_srv::proc_macro::bridge::server::MarkedTypes<S>> as proc_macro_srv::proc_macro::bridge::server::DispatcherTrait>::dispatch
   3: <proc_macro_srv::proc_macro::bridge::closure::Closure<A,R> as core::convert::From<&mut F>>::from::call
   4: proc_macro::bridge::closure::Closure<A,R>::call
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libproc_macro/bridge/closure.rs:27
   5: proc_macro::bridge::client::TokenStream::into_iter::{{closure}}
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libproc_macro/bridge/client.rs:237
   6: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::with::{{closure}}
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libproc_macro/bridge/client.rs:321
   7: proc_macro::bridge::client::BridgeState::with::{{closure}}::{{closure}}
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libproc_macro/bridge/client.rs:286
   8: proc_macro::bridge::scoped_cell::ScopedCell<T>::replace
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libproc_macro/bridge/scoped_cell.rs:74
   9: proc_macro::bridge::client::BridgeState::with::{{closure}}
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libproc_macro/bridge/client.rs:284
  10: std::thread::local::LocalKey<T>::try_with
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libstd/thread/local.rs:263
  11: std::thread::local::LocalKey<T>::with
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libstd/thread/local.rs:239
  12: proc_macro::bridge::client::BridgeState::with
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libproc_macro/bridge/client.rs:283
  13: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::with
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libproc_macro/bridge/client.rs:314
  14: proc_macro::bridge::client::TokenStream::into_iter
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libproc_macro/bridge/client.rs:230
  15: proc_macro::token_stream::<impl core::iter::traits::collect::IntoIterator for proc_macro::TokenStream>::into_iter
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libproc_macro/lib.rs:226
  16: <proc_macro2::imp::TokenStream as core::iter::traits::collect::IntoIterator>::into_iter
             at /home/dev/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/proc-macro2-1.0.24/src/wrapper.rs:292
  17: proc_macro2::token_stream::<impl core::iter::traits::collect::IntoIterator for proc_macro2::TokenStream>::into_iter
             at /home/dev/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/proc-macro2-1.0.24/src/lib.rs:1229
  18: syn::buffer::TokenBuffer::inner_new
             at /home/dev/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/syn-1.0.53/src/buffer.rs:53
  19: syn::buffer::TokenBuffer::new2
             at /home/dev/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/syn-1.0.53/src/buffer.rs:112
  20: <F as syn::parse::Parser>::parse2
             at /home/dev/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/syn-1.0.53/src/parse.rs:1210
  21: syn::parse::Parser::parse
             at /home/dev/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/syn-1.0.53/src/parse.rs:1164
  22: syn::parse_macro_input::parse
             at /home/dev/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/syn-1.0.53/src/parse_macro_input.rs:139
  23: serde_derive::derive_deserialize
             at /home/dev/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde_derive-1.0.117/src/lib.rs:89
  24: core::ops::function::FnOnce::call_once
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:232
  25: proc_macro::bridge::client::Client<fn(proc_macro::TokenStream) .> proc_macro::TokenStream>::expand1::run::{{closure}}
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libproc_macro/bridge/client.rs:394
  26: proc_macro::bridge::client::run_client::{{closure}}::{{closure}}
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libproc_macro/bridge/client.rs:362
  27: proc_macro::bridge::scoped_cell::ScopedCell<T>::set::{{closure}}
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libproc_macro/bridge/scoped_cell.rs:79
  28: proc_macro::bridge::scoped_cell::ScopedCell<T>::replace
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libproc_macro/bridge/scoped_cell.rs:74
  29: proc_macro::bridge::scoped_cell::ScopedCell<T>::set
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libproc_macro/bridge/scoped_cell.rs:79
  30: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libproc_macro/bridge/client.rs:310
  31: std::thread::local::LocalKey<T>::try_with
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/thread/local.rs:263
  32: std::thread::local::LocalKey<T>::with
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/thread/local.rs:239
  33: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libproc_macro/bridge/client.rs:310
  34: proc_macro::bridge::client::run_client::{{closure}}
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libproc_macro/bridge/client.rs:355
  35: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:318
  36: std::panicking::try::do_call
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:331
  37: __rust_try
  38: std::panicking::try
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:274
  39: std::panic::catch_unwind
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:394
  40: proc_macro::bridge::client::run_client
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libproc_macro/bridge/client.rs:354
  41: proc_macro::bridge::client::Client<fn(proc_macro::TokenStream) .> proc_macro::TokenStream>::expand1::run
             at /home/dev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libproc_macro/bridge/client.rs:394
  42: proc_macro_srv::proc_macro::bridge::server::run_server
  43: proc_macro_srv::dylib::Expander::expand
  44: proc_macro_srv::cli::run
  45: rust_analyzer::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

trace.txt

@bjorn3
Copy link
Member

bjorn3 commented Dec 1, 2020

This kind of error is usually caused by an incompatibility between the libproc_macro version of rustc and rust-analyzer. If this is the case, the fix will have to wait until the current rustc nightly hits stable.

@flodiebold
Copy link
Member

This is not a regression, the macro-error diagnostic is just new. This was probably already happening in the older versions as well, just not reported.

@kjeremy
Copy link
Contributor

kjeremy commented Dec 1, 2020

I'm not seeing a diagnostic for this error but hover shows that it fails.

proc macro Deserialize not expanded

@lnicola lnicola added A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now labels Dec 20, 2020
@edwin0cheng
Copy link
Member

Triage: can't reproduce.

@tomjakubowski do you see any errors now ?

@lnicola
Copy link
Member

lnicola commented Jan 7, 2021

Seems fixed, probably by #7047.

@lnicola lnicola closed this as completed Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

6 participants