Skip to content

#[tokio::test] bug in v0.2.826 #10837

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
gipsyh opened this issue Nov 22, 2021 · 18 comments
Closed

#[tokio::test] bug in v0.2.826 #10837

gipsyh opened this issue Nov 22, 2021 · 18 comments
Labels
A-macro macro expansion Broken Window Bugs / technical debt to be addressed immediately S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@gipsyh
Copy link

gipsyh commented Nov 22, 2021

image

however, "cargo test" is ok.

after upgrade to v0.2.826 has this problem.

@cwfitzgerald
Copy link

I can also reproduce this issue with #[wasm_bindgen] saying that RA hit "unreachable code".

@msfjarvis
Copy link

Also reproducible with serde's derive macros, I was in the process of creating a minimal repro case before I reported the bug when I saw this issue. The repository is available at https://github.com/msfjarvis/rust-analyzer-serde-repro.

I'm using v0.2.286 of the VSCode plugin and rust-analyzer 7366833 2021-11-20 dev of the rust-analyzer server.

@Veykril
Copy link
Member

Veykril commented Nov 22, 2021

What rustc version are you using, in case of 1.58-nightly you might want try updating as the early versions of 1.58 have an incompatible proc-macro abi for r-a

@msfjarvis
Copy link

What rustc version are you using, in case of 1.58-nightly you might want try updating as the early versions of 1.58 have an incompatible proc-macro abi for r-a

Broken for me on both rustc 1.58.0-nightly (2885c4748 2021-11-20) and rustc 1.58.0-nightly (65f3f8b22 2021-11-21).

@T-parrish
Copy link

Having a similar issue (rustc 1.56.1, rust-analyzer v0.2.826):
Screen Shot 2021-11-22 at 10 21 39 AM

@wpbrown
Copy link

wpbrown commented Nov 24, 2021

This isn't specific to Tokio. We are seeing this broken pipe err with rustc 1.54 and v0.2.826 - 183ef048f 2021-11-22 stable as well. It's not happening in v0.2.817 - : 73668334f 2021-11-15 stable.

thread 'main' panicked at 'range end index 8 out of range for slice of length 0', crates/proc_macro_srv/src/abis/abi_1_47/proc_macro/bridge/rpc.rs:135:1
stack backtrace:
   0: rust_begin_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/panicking.rs:101:14
   2: core::slice::index::slice_end_index_len_fail
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/slice/index.rs:41:5
   3:  as core::ops::function::FnOnce<()>>::call_once
   4: > as proc_macro_srv::abis::abi_1_47::proc_macro::bridge::server::DispatcherTrait>::dispatch
   5:  as core::convert::From<&mut F>>::from::call
   6: proc_macro::bridge::closure::Closure::call
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/closure.rs:27:18
   7: proc_macro::bridge::client::Literal::integer::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:244:25
   8: proc_macro::bridge::client::::with::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:336:47
   9: proc_macro::bridge::client::BridgeState::with::{{closure}}::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:293:17
  10: proc_macro::bridge::scoped_cell::ScopedCell::replace
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/scoped_cell.rs:75:9
  11: proc_macro::bridge::client::BridgeState::with::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:291:13
  12: std::thread::local::LocalKey::try_with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/local.rs:400:16
  13: std::thread::local::LocalKey::with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/local.rs:376:9
  14: proc_macro::bridge::client::BridgeState::with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:290:9
  15: proc_macro::bridge::client::::with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:329:9
  16: proc_macro::bridge::client::Literal::integer
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:237:17
  17: proc_macro::Literal::i64_unsuffixed
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/lib.rs:1005:21
  18: proc_macro2::imp::Literal::i64_unsuffixed
             at /home/will/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.32/src/wrapper.rs:798:56
  19: proc_macro2::Literal::i64_unsuffixed
             at /home/will/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.32/src/lib.rs:1067:41
  20: syn::expr::printing::::to_tokens
             at /home/will/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.81/src/expr.rs:3308:27
  21: quote::to_tokens::ToTokens::to_token_stream
             at /home/will/.cargo/registry/src/github.com-1ecc6299db9ec823/quote-1.0.10/src/to_tokens.rs:63:9
  22: derive_more::utils::State::field_idents::{{closure}}
             at /home/will/.cargo/registry/src/github.com-1ecc6299db9ec823/derive_more-0.99.16/src/utils.rs:759:26
  23: core::iter::adapters::map::map_fold::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/iter/adapters/map.rs:82:28
  24: core::iter::traits::iterator::Iterator::fold
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/iter/traits/iterator.rs:2112:21
  25:  as core::iter::traits::iterator::Iterator>::fold
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/iter/adapters/map.rs:122:9
  26: core::iter::traits::iterator::Iterator::for_each
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/iter/traits/iterator.rs:736:9
  27:  as alloc::vec::spec_extend::SpecExtend>::spec_extend
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/vec/spec_extend.rs:40:17
  28:  as alloc::vec::spec_from_iter_nested::SpecFromIterNested>::from_iter
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/vec/spec_from_iter_nested.rs:56:9
  29:  as alloc::vec::spec_from_iter::SpecFromIter>::from_iter
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/vec/spec_from_iter.rs:33:9
  30:  as core::iter::traits::collect::FromIterator>::from_iter
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/vec/mod.rs:2449:9
  31: core::iter::traits::iterator::Iterator::collect
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/iter/traits/iterator.rs:1748:9
  32: derive_more::utils::State::field_idents
             at /home/will/.cargo/registry/src/github.com-1ecc6299db9ec823/derive_more-0.99.16/src/utils.rs:758:13
  33: derive_more::utils::State::enabled_fields_idents
             at /home/will/.cargo/registry/src/github.com-1ecc6299db9ec823/derive_more-0.99.16/src/utils.rs:765:9
  34: derive_more::utils::State::enabled_fields_data
             at /home/will/.cargo/registry/src/github.com-1ecc6299db9ec823/derive_more-0.99.16/src/utils.rs:647:28
  35: derive_more::from::enum_from
             at /home/will/.cargo/registry/src/github.com-1ecc6299db9ec823/derive_more-0.99.16/src/from.rs:112:32
  36: derive_more::from::expand
             at /home/will/.cargo/registry/src/github.com-1ecc6299db9ec823/derive_more-0.99.16/src/from.rs:27:12
  37: derive_more::from_derive
             at /home/will/.cargo/registry/src/github.com-1ecc6299db9ec823/derive_more-0.99.16/src/lib.rs:283:29
  38: core::ops::function::FnOnce::call_once
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/ops/function.rs:227:5
  39: proc_macro::bridge::client::Client proc_macro::TokenStream>::expand1::run::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:410:40
  40: proc_macro::bridge::client::run_client::{{closure}}::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:377:26
  41: proc_macro::bridge::scoped_cell::ScopedCell::set::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/scoped_cell.rs:80:33
  42: proc_macro::bridge::scoped_cell::ScopedCell::replace
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/scoped_cell.rs:75:9
  43: proc_macro::bridge::scoped_cell::ScopedCell::set
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/scoped_cell.rs:80:9
  44: proc_macro::bridge::client::::enter::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:325:35
  45: std::thread::local::LocalKey::try_with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/local.rs:400:16
  46: std::thread::local::LocalKey::with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/local.rs:376:9
  47: proc_macro::bridge::client::::enter
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:325:9
  48: proc_macro::bridge::client::run_client::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:370:9
  49:  as core::ops::function::FnOnce<()>>::call_once
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panic.rs:347:9
  50: std::panicking::try::do_call
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:401:40
  51: __rust_try
  52: std::panicking::try
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:365:19
  53: std::panic::catch_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panic.rs:434:14
  54: proc_macro::bridge::client::run_client
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:369:5
  55: proc_macro::bridge::client::Client proc_macro::TokenStream>::expand1::run
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:410:13
  56: proc_macro_srv::abis::abi_1_47::proc_macro::bridge::server::run_server
  57: proc_macro_srv::abis::abi_1_47::Abi::expand
  58: proc_macro_srv::dylib::Expander::expand
  59: proc_macro_srv::ProcMacroSrv::expand
  60: proc_macro_srv::cli::run
  61: rust_analyzer::try_main
  62: rust_analyzer::main

@Veykril Veykril added Broken Window Bugs / technical debt to be addressed immediately A-macro macro expansion labels Nov 24, 2021
@Veykril
Copy link
Member

Veykril commented Nov 25, 2021

This is rather odd, given this seems to occur for people on serveral different rustc versions. And for me at least it definitely works on the latest nightly 1.58 as well as stable 1.56.1 which stands in conflict with some of the comments here 😕

@Veykril Veykril added the S-unactionable Issue requires feedback, design decisions or is blocked on other work label Nov 25, 2021
@jonas-schievink
Copy link
Contributor

jonas-schievink commented Nov 29, 2021

I think this might be the issue? abdb2ac#r61059223 No, this was already fixed

@ivans-tbtl
Copy link

Can confirm similar issue with 1.54, as @wpbrown mentioned, 0.2.817 seems to be the last that doesn't crash.

@danielframpton
Copy link
Contributor

I just confirmed locally that the example here fails for me with a local rust-analyzer against rustc 1.54, but starts working if I change crates/proc_macro_srv/src/abis/mod.rs to use the 1.55 abi for rustc 1.54.

Maybe that abi is misnamed; 1.54 has always used the 1.55 abi since its introduction. I suspect that #10799 fixed on of the cases (1.57 vs 1.58) but broke 1.54 by making it use the older 1.47 abi.

@lnicola
Copy link
Member

lnicola commented Jan 5, 2022

Fixed in #11187.

@lnicola lnicola closed this as completed Jan 5, 2022
@lnicola
Copy link
Member

lnicola commented Jan 6, 2022

Actually, this might not be fixed. Please leave a comment with your compiler version if it still happens with a nightly or in the next release. You'll probably have to download that from GitHub, though.

@xcaptain
Copy link

xcaptain commented Jan 6, 2022

Yes, this bug still happens on nightly 1.58, but stable rust 1.57 is ok.

@lnicola
Copy link
Member

lnicola commented Jan 6, 2022

@xcaptain which nightly is that? As far as I can tell, it's working on rustc 1.58.0-beta.2 (0e07bcb68 2021-12-04) and rustc 1.59.0-nightly (f1ce0e6a0 2022-01-05). Can you clone the RA repo and run RUN_SLOW_TESTS=1 cargo test (on Unix) or set RUN_SLOW_TESTS=1, then cargo test on Windows?

@xcaptain
Copy link

xcaptain commented Jan 7, 2022

image

I'm using rustc 1.58.0-nightly (efd048394 2021-10-20), hope this can help @lnicola

@xcaptain
Copy link

xcaptain commented Jan 7, 2022

rustc 1.58.0-nightly (e99963c55 2021-10-29) fail
rustc 1.58.0-nightly (ad4423997 2021-11-14) ok

It may be a 1.58 nightly bug and was fixed in following 1.58 releases

@Veykril
Copy link
Member

Veykril commented Jan 7, 2022

Those nightlies are most likely using different proc-macro abis, so the early 1.58 ones not working is expected in that case. We can't do much here unfortunately as we don't want to add support for too many different abi versions.

@lnicola
Copy link
Member

lnicola commented Jan 7, 2022

Yeah, the 1.58 ABI is the one used in the stable 1.58 release. But early 1.58 nightlies were using the previous ABI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion Broken Window Bugs / technical debt to be addressed immediately S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

No branches or pull requests