Skip to content

panic when using 'go to definition' on include!d file #6992

@flodiebold

Description

@flodiebold

Trying to go to definition on a method defined in an include!d file currently gives me a panic:

thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
  left: `HirFileId(MacroFile(MacroFile { macro_call_id: EagerMacro(EagerMacroId(2612)) }))`,
 right: `HirFileId(FileId(FileId(0)))`', crates/hir_expand/src/lib.rs:464:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
   1: std::panicking::begin_panic_fmt
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:437
   2: hir_expand::InFile<&rowan::api::SyntaxNode<syntax::syntax_node::RustLanguage>>::original_file_range
   3: ide::display::navigation_target::NavigationTarget::from_named
   4: <D as ide::display::navigation_target::ToNav>::to_nav
   5: <hir::code_model::ModuleDef as ide::display::navigation_target::TryToNav>::try_to_nav
   6: <ide_db::defs::Definition as ide::display::navigation_target::TryToNav>::try_to_nav
   7: ide::goto_definition::reference_definition
   8: ide::goto_definition::goto_definition
   9: std::panicking::try
  10: ide::Analysis::goto_definition
  11: rust_analyzer::handlers::handle_goto_definition

main.rs:

include!("./foo.rs");

fn main() {
    S.foo();
}

foo.rs:

/// S.
struct S;

impl S {
    fn foo(&self) {}
}

Metadata

Metadata

Labels

A-macromacro expansionS-actionableSomeone could pick this issue up and work on it right now

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions