Skip to content
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

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

Closed
flodiebold opened this issue Dec 21, 2020 · 1 comment · Fixed by #7000
Closed

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

flodiebold opened this issue Dec 21, 2020 · 1 comment · Fixed by #7000
Assignees
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now

Comments

@flodiebold
Copy link
Member

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) {}
}
@flodiebold flodiebold added the S-actionable Someone could pick this issue up and work on it right now label Dec 21, 2020
@edwin0cheng edwin0cheng added the A-macro macro expansion label Dec 22, 2020
@jonas-schievink
Copy link
Contributor

I added this assertion to original_file_range, but it turns out that call_node returns None for eager macros, so determining the original macro invocation stops inside the include! call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants