Skip to content

Q: racer integration, find_definition usage #422

Closed
@jwilm

Description

@jwilm

I recently started integrating racer for YouCompleteMe support, and this is the first of what I'm sure will be many questions 😄. This question regards find_definition.

pub fn find_definition(src: &str, filepath: &path::Path, pos: usize, session: SessionRef) -> Option<Match>

One of the arguments is a source buffer. If I don’t write the buffer to disk first, I get a panic (full bt below).

thread 'engine::racer::tests::find_definition' panicked at 'index 0 and/or 89 in `` do not lie on character boundary', ../src/libcore/str/mod.rs:1441

However, writing the buffer to disk completely resolves that problem. It seems to me that, given a buffer, reading the initial file should be unnecessary. Is this a requirement? I would like to change the behavior to not do that if possible. I actually couldn’t find where it was doing that IO, either. Additionally, since this method is doing I/O, maybe it should return a Result instead of panicking while indexing a slice.

Backtrace

   6:        0x10c490097 - rust_begin_unwind
   7:        0x10c4b4060 - panicking::panic_fmt::h6c78ce0128588a957HK
   8:        0x10c4b7b60 - str::slice_error_fail::hae4b5de9c67475548OS
   9:        0x10c0f44b5 - str::traits::_<impl>::index::he8945502e3410953mBS
  10:        0x10c0f437e - string::_<impl>::index::h547be55ef8b5db17i3f
  11:        0x10c0f3b92 - core::_<impl>::deref::h6728862e5c44cb4atMa
  12:        0x10c1030aa - scopes::mask_comments::h758821d339eb152bJeb
  13:        0x10c10e321 - scopes::scope_start::h49adfd7fdda43b7544a
  14:        0x10c1c6f90 - nameres::search_local_scopes::h2aa638ee8218b5856xe
  15:        0x10c1bc129 - nameres::resolve_name::ha8fef8b2d1cc0115pPe
  16:        0x10c10912e - nameres::resolve_path::hd3f93ff20151730eeZe
  17:        0x10c10c842 - core::find_definition_::h8b9c5b4772ebed00tYa
  18:        0x10c10c16b - core::find_definition::h36205eee38345da54Xa
  19:        0x10c0dc75b - engine::racer::_<impl>::find_definition::h6f5d2878fe1b3851yea
  20:        0x10c0e34c0 - engine::racer::tests::find_definition::h607071473acdcea1yla
  21:        0x10c2469eb - boxed::_<impl>::call_box::call_box::h5504267803333294456
  22:        0x10c2490f0 - sys_common::unwind::try::try_fn::try_fn::h8503899523036047578
  23:        0x10c48fed8 - __rust_try
  24:        0x10c48de7e - sys_common::unwind::try::inner_try::h4c901f4c815f0df8y9r
  25:        0x10c2494ea - boxed::_<impl>::call_box::call_box::h16742266516396999763
  26:        0x10c4918ad - sys::thread::_<impl>::new::thread_start::h9bc185148c33bf72Kvw
  27:     0x7fff8add49b0 - _pthread_body
  28:     0x7fff8add492d - _pthread_start

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