File tree Expand file tree Collapse file tree 2 files changed +47
-5
lines changed
src/tools/rust-analyzer/crates/hir-def/src/nameres Expand file tree Collapse file tree 2 files changed +47
-5
lines changed Original file line number Diff line number Diff line change 11//! This module resolves `mod foo;` declaration to file.
22use arrayvec:: ArrayVec ;
33use base_db:: AnchoredPath ;
4- use hir_expand:: { name:: Name , HirFileIdExt , MacroFileIdExt } ;
4+ use hir_expand:: { name:: Name , HirFileIdExt } ;
55use limit:: Limit ;
66use span:: EditionedFileId ;
77use syntax:: ToSmolStr as _;
@@ -73,10 +73,6 @@ impl ModDir {
7373 Some ( attr_path) => {
7474 candidate_files. push ( self . dir_path . join_attr ( attr_path, self . root_non_dir_owner ) )
7575 }
76- None if file_id. macro_file ( ) . map_or ( false , |it| it. is_include_macro ( db. upcast ( ) ) ) => {
77- candidate_files. push ( format ! ( "{}.rs" , name. display( db. upcast( ) ) ) ) ;
78- candidate_files. push ( format ! ( "{}/mod.rs" , name. display( db. upcast( ) ) ) ) ;
79- }
8076 None => {
8177 candidate_files. push ( format ! (
8278 "{}{}.rs" ,
Original file line number Diff line number Diff line change @@ -1309,6 +1309,52 @@ pub mod ip_address {
13091309 ) ;
13101310}
13111311
1312+ #[ test]
1313+ fn include_with_submod_file ( ) {
1314+ check (
1315+ r#"
1316+ //- minicore: include
1317+ //- /lib.rs
1318+ include!("out_dir/includes.rs");
1319+
1320+ //- /out_dir/includes.rs
1321+ pub mod company_name {
1322+ pub mod network {
1323+ pub mod v1;
1324+ }
1325+ }
1326+ //- /out_dir/company_name/network/v1.rs
1327+ pub struct IpAddress {
1328+ pub ip_type: &'static str,
1329+ }
1330+ /// Nested message and enum types in `IpAddress`.
1331+ pub mod ip_address {
1332+ pub enum IpType {
1333+ IpV4(u32),
1334+ }
1335+ }
1336+
1337+ "# ,
1338+ expect ! [ [ r#"
1339+ crate
1340+ company_name: t
1341+
1342+ crate::company_name
1343+ network: t
1344+
1345+ crate::company_name::network
1346+ v1: t
1347+
1348+ crate::company_name::network::v1
1349+ IpAddress: t
1350+ ip_address: t
1351+
1352+ crate::company_name::network::v1::ip_address
1353+ IpType: t
1354+ "# ] ] ,
1355+ ) ;
1356+ }
1357+
13121358#[ test]
13131359fn macro_use_imports_all_macro_types ( ) {
13141360 let db = TestDB :: with_files (
You can’t perform that action at this time.
0 commit comments