Skip to content

Parser panic on refactoring use declarations #1866

@zoewithabang

Description

@zoewithabang

E.g. running in VSCode, I'm attempting to refactor from

use std::error::Error;
use std::io;

to

use std::{
    error::Error,
    std::io,
};

On adding a curly brace here

use std::{error::Error;
use std::io;

the editor briefly hangs and the following panic is logged several times:

thread '<unnamed>' panicked at 'the parser seems stuck', crates\ra_parser\src\parser.rs:49:9
stack backtrace:
   0: backtrace::backtrace::trace_unsynchronized
             at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.35\src\backtrace\mod.rs:66
   1: std::sys_common::backtrace::_print
             at /rustc/c6e9c76c59e3c10acd63ca9ec157a8894ea1a068\/src\libstd\sys_common\backtrace.rs:47
   2: std::sys_common::backtrace::print
             at /rustc/c6e9c76c59e3c10acd63ca9ec157a8894ea1a068\/src\libstd\sys_common\backtrace.rs:36
   3: std::panicking::default_hook::{{closure}}
             at /rustc/c6e9c76c59e3c10acd63ca9ec157a8894ea1a068\/src\libstd\panicking.rs:200
   4: std::panicking::default_hook
             at /rustc/c6e9c76c59e3c10acd63ca9ec157a8894ea1a068\/src\libstd\panicking.rs:214
   5: std::panicking::rust_panic_with_hook
             at /rustc/c6e9c76c59e3c10acd63ca9ec157a8894ea1a068\/src\libstd\panicking.rs:477
   6: std::panicking::begin_panic<str*>
             at /rustc/c6e9c76c59e3c10acd63ca9ec157a8894ea1a068\src\libstd\panicking.rs:411
   7: ra_parser::parser::Parser::err_recover
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_parser\src\parser.rs:0
   8: ra_parser::grammar::items::use_item::use_tree
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_parser\src\grammar\items\use_item.rs:104
   9: ra_parser::grammar::items::use_item::use_tree_list
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_parser\src\grammar\items\use_item.rs:119
  10: ra_parser::grammar::items::use_item::use_tree
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_parser\src\grammar\items\use_item.rs:92
  11: ra_parser::grammar::items::use_item::use_item
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_parser\src\grammar\items\use_item.rs:6
  12: ra_parser::grammar::items::items_without_modifiers
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_parser\src\grammar\items.rs:260
  13: ra_parser::grammar::items::maybe_item
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_parser\src\grammar\items.rs:82
  14: ra_parser::grammar::items::item_or_macro
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_parser\src\grammar\items.rs:40
  15: ra_parser::grammar::items::mod_contents
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_parser\src\grammar\items.rs:23
  16: ra_parser::grammar::root
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_parser\src\grammar.rs:48
  17: core::ops::function::FnOnce::call_once
             at /rustc/c6e9c76c59e3c10acd63ca9ec157a8894ea1a068\src\libcore\ops\function.rs:227
  18: ra_parser::parse_from_tokens
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_parser\src\lib.rs:76
  19: ra_parser::parse
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_parser\src\lib.rs:83
  20: ra_syntax::parsing::parse_text
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_syntax\src\parsing.rs:19
  21: ra_syntax::ast::generated::SourceFile::parse
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_syntax\src\lib.rs:149
  22: ra_db::parse_query
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_db\src\lib.rs:103
  23: ra_db::{{impl}}::execute<ra_ide_api::db::RootDatabase>
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_db\src\lib.rs:76
  24: salsa::runtime::Runtime<ra_ide_api::db::RootDatabase>::execute_query_implementation<ra_ide_api::db::RootDatabase,ra_syntax::Parse<ra_syntax::ast::generated::SourceFile>,closure-1>
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\salsa-0.13.0\src\runtime.rs:351
  25: salsa::derived::slot::Slot<ra_ide_api::db::RootDatabase, ra_db::ParseQuery, salsa::derived::AlwaysMemoizeValue>::read_upgrade<ra_ide_api::db::RootDatabase,ra_db::ParseQuery,salsa::derived::AlwaysMemoizeValue>
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\salsa-0.13.0\src\derived\slot.rs:200
  26: salsa::derived::slot::Slot<ra_ide_api::db::RootDatabase, ra_db::ParseQuery, salsa::derived::AlwaysMemoizeValue>::read<ra_ide_api::db::RootDatabase,ra_db::ParseQuery,salsa::derived::AlwaysMemoizeValue>
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\salsa-0.13.0\src\derived\slot.rs:140
  27: salsa::derived::{{impl}}::try_fetch<ra_ide_api::db::RootDatabase,ra_db::ParseQuery,salsa::derived::AlwaysMemoizeValue>
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\salsa-0.13.0\src\derived.rs:140
  28: salsa::QueryTable<ra_ide_api::db::RootDatabase, ra_db::ParseQuery>::get
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\salsa-0.13.0\src\lib.rs:471
  29: ra_db::{{impl}}::parse
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_db\src\lib.rs:70
  30: ra_ide_api::diagnostics::diagnostics
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_ide_api\src\diagnostics.rs:27
  31: ra_ide_api::{{impl}}::diagnostics::{{closure}}
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_ide_api\src\lib.rs:525
  32: ra_db::CheckCanceled::catch_canceled::{{closure}}
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_db\src\lib.rs:39
  33: std::panicking::try::do_call<closure-0,alloc::vec::Vec<ra_ide_api::Diagnostic>>
             at /rustc/c6e9c76c59e3c10acd63ca9ec157a8894ea1a068\src\libstd\panicking.rs:296
  34: panic_unwind::__rust_maybe_catch_panic
             at /rustc/c6e9c76c59e3c10acd63ca9ec157a8894ea1a068\/src\libpanic_unwind\lib.rs:80
  35: std::panicking::try
             at /rustc/c6e9c76c59e3c10acd63ca9ec157a8894ea1a068\src\libstd\panicking.rs:275
  36: std::panic::catch_unwind
             at /rustc/c6e9c76c59e3c10acd63ca9ec157a8894ea1a068\src\libstd\panic.rs:394
  37: ra_db::CheckCanceled::catch_canceled<ra_ide_api::db::RootDatabase,closure-0,alloc::vec::Vec<ra_ide_api::Diagnostic>>
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_db\src\lib.rs:39
  38: ra_ide_api::Analysis::with_db
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_ide_api\src\lib.rs:547
  39: ra_ide_api::Analysis::diagnostics
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_ide_api\src\lib.rs:525
  40: ra_lsp_server::main_loop::handlers::publish_diagnostics
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_lsp_server\src\main_loop\handlers.rs:778
  41: ra_lsp_server::main_loop::update_file_notifications_on_threadpool::{{closure}}
             at C:\Users\user\Documents\Hacks\Rust\rust-analyzer\crates\ra_lsp_server\src\main_loop.rs:680
  42: threadpool::{{impl}}::call_box<closure-0>
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\threadpool-1.7.1\src\lib.rs:95
  43: threadpool::spawn_in_pool::{{closure}}
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\threadpool-1.7.1\src\lib.rs:767
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions