racer-rust / racer

Rust Code Completion utility
MIT License
3.36k stars 279 forks source link

Racer panics on Option::unwrap #731

Open Eternity-Yarr opened 7 years ago

Eternity-Yarr commented 7 years ago

i'm on

$racer --version
racer 2.0.8
Racer Error: 
thread 'searcher' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:323
Racer Error: 
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:323
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:355
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:371
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:549
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:511
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:495
   7: rust_begin_unwind
             at /checkout/src/libstd/panicking.rs:471
   8: core::panicking::panic_fmt
             at /checkout/src/libcore/panicking.rs:69
   9: core::panicking::panic
             at /checkout/src/libcore/panicking.rs:49
  10: racer::typeinf::get_type_of_match
             at /checkout/src/libcore/macros.rs:21
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/racer/typeinf.rs:16
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/racer/typeinf.rs:130
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/racer/typeinf.rs:270
  11: <core::option::Option<T>>::and_then
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/racer/ast.rs:494
             at /checkout/src/libcore/option.rs:578
  12: <racer::ast::ExprTypeVisitor<'c, 's> as syntex_syntax::visit::Visitor>::visit_expr
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/racer/ast.rs:489
  13: racer::ast::get_type_of
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/racer/ast.rs:1025
  14: racer::core::find_definition_
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/racer/core.rs:1089
  15: racer::run
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/racer/core.rs:1038
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/bin/main.rs:161
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/bin/main.rs:411
  16: racer::daemon
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/bin/main.rs:191
  17: racer::run
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/bin/main.rs:407
  18: racer::main
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.0.8/src/bin/main.rs:397
  19: std::panicking::try::do_call
             at /checkout/src/libstd/panicking.rs:454
  20: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  21: std::rt::lang_start
             at /checkout/src/libstd/panicking.rs:433
             at /checkout/src/libstd/panic.rs:361
             at /checkout/src/libstd/rt.rs:57
  22: __libc_start_main
  23: _start

I'm trying to find a definition of .ok() by running:

 racer find-definition 65 29 main.rs

on line:

        for line in reader.lines()
          .filter_map(|x| x.ok() )   // <-- line no 65
          .filter(|x| in_cname_pattern.is_match(x)) {
TedDriggs commented 7 years ago

Can you please try running this with RUST_LOG=racer=trace as an environment variable and share that output?

A playground with a minimal repro of the issue would also be helpful.

Eternity-Yarr commented 7 years ago

i think that for the whole trace output this part is relevant for current issue:

ERROR:racer: Search thread paniced: Any
DEBUG:racer::core: find_definition_ for |"x"| |"ok"| Field
DEBUG:racer::ast: visit_expr expr(4294967295: x)
DEBUG:racer::ast: expr is a path P[x]
DEBUG:racer::ast: resolve_ast_path P[x]
DEBUG:racer::nameres: resolve_path_with_str P[x]
DEBUG:racer::nameres: resolve_path P[x] "/home/user/projects/rqh/src/main.rs" 1708 ExactMatch
DEBUG:racer::nameres: resolve_name x "/home/user/projects/rqh/src/main.rs" 1708 ExactMatch Both
DEBUG:racer::nameres: search_local_scopes PathSegment { name: "x", types: [] } "/home/user/projects/rqh/src/main.rs" 1708 ExactMatch Both
DEBUG:racer::nameres: searching scope Both start: 1702 point: 1708 'x' "/home/user/projects/rqh/src/main.rs" ExactMatch local: true, session: Session { .. }
DEBUG:racer::typeinf: get_type_of match Match ["x", "/home/user/projects/rqh/src/main.rs", 4648, true, FnArg, [], [] ||x| x.ok() )

i'll try to make an minimal repro shortly

Eternity-Yarr commented 7 years ago

https://gist.github.com/Eternity-Yarr/b09c5190542989ce88925192624089bd here is minimal repro.

if i run RUST_BACKTRACE=1 RUST_LOG=racer=trace racer find-definition 9 28 main.rs, racer crashes

TedDriggs commented 7 years ago

Thanks!

What's happening here is that #697 is causing racer to find a definition for x where previously it wouldn't have.

Edit: My original statement was wrong. We're failing to find the beginning of the statement, and that's where the crash is occurring.