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

Files included using include!() macro in lib.rs are still unlinked-file #17390

Closed
NessajCN opened this issue Jun 11, 2024 · 4 comments · Fixed by #17863
Closed

Files included using include!() macro in lib.rs are still unlinked-file #17390

NessajCN opened this issue Jun 11, 2024 · 4 comments · Fixed by #17863
Labels
A-ide general IDE features C-bug Category: bug

Comments

@NessajCN
Copy link

NessajCN commented Jun 11, 2024

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

rust-analyzer version: 0.4.1994-standalone [/home/nessaj/.vscode/extensions/rust-lang.rust-analyzer-0.4.1994-linux-x64/server/rust-analyzer]

rustc version: (eg. output of rustc -V)
rustc 1.78.0 (9b00956e5 2024-04-29)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)

VSCode 1.90.0 rust-analyzer v0.4.1994 (pre-release)

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

repository link (if public, optional): (eg. rust-analyzer)

code snippet to reproduce:

// src/lib.rs
include!("xx.rs");
// src/xx.rs
// Statements defined here all indicates: file not included in module tree rust-analyzer (unlinked-file)
// which worked perfect in previous versions.
pub const YY: u8 = 0xff;

Having tested in both Linux (Archlinux+KDE) and MacOS. Reproduced.

@NessajCN NessajCN added the C-bug Category: bug label Jun 11, 2024
@Veykril
Copy link
Member

Veykril commented Jun 11, 2024

Hmm right, this file is in fact not a module, so when we try to resolve it as one we fail emitting the diagnostic. Semantics::file_to_module_def should probably have a fallback check for files that don't resolve to one and then check if the file is included treating the callee module of the include! as the module maybe.

@NessajCN
Copy link
Author

NessajCN commented Aug 13, 2024

Hey @Veykril
I am not sure if I should open a new issue.
After your fix has been updated I found r-a did not recognize the following attributes correctly in lib.rs that using include!() macro:

// src/lib.rs
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
include!("./xx.rs");

Warnings like Type alias __u_char should have CamelCase name, e.g. UChar still popped up in included files like xx.rs ablove.
Could you possibly fix this?

@Veykril
Copy link
Member

Veykril commented Aug 13, 2024

That is a separate issue so please open an ew one

@NessajCN
Copy link
Author

That is a separate issue so please open an ew one

ok

lnicola pushed a commit to lnicola/rust that referenced this issue Aug 13, 2024
fix: Resolve included files to their calling modules in IDE layer

Fixes rust-lang/rust-analyzer#17390 at the expense of reporting duplicate diagnostics for modules that have includes in them when both the calling and called file are included.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ide general IDE features C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants