Auto merge of #16348 - Veykril:nested-includes, r=Veykril

fix: Fix nested includes resolving from the wrong base file

Fixes https://github.com/rust-lang/rust-analyzer/issues/16109
This commit is contained in:
bors 2024-01-11 11:53:24 +00:00
commit 9d8889cdfc
3 changed files with 54 additions and 2 deletions

View file

@ -1264,6 +1264,54 @@ struct A;
);
}
#[test]
fn nested_include() {
check(
r#"
//- minicore: include
//- /lib.rs
include!("out_dir/includes.rs");
//- /out_dir/includes.rs
pub mod company_name {
pub mod network {
pub mod v1 {
include!("company_name.network.v1.rs");
}
}
}
//- /out_dir/company_name.network.v1.rs
pub struct IpAddress {
pub ip_type: &'static str,
}
/// Nested message and enum types in `IpAddress`.
pub mod ip_address {
pub enum IpType {
IpV4(u32),
}
}
"#,
expect![[r#"
crate
company_name: t
crate::company_name
network: t
crate::company_name::network
v1: t
crate::company_name::network::v1
IpAddress: t
ip_address: t
crate::company_name::network::v1::ip_address
IpType: t
"#]],
);
}
#[test]
fn macro_use_imports_all_macro_types() {
let db = TestDB::with_files(