Skip to content

ParseFloatError unwrap panic while checking proc-macro code #11358

@ShadowJonathan

Description

@ShadowJonathan

While having loaded mozilla/uniffi-rs@7dcbe12, rust-analyzer exited unnaturally while parsing/working with proc-macros;

image

image

This is repeated across a few places in the codebase.

I can reproduce this with the above commit on an unrelated machine.

rust-analyzer version: db2a7087b 2021-12-13 stable

rustc version: rustc 1.54.0 (a178d0322 2021-07-26)

Full Error
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseFloatError { kind: Invalid }', crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs:527:32
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
   2: core::result::unwrap_failed
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/result.rs:1616:5
   3: <proc_macro_srv::abis::abi_1_47::rustc_server::Rustc as proc_macro_srv::abis::abi_1_47::proc_macro::bridge::server::Literal>::float
   4: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
   5: <proc_macro_srv::abis::abi_1_47::proc_macro::bridge::server::Dispatcher<proc_macro_srv::abis::abi_1_47::proc_macro::bridge::server::MarkedTypes<S>> as proc_macro_srv::abis::abi_1_47::proc_macro::bridge::server::DispatcherTrait>::dispatch
   6: <proc_macro_srv::abis::abi_1_47::proc_macro::bridge::closure::Closure<A,R> as core::convert::From<&mut F>>::from::call
   7: proc_macro::bridge::closure::Closure<A,R>::call
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/closure.rs:27:18
   8: proc_macro::bridge::client::Literal::typed_integer::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:244:25
   9: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::with::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:336:47
  10: proc_macro::bridge::client::BridgeState::with::{{closure}}::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:293:17
  11: proc_macro::bridge::scoped_cell::ScopedCell<T>::replace
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/scoped_cell.rs:75:9
  12: proc_macro::bridge::client::BridgeState::with::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:291:13
  13: std::thread::local::LocalKey<T>::try_with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/local.rs:400:16
  14: std::thread::local::LocalKey<T>::with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/local.rs:376:9
  15: proc_macro::bridge::client::BridgeState::with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:290:9
  16: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:329:9
  17: proc_macro::bridge::client::Literal::typed_integer
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:237:17
  18: proc_macro::Literal::usize_suffixed
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/lib.rs:983:21
  19: proc_macro2::imp::Literal::usize_suffixed
             at /home/jonathan/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.36/src/wrapper.rs:786:56
  20: proc_macro2::Literal::usize_suffixed
             at /home/jonathan/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.36/src/lib.rs:1055:41
  21: <usize as quote::to_tokens::ToTokens>::to_tokens
             at /home/jonathan/.cargo/registry/src/github.com-1ecc6299db9ec823/quote-1.0.15/src/to_tokens.rs:134:44
  22: serde_derive::de::deserialize_seq::{{closure}}
             at /home/jonathan/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_derive-1.0.136/src/de.rs:679:40
  23: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/ops/function.rs:280:13
  24: core::option::Option<T>::map
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/option.rs:489:29
  25: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/iter/adapters/map.rs:101:9
  26: serde_derive::de::deserialize_seq
             at /home/jonathan/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_derive-1.0.136/src/de.rs:728:5
  27: serde_derive::de::deserialize_struct
             at /home/jonathan/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_derive-1.0.136/src/de.rs:929:27
  28: serde_derive::de::deserialize_body
             at /home/jonathan/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_derive-1.0.136/src/de.rs:290:17
  29: serde_derive::de::expand_derive_deserialize
             at /home/jonathan/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_derive-1.0.136/src/de.rs:33:22
  30: serde_derive::derive_deserialize
             at /home/jonathan/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_derive-1.0.136/src/lib.rs:99:5
  31: core::ops::function::FnOnce::call_once
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/ops/function.rs:227:5
  32: proc_macro::bridge::client::Client<fn(proc_macro::TokenStream) .> proc_macro::TokenStream>::expand1::run::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:410:40
  33: proc_macro::bridge::client::run_client::{{closure}}::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:377:26
  34: proc_macro::bridge::scoped_cell::ScopedCell<T>::set::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/scoped_cell.rs:80:33
  35: proc_macro::bridge::scoped_cell::ScopedCell<T>::replace
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/scoped_cell.rs:75:9
  36: proc_macro::bridge::scoped_cell::ScopedCell<T>::set
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/scoped_cell.rs:80:9
  37: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:325:35
  38: std::thread::local::LocalKey<T>::try_with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/local.rs:400:16
  39: std::thread::local::LocalKey<T>::with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/local.rs:376:9
  40: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:325:9
  41: proc_macro::bridge::client::run_client::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:370:9
  42: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panic.rs:347:9
  43: std::panicking::try::do_call
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:401:40
  44: __rust_try
  45: std::panicking::try
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:365:19
  46: std::panic::catch_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panic.rs:434:14
  47: proc_macro::bridge::client::run_client
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:369:5
  48: proc_macro::bridge::client::Client<fn(proc_macro::TokenStream) .> proc_macro::TokenStream>::expand1::run
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/proc_macro/src/bridge/client.rs:410:13
  49: proc_macro_srv::abis::abi_1_47::proc_macro::bridge::server::run_server
  50: proc_macro_srv::abis::abi_1_47::Abi::expand
  51: proc_macro_srv::dylib::Expander::expand
  52: proc_macro_srv::ProcMacroSrv::expand
  53: proc_macro_srv::cli::run
  54: rust_analyzer::try_main
  55: rust_analyzer::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macromacro expansion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions