File tree 2 files changed +47
-5
lines changed
src/tools/rust-analyzer/crates/hir-def/src/nameres
2 files changed +47
-5
lines changed Original file line number Diff line number Diff line change 1
1
//! This module resolves `mod foo;` declaration to file.
2
2
use arrayvec:: ArrayVec ;
3
3
use base_db:: AnchoredPath ;
4
- use hir_expand:: { name:: Name , HirFileIdExt , MacroFileIdExt } ;
4
+ use hir_expand:: { name:: Name , HirFileIdExt } ;
5
5
use limit:: Limit ;
6
6
use span:: EditionedFileId ;
7
7
use syntax:: ToSmolStr as _;
@@ -73,10 +73,6 @@ impl ModDir {
73
73
Some ( attr_path) => {
74
74
candidate_files. push ( self . dir_path . join_attr ( attr_path, self . root_non_dir_owner ) )
75
75
}
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
- }
80
76
None => {
81
77
candidate_files. push ( format ! (
82
78
"{}{}.rs" ,
Original file line number Diff line number Diff line change @@ -1309,6 +1309,52 @@ pub mod ip_address {
1309
1309
) ;
1310
1310
}
1311
1311
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
+
1312
1358
#[ test]
1313
1359
fn macro_use_imports_all_macro_types ( ) {
1314
1360
let db = TestDB :: with_files (
You can’t perform that action at this time.
0 commit comments