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

std::fs::write inside of proc-macro breaks intellisense #17234

Closed
xxshady opened this issue May 15, 2024 · 11 comments
Closed

std::fs::write inside of proc-macro breaks intellisense #17234

xxshady opened this issue May 15, 2024 · 11 comments
Labels
A-proc-macro proc macro C-support Category: support questions S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@xxshady
Copy link

xxshady commented May 15, 2024

rust-analyzer version: 0.3.1958-standalone (5bf2f85 2024-05-09)

rustc version: 1.77.2

editor or extension: VSCode

code snippet to reproduce (UPDATED, again):

#[proc_macro_attribute]
pub fn repro(_: TokenStream, input: TokenStream) -> TokenStream {
    let crate_name = env!("CARGO_PKG_NAME");
    std::fs::write(format!("{crate_name}/repro"), "").unwrap();
    input
}
demo bugged:

not bugged:
@xxshady xxshady added the C-bug Category: bug label May 15, 2024
@Veykril
Copy link
Member

Veykril commented May 15, 2024

This works fine for me with and without the fs access

@flodiebold
Copy link
Member

It's a bad idea in general, though.

@Veykril Veykril added S-unactionable Issue requires feedback, design decisions or is blocked on other work A-proc-macro proc macro C-support Category: support questions and removed C-bug Category: bug labels May 15, 2024
@xxshady
Copy link
Author

xxshady commented May 15, 2024

This works fine for me with and without the fs access

@Veykril updated repro, for some reason it only happens when file is created inside of some directory

@Veykril
Copy link
Member

Veykril commented May 15, 2024

will check later, but is the macro perhaps panicking on your system for some reason? (that is is it hitting the unwrap) Cause then this is expected

@xxshady
Copy link
Author

xxshady commented May 15, 2024

no, its not panicking

@Veykril
Copy link
Member

Veykril commented May 16, 2024

Are you sure it doesn't? Because it does for me
image

@xxshady
Copy link
Author

xxshady commented May 18, 2024

are you on linux? because i'm on windows, i updated repro again xd, old one stopped reproducing for me

5-18-2024.19-42-28.mp4

@Veykril
Copy link
Member

Veykril commented May 18, 2024

I am on windows as well, can you enable the setting "rust-analyzer.diagnostics.experimental.enable": true,? Just realized that macro errrors are still gated so you wont see proc-macros panic by default (we should change that)

@xxshady
Copy link
Author

xxshady commented May 18, 2024

oh, i see, yes, it was panic in proc-macro

image

but why i can still see (some?) panics without enabling this experimental setting?

image

@Veykril
Copy link
Member

Veykril commented May 18, 2024

The latter one comes from rustc that we just display inline as part of running cargo check on save

@xxshady
Copy link
Author

xxshady commented May 18, 2024

ah, so proc-macro runs two times in workspace workdir, and in crate workdir, thats why file was creating

@xxshady xxshady closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-proc-macro proc macro C-support Category: support questions S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

No branches or pull requests

3 participants