Skip to content

Panic in Parser::nth(): "the parser seems stuck" #13813

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
djc opened this issue Dec 21, 2022 · 2 comments
Closed

Panic in Parser::nth(): "the parser seems stuck" #13813

djc opened this issue Dec 21, 2022 · 2 comments

Comments

@djc
Copy link

djc commented Dec 21, 2022

Backtrace:

thread 'Worker' panicked at 'the parser seems stuck', crates/parser/src/parser.rs:55:9
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: parser::parser::Parser::nth
   3: parser::grammar::expressions::expr_bp
   4: parser::grammar::expressions::arg_list
   5: parser::grammar::expressions::expr_bp
   6: parser::grammar::expressions::atom::array_expr
   7: parser::grammar::expressions::atom::atom_expr
   8: parser::grammar::expressions::expr_bp
   9: parser::grammar::expressions::expr_bp
  10: parser::grammar::expressions::atom::tuple_expr
  11: parser::grammar::expressions::atom::atom_expr
  12: parser::grammar::expressions::expr_bp
  13: parser::grammar::expressions::atom::array_expr
  14: parser::grammar::expressions::atom::atom_expr
  15: parser::grammar::expressions::expr_bp
  16: parser::grammar::expressions::expr_bp
  17: parser::grammar::expressions::arg_list
  18: parser::grammar::expressions::expr_bp
  19: parser::grammar::expressions::record_expr_field_list
  20: parser::grammar::expressions::path_expr
  21: parser::grammar::expressions::atom::atom_expr
  22: parser::grammar::expressions::expr_bp
  23: parser::grammar::items::consts::const_or_static
  24: parser::grammar::items::opt_item
  25: parser::grammar::items::item_or_macro
  26: parser::grammar::items::mod_contents
  27: parser::grammar::entry::top::macro_items
  28: mbe::syntax_bridge::token_tree_to_syntax_node
  29: <hir_expand::db::ParseMacroExpansionQuery as salsa::plumbing::QueryFunction>::execute
  30: salsa::runtime::Runtime::execute_query_implementation
  31: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  32: salsa::derived::slot::Slot<Q,MP>::read
  33: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  34: <DB as hir_expand::db::AstDatabase>::parse_macro_expansion::__shim
  35: hir_expand::db::parse_or_expand
  36: hir_def::item_tree::ItemTree::file_item_tree_query
  37: salsa::runtime::Runtime::execute_query_implementation
  38: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  39: salsa::derived::slot::Slot<Q,MP>::read
  40: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  41: <DB as hir_def::db::DefDatabase>::file_item_tree::__shim
  42: hir_def::nameres::collector::DefCollector::collect_macro_expansion
  43: hir_def::nameres::collector::ModCollector::collect
  44: hir_def::nameres::collector::collect_defs
  45: hir_def::nameres::DefMap::crate_def_map_query
  46: salsa::runtime::Runtime::execute_query_implementation
  47: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  48: salsa::derived::slot::Slot<Q,MP>::read
  49: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  50: <DB as hir_def::db::DefDatabase>::crate_def_map_query::__shim
  51: hir_def::db::crate_def_map_wait
  52: hir_def::nameres::collector::collect_defs
  53: hir_def::nameres::DefMap::crate_def_map_query
  54: salsa::runtime::Runtime::execute_query_implementation
  55: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  56: salsa::derived::slot::Slot<Q,MP>::read
  57: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  58: <DB as hir_def::db::DefDatabase>::crate_def_map_query::__shim
  59: hir_def::db::crate_def_map_wait
  60: hir_def::nameres::collector::collect_defs
  61: hir_def::nameres::DefMap::crate_def_map_query
  62: salsa::runtime::Runtime::execute_query_implementation
  63: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  64: salsa::derived::slot::Slot<Q,MP>::read
  65: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  66: <DB as hir_def::db::DefDatabase>::crate_def_map_query::__shim
  67: hir_def::db::crate_def_map_wait
  68: hir_def::nameres::collector::collect_defs
  69: hir_def::nameres::DefMap::crate_def_map_query
  70: salsa::runtime::Runtime::execute_query_implementation
  71: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  72: salsa::derived::slot::Slot<Q,MP>::read
  73: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  74: <DB as hir_def::db::DefDatabase>::crate_def_map_query::__shim
  75: hir_def::db::crate_def_map_wait
  76: hir::semantics::source_to_def::SourceToDefCtx::file_to_def
  77: hir::semantics::source_to_def::SourceToDefCtx::find_container
  78: hir::semantics::SemanticsImpl::analyze_impl
  79: hir::semantics::SemanticsImpl::scope
  80: ide::inlay_hints::inlay_hints
  81: std::panicking::try
  82: rust_analyzer::handlers::handle_inlay_hints
  83: std::panicking::try
  84: <F as threadpool::FnBox>::call_box

This seems to be in response to the following source code (mentioned in the request: textDocument/codeLens):

use std::fs;

fn main() {
    let model = grapheme_to_phoneme::Model::load_in_memory().expect("should load");
    let dict = fs::read_to_string("/usr/share/dict/words").expect("should read words");
    let words = dict.lines().collect::<Vec<_>>();
    dbg!(&words[..10]);


    //let phonemes = model.predict_phonemes_strs("test").expect("should encode");
    //println!("{:?}", phonemes);
}

#[cfg(test)]
mod tests {
    use grapheme_to_phoneme::Model;

    #[test]
    fn basic() {
        let model = Model::load_in_memory().expect("should load");
        assert_eq!(
            model.predict_phonemes_strs("test").expect("should encode"),
            vec!["T", "EH1", "S", "T"]
                .iter()
                .map(|s| s.to_string())
                .collect::<Vec<String>>()
        );
    }
}

(FWIW, in the terminal Cargo/rustc don't seem to have any issues dealing with this project.)

rust-analyzer version: rust-analyzer version: 0.3.1325-standalone (9ed1829 2022-12-17)
rustc version: rustc 1.66.0 (69f9c33d7 2022-12-12)

@bjorn3
Copy link
Member

bjorn3 commented Dec 21, 2022

#13794 might have fixed this. Can you try the latest rust-analyzer version?

@djc
Copy link
Author

djc commented Dec 21, 2022

Yes, 0.4.1327-standalone (761b127 2022-12-20) seems to work. Thanks!

@bjorn3 bjorn3 closed this as completed Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants