rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.09k stars 1.57k forks source link

Attributes like #![allow(non_camel_case_types)] not recognized in files included using `include!()` macro #17874

Open NessajCN opened 1 month ago

NessajCN commented 1 month ago

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

rustc version: rustc 1.80.1 (3f5fd8dd4 2024-08-06)

editor or extension: VSCode 1.92.1, rust-analyzer v0.4.2071 (pre-release)

relevant settings:

repository link (if public, optional):

code snippet to reproduce:

// src/lib.rs
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
include!("./xx.rs");
// src/xx.rs
pub type __u_char = ::std::os::raw::c_uchar;

After #17863 has been applied it seemed 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.

ChayimFriedman2 commented 1 day ago

This is fixed now, probably since https://github.com/rust-lang/rust-analyzer/pull/18099.