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

False positive diagnostic in proc-macro #17630

Closed
laurmaedje opened this issue Jul 18, 2024 · 4 comments · Fixed by #18160
Closed

False positive diagnostic in proc-macro #17630

laurmaedje opened this issue Jul 18, 2024 · 4 comments · Fixed by #18160
Labels
A-nameres name, path and module resolution C-bug Category: bug

Comments

@laurmaedje
Copy link

On the Typst codebase, rust-analyzer raises a false positive diagnostic since a while. The concrete error message (typst: explicit parent type required (rust-analyzer macro-error)) is specific to the codebase since it stems from a proc macro, but the important part is that the command line compiler doesn't produce this diagnostic.

I'm not sure when exactly the diagnostic started, but it used to work and if I switch back to a ~2 months old rust-analyzer release, it works again.

rust-analyzer version: 0.3.2037-standalone (e9afba5 2024-07-14)

rustc version: rustc 1.79.0 (129f3b996 2024-06-10)

editor or extension: VSCode, extension version v0.3.2037

repository link: https://github.com/typst/typst

code snippet to reproduce: crates/typst/src/foundations/array.rs

@laurmaedje laurmaedje added the C-bug Category: bug label Jul 18, 2024
@laurmaedje laurmaedje changed the title False positive error in proc-macro False positive diagnostic in proc-macro Jul 18, 2024
@Veykril Veykril added A-macro macro expansion A-proc-macro proc macro labels Jul 18, 2024
@Jeremiah-Griffin
Copy link

Jeremiah-Griffin commented Jul 22, 2024

Thanks for the working rust analyzer build.

I'm having a vaguely similar issue in #17615 so I'll start here.

@Veykril
Copy link
Member

Veykril commented Jul 23, 2024

The problem seems to be that we fail to resolve the ty and scope macros in the typst codebase. r-a seems to get confused by the glob re-exports being shadowed by the same named modules

@Veykril Veykril added A-nameres name, path and module resolution and removed A-macro macro expansion A-proc-macro proc macro labels Jul 23, 2024
@Leedehai
Copy link

Leedehai commented Jul 25, 2024

r-a seems to get confused by the glob re-exports being shadowed by the same named modules

Hi, am I right to elaborate your finding like this: crates/typst/src/foundations/ty.rs re-exports the ty and scope macros, but since crates/typst/src/foundations/mod.rs has mod ty; and mod scope;, these macro names, which are exported by pub use self::ty::*; in that mod.rs file, are shadowed?

Further, I also tried adding pub use typst_macros::{scope, ty}; directly in that mod.rs, after the module declarations, and the same issue remains. But if I put that re-export statement before the module declarations, the issue goes away.

@Veykril
Copy link
Member

Veykril commented Jul 26, 2024

Yes, I don't know the exact problem here but the setup of the mod declarations + more visible re-exports is what seems to be tripping up rust-analyzer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-nameres name, path and module resolution C-bug Category: bug
Projects
None yet
4 participants