Skip to content

Go to definition doesn't work for unqualified function-like proc macros #7073

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
lnicola opened this issue Dec 29, 2020 · 2 comments · Fixed by #8091
Closed

Go to definition doesn't work for unqualified function-like proc macros #7073

lnicola opened this issue Dec 29, 2020 · 2 comments · Fixed by #8091
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now

Comments

@lnicola
Copy link
Member

lnicola commented Dec 29, 2020

// using the unzip-n crate

use unzip_n::unzip_n;

unzip_n!(3); // trigger go to def here
unzip_n::unzip_n!(4); // this one works

fn main() {}
@lnicola lnicola changed the title Go to definition doesn't work for unqualified function-like macros Go to definition doesn't work for unqualified function-like proc macros Dec 29, 2020
@lnicola lnicola added A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now labels Dec 29, 2020
@AdnoC
Copy link
Contributor

AdnoC commented Dec 31, 2020

Issue is that hir::MacroDef does not have an ast-node when it is for a proc-macro. (See https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro.20no.20ast-node). When doing unzip_n::unzip_n!(4) we classify it as a function rather than a macro. And this for some reason works.

Specifically, the NameRefClass for unzip_n!(3) is

Definition(Macro(MacroDef { id: MacroDefId { krate: CrateId(53), ast_id: None, kind: ProcMacro(ProcMacroExpander { krate: CrateId(53), proc_macro_id: None }), local_inner: false } }))

and the NameRefClass for unizp_n::unzip_n!(4) is

Definition(ModuleDef(Function(Function { id: FunctionId(1115) })))

@jonas-schievink
Copy link
Contributor

This was fixed by #8088, I'll try to add a test

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