diff options
Diffstat (limited to 'crates/ra_hir/src/nameres/tests')
-rw-r--r-- | crates/ra_hir/src/nameres/tests/incremental.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/tests/macros.rs | 29 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/tests/mod_resolution.rs | 214 |
3 files changed, 139 insertions, 106 deletions
diff --git a/crates/ra_hir/src/nameres/tests/incremental.rs b/crates/ra_hir/src/nameres/tests/incremental.rs index c41862a0b..af9c39760 100644 --- a/crates/ra_hir/src/nameres/tests/incremental.rs +++ b/crates/ra_hir/src/nameres/tests/incremental.rs | |||
@@ -2,7 +2,7 @@ use super::*; | |||
2 | 2 | ||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use ra_db::SourceDatabase; | 5 | use ra_db::{SourceDatabase, SourceDatabaseExt}; |
6 | 6 | ||
7 | fn check_def_map_is_not_recomputed(initial: &str, file_change: &str) { | 7 | fn check_def_map_is_not_recomputed(initial: &str, file_change: &str) { |
8 | let (mut db, pos) = MockDatabase::with_position(initial); | 8 | let (mut db, pos) = MockDatabase::with_position(initial); |
diff --git a/crates/ra_hir/src/nameres/tests/macros.rs b/crates/ra_hir/src/nameres/tests/macros.rs index e4b408394..4f52ad2c5 100644 --- a/crates/ra_hir/src/nameres/tests/macros.rs +++ b/crates/ra_hir/src/nameres/tests/macros.rs | |||
@@ -38,21 +38,34 @@ fn macro_rules_can_define_modules() { | |||
38 | } | 38 | } |
39 | m!(n1); | 39 | m!(n1); |
40 | 40 | ||
41 | mod m { | ||
42 | m!(n3) | ||
43 | } | ||
44 | |||
41 | //- /n1.rs | 45 | //- /n1.rs |
42 | m!(n2) | 46 | m!(n2) |
43 | //- /n1/n2.rs | 47 | //- /n1/n2.rs |
44 | struct X; | 48 | struct X; |
49 | //- /m/n3.rs | ||
50 | struct Y; | ||
45 | ", | 51 | ", |
46 | ); | 52 | ); |
47 | assert_snapshot!(map, @r###" | 53 | assert_snapshot!(map, @r###" |
48 | ⋮crate | 54 | crate |
49 | ⋮n1: t | 55 | m: t |
50 | ⋮ | 56 | n1: t |
51 | ⋮crate::n1 | 57 | |
52 | ⋮n2: t | 58 | crate::m |
53 | ⋮ | 59 | n3: t |
54 | ⋮crate::n1::n2 | 60 | |
55 | ⋮X: t v | 61 | crate::m::n3 |
62 | Y: t v | ||
63 | |||
64 | crate::n1 | ||
65 | n2: t | ||
66 | |||
67 | crate::n1::n2 | ||
68 | X: t v | ||
56 | "###); | 69 | "###); |
57 | } | 70 | } |
58 | 71 | ||
diff --git a/crates/ra_hir/src/nameres/tests/mod_resolution.rs b/crates/ra_hir/src/nameres/tests/mod_resolution.rs index e3e6f1e95..f569aacdc 100644 --- a/crates/ra_hir/src/nameres/tests/mod_resolution.rs +++ b/crates/ra_hir/src/nameres/tests/mod_resolution.rs | |||
@@ -26,6 +26,33 @@ fn name_res_works_for_broken_modules() { | |||
26 | } | 26 | } |
27 | 27 | ||
28 | #[test] | 28 | #[test] |
29 | fn nested_module_resolution() { | ||
30 | let map = def_map( | ||
31 | " | ||
32 | //- /lib.rs | ||
33 | mod n1; | ||
34 | |||
35 | //- /n1.rs | ||
36 | mod n2; | ||
37 | |||
38 | //- /n1/n2.rs | ||
39 | struct X; | ||
40 | ", | ||
41 | ); | ||
42 | |||
43 | assert_snapshot!(map, @r###" | ||
44 | ⋮crate | ||
45 | ⋮n1: t | ||
46 | ⋮ | ||
47 | ⋮crate::n1 | ||
48 | ⋮n2: t | ||
49 | ⋮ | ||
50 | ⋮crate::n1::n2 | ||
51 | ⋮X: t v | ||
52 | "###); | ||
53 | } | ||
54 | |||
55 | #[test] | ||
29 | fn module_resolution_works_for_non_standard_filenames() { | 56 | fn module_resolution_works_for_non_standard_filenames() { |
30 | let map = def_map_with_crate_graph( | 57 | let map = def_map_with_crate_graph( |
31 | " | 58 | " |
@@ -53,18 +80,15 @@ fn module_resolution_works_for_non_standard_filenames() { | |||
53 | 80 | ||
54 | #[test] | 81 | #[test] |
55 | fn module_resolution_works_for_raw_modules() { | 82 | fn module_resolution_works_for_raw_modules() { |
56 | let map = def_map_with_crate_graph( | 83 | let map = def_map( |
57 | " | 84 | " |
58 | //- /library.rs | 85 | //- /lib.rs |
59 | mod r#async; | 86 | mod r#async; |
60 | use self::r#async::Bar; | 87 | use self::r#async::Bar; |
61 | 88 | ||
62 | //- /async.rs | 89 | //- /async.rs |
63 | pub struct Bar; | 90 | pub struct Bar; |
64 | ", | 91 | ", |
65 | crate_graph! { | ||
66 | "library": ("/library.rs", []), | ||
67 | }, | ||
68 | ); | 92 | ); |
69 | 93 | ||
70 | assert_snapshot!(map, @r###" | 94 | assert_snapshot!(map, @r###" |
@@ -79,9 +103,9 @@ fn module_resolution_works_for_raw_modules() { | |||
79 | 103 | ||
80 | #[test] | 104 | #[test] |
81 | fn module_resolution_decl_path() { | 105 | fn module_resolution_decl_path() { |
82 | let map = def_map_with_crate_graph( | 106 | let map = def_map( |
83 | r###" | 107 | r###" |
84 | //- /library.rs | 108 | //- /lib.rs |
85 | #[path = "bar/baz/foo.rs"] | 109 | #[path = "bar/baz/foo.rs"] |
86 | mod foo; | 110 | mod foo; |
87 | use self::foo::Bar; | 111 | use self::foo::Bar; |
@@ -89,9 +113,6 @@ fn module_resolution_decl_path() { | |||
89 | //- /bar/baz/foo.rs | 113 | //- /bar/baz/foo.rs |
90 | pub struct Bar; | 114 | pub struct Bar; |
91 | "###, | 115 | "###, |
92 | crate_graph! { | ||
93 | "library": ("/library.rs", []), | ||
94 | }, | ||
95 | ); | 116 | ); |
96 | 117 | ||
97 | assert_snapshot!(map, @r###" | 118 | assert_snapshot!(map, @r###" |
@@ -106,7 +127,7 @@ fn module_resolution_decl_path() { | |||
106 | 127 | ||
107 | #[test] | 128 | #[test] |
108 | fn module_resolution_module_with_path_in_mod_rs() { | 129 | fn module_resolution_module_with_path_in_mod_rs() { |
109 | let map = def_map_with_crate_graph( | 130 | let map = def_map( |
110 | r###" | 131 | r###" |
111 | //- /main.rs | 132 | //- /main.rs |
112 | mod foo; | 133 | mod foo; |
@@ -120,9 +141,6 @@ fn module_resolution_module_with_path_in_mod_rs() { | |||
120 | //- /foo/baz.rs | 141 | //- /foo/baz.rs |
121 | pub struct Baz; | 142 | pub struct Baz; |
122 | "###, | 143 | "###, |
123 | crate_graph! { | ||
124 | "main": ("/main.rs", []), | ||
125 | }, | ||
126 | ); | 144 | ); |
127 | 145 | ||
128 | assert_snapshot!(map, @r###" | 146 | assert_snapshot!(map, @r###" |
@@ -140,7 +158,7 @@ fn module_resolution_module_with_path_in_mod_rs() { | |||
140 | 158 | ||
141 | #[test] | 159 | #[test] |
142 | fn module_resolution_module_with_path_non_crate_root() { | 160 | fn module_resolution_module_with_path_non_crate_root() { |
143 | let map = def_map_with_crate_graph( | 161 | let map = def_map( |
144 | r###" | 162 | r###" |
145 | //- /main.rs | 163 | //- /main.rs |
146 | mod foo; | 164 | mod foo; |
@@ -154,9 +172,6 @@ fn module_resolution_module_with_path_non_crate_root() { | |||
154 | //- /baz.rs | 172 | //- /baz.rs |
155 | pub struct Baz; | 173 | pub struct Baz; |
156 | "###, | 174 | "###, |
157 | crate_graph! { | ||
158 | "main": ("/main.rs", []), | ||
159 | }, | ||
160 | ); | 175 | ); |
161 | 176 | ||
162 | assert_snapshot!(map, @r###" | 177 | assert_snapshot!(map, @r###" |
@@ -174,7 +189,7 @@ fn module_resolution_module_with_path_non_crate_root() { | |||
174 | 189 | ||
175 | #[test] | 190 | #[test] |
176 | fn module_resolution_module_decl_path_super() { | 191 | fn module_resolution_module_decl_path_super() { |
177 | let map = def_map_with_crate_graph( | 192 | let map = def_map( |
178 | r###" | 193 | r###" |
179 | //- /main.rs | 194 | //- /main.rs |
180 | #[path = "bar/baz/module.rs"] | 195 | #[path = "bar/baz/module.rs"] |
@@ -184,9 +199,6 @@ fn module_resolution_module_decl_path_super() { | |||
184 | //- /bar/baz/module.rs | 199 | //- /bar/baz/module.rs |
185 | use super::Baz; | 200 | use super::Baz; |
186 | "###, | 201 | "###, |
187 | crate_graph! { | ||
188 | "main": ("/main.rs", []), | ||
189 | }, | ||
190 | ); | 202 | ); |
191 | 203 | ||
192 | assert_snapshot!(map, @r###" | 204 | assert_snapshot!(map, @r###" |
@@ -201,7 +213,7 @@ fn module_resolution_module_decl_path_super() { | |||
201 | 213 | ||
202 | #[test] | 214 | #[test] |
203 | fn module_resolution_explicit_path_mod_rs() { | 215 | fn module_resolution_explicit_path_mod_rs() { |
204 | let map = def_map_with_crate_graph( | 216 | let map = def_map( |
205 | r###" | 217 | r###" |
206 | //- /main.rs | 218 | //- /main.rs |
207 | #[path = "module/mod.rs"] | 219 | #[path = "module/mod.rs"] |
@@ -210,9 +222,6 @@ fn module_resolution_explicit_path_mod_rs() { | |||
210 | //- /module/mod.rs | 222 | //- /module/mod.rs |
211 | pub struct Baz; | 223 | pub struct Baz; |
212 | "###, | 224 | "###, |
213 | crate_graph! { | ||
214 | "main": ("/main.rs", []), | ||
215 | }, | ||
216 | ); | 225 | ); |
217 | 226 | ||
218 | assert_snapshot!(map, @r###" | 227 | assert_snapshot!(map, @r###" |
@@ -226,7 +235,7 @@ fn module_resolution_explicit_path_mod_rs() { | |||
226 | 235 | ||
227 | #[test] | 236 | #[test] |
228 | fn module_resolution_relative_path() { | 237 | fn module_resolution_relative_path() { |
229 | let map = def_map_with_crate_graph( | 238 | let map = def_map( |
230 | r###" | 239 | r###" |
231 | //- /main.rs | 240 | //- /main.rs |
232 | mod foo; | 241 | mod foo; |
@@ -238,9 +247,6 @@ fn module_resolution_relative_path() { | |||
238 | //- /sub.rs | 247 | //- /sub.rs |
239 | pub struct Baz; | 248 | pub struct Baz; |
240 | "###, | 249 | "###, |
241 | crate_graph! { | ||
242 | "main": ("/main.rs", []), | ||
243 | }, | ||
244 | ); | 250 | ); |
245 | 251 | ||
246 | assert_snapshot!(map, @r###" | 252 | assert_snapshot!(map, @r###" |
@@ -257,7 +263,7 @@ fn module_resolution_relative_path() { | |||
257 | 263 | ||
258 | #[test] | 264 | #[test] |
259 | fn module_resolution_relative_path_2() { | 265 | fn module_resolution_relative_path_2() { |
260 | let map = def_map_with_crate_graph( | 266 | let map = def_map( |
261 | r###" | 267 | r###" |
262 | //- /main.rs | 268 | //- /main.rs |
263 | mod foo; | 269 | mod foo; |
@@ -269,9 +275,6 @@ fn module_resolution_relative_path_2() { | |||
269 | //- /sub.rs | 275 | //- /sub.rs |
270 | pub struct Baz; | 276 | pub struct Baz; |
271 | "###, | 277 | "###, |
272 | crate_graph! { | ||
273 | "main": ("/main.rs", []), | ||
274 | }, | ||
275 | ); | 278 | ); |
276 | 279 | ||
277 | assert_snapshot!(map, @r###" | 280 | assert_snapshot!(map, @r###" |
@@ -288,7 +291,7 @@ fn module_resolution_relative_path_2() { | |||
288 | 291 | ||
289 | #[test] | 292 | #[test] |
290 | fn module_resolution_explicit_path_mod_rs_2() { | 293 | fn module_resolution_explicit_path_mod_rs_2() { |
291 | let map = def_map_with_crate_graph( | 294 | let map = def_map( |
292 | r###" | 295 | r###" |
293 | //- /main.rs | 296 | //- /main.rs |
294 | #[path = "module/bar/mod.rs"] | 297 | #[path = "module/bar/mod.rs"] |
@@ -297,9 +300,6 @@ fn module_resolution_explicit_path_mod_rs_2() { | |||
297 | //- /module/bar/mod.rs | 300 | //- /module/bar/mod.rs |
298 | pub struct Baz; | 301 | pub struct Baz; |
299 | "###, | 302 | "###, |
300 | crate_graph! { | ||
301 | "main": ("/main.rs", []), | ||
302 | }, | ||
303 | ); | 303 | ); |
304 | 304 | ||
305 | assert_snapshot!(map, @r###" | 305 | assert_snapshot!(map, @r###" |
@@ -313,7 +313,7 @@ fn module_resolution_explicit_path_mod_rs_2() { | |||
313 | 313 | ||
314 | #[test] | 314 | #[test] |
315 | fn module_resolution_explicit_path_mod_rs_with_win_separator() { | 315 | fn module_resolution_explicit_path_mod_rs_with_win_separator() { |
316 | let map = def_map_with_crate_graph( | 316 | let map = def_map( |
317 | r###" | 317 | r###" |
318 | //- /main.rs | 318 | //- /main.rs |
319 | #[path = "module\bar\mod.rs"] | 319 | #[path = "module\bar\mod.rs"] |
@@ -322,9 +322,6 @@ fn module_resolution_explicit_path_mod_rs_with_win_separator() { | |||
322 | //- /module/bar/mod.rs | 322 | //- /module/bar/mod.rs |
323 | pub struct Baz; | 323 | pub struct Baz; |
324 | "###, | 324 | "###, |
325 | crate_graph! { | ||
326 | "main": ("/main.rs", []), | ||
327 | }, | ||
328 | ); | 325 | ); |
329 | 326 | ||
330 | assert_snapshot!(map, @r###" | 327 | assert_snapshot!(map, @r###" |
@@ -338,7 +335,7 @@ fn module_resolution_explicit_path_mod_rs_with_win_separator() { | |||
338 | 335 | ||
339 | #[test] | 336 | #[test] |
340 | fn module_resolution_decl_inside_inline_module_with_path_attribute() { | 337 | fn module_resolution_decl_inside_inline_module_with_path_attribute() { |
341 | let map = def_map_with_crate_graph( | 338 | let map = def_map( |
342 | r###" | 339 | r###" |
343 | //- /main.rs | 340 | //- /main.rs |
344 | #[path = "models"] | 341 | #[path = "models"] |
@@ -349,9 +346,6 @@ fn module_resolution_decl_inside_inline_module_with_path_attribute() { | |||
349 | //- /models/bar.rs | 346 | //- /models/bar.rs |
350 | pub struct Baz; | 347 | pub struct Baz; |
351 | "###, | 348 | "###, |
352 | crate_graph! { | ||
353 | "main": ("/main.rs", []), | ||
354 | }, | ||
355 | ); | 349 | ); |
356 | 350 | ||
357 | assert_snapshot!(map, @r###" | 351 | assert_snapshot!(map, @r###" |
@@ -368,7 +362,7 @@ fn module_resolution_decl_inside_inline_module_with_path_attribute() { | |||
368 | 362 | ||
369 | #[test] | 363 | #[test] |
370 | fn module_resolution_decl_inside_inline_module() { | 364 | fn module_resolution_decl_inside_inline_module() { |
371 | let map = def_map_with_crate_graph( | 365 | let map = def_map( |
372 | r###" | 366 | r###" |
373 | //- /main.rs | 367 | //- /main.rs |
374 | mod foo { | 368 | mod foo { |
@@ -378,9 +372,6 @@ fn module_resolution_decl_inside_inline_module() { | |||
378 | //- /foo/bar.rs | 372 | //- /foo/bar.rs |
379 | pub struct Baz; | 373 | pub struct Baz; |
380 | "###, | 374 | "###, |
381 | crate_graph! { | ||
382 | "main": ("/main.rs", []), | ||
383 | }, | ||
384 | ); | 375 | ); |
385 | 376 | ||
386 | assert_snapshot!(map, @r###" | 377 | assert_snapshot!(map, @r###" |
@@ -397,7 +388,7 @@ fn module_resolution_decl_inside_inline_module() { | |||
397 | 388 | ||
398 | #[test] | 389 | #[test] |
399 | fn module_resolution_decl_inside_inline_module_2_with_path_attribute() { | 390 | fn module_resolution_decl_inside_inline_module_2_with_path_attribute() { |
400 | let map = def_map_with_crate_graph( | 391 | let map = def_map( |
401 | r###" | 392 | r###" |
402 | //- /main.rs | 393 | //- /main.rs |
403 | #[path = "models/db"] | 394 | #[path = "models/db"] |
@@ -408,9 +399,6 @@ fn module_resolution_decl_inside_inline_module_2_with_path_attribute() { | |||
408 | //- /models/db/bar.rs | 399 | //- /models/db/bar.rs |
409 | pub struct Baz; | 400 | pub struct Baz; |
410 | "###, | 401 | "###, |
411 | crate_graph! { | ||
412 | "main": ("/main.rs", []), | ||
413 | }, | ||
414 | ); | 402 | ); |
415 | 403 | ||
416 | assert_snapshot!(map, @r###" | 404 | assert_snapshot!(map, @r###" |
@@ -427,7 +415,7 @@ fn module_resolution_decl_inside_inline_module_2_with_path_attribute() { | |||
427 | 415 | ||
428 | #[test] | 416 | #[test] |
429 | fn module_resolution_decl_inside_inline_module_3() { | 417 | fn module_resolution_decl_inside_inline_module_3() { |
430 | let map = def_map_with_crate_graph( | 418 | let map = def_map( |
431 | r###" | 419 | r###" |
432 | //- /main.rs | 420 | //- /main.rs |
433 | #[path = "models/db"] | 421 | #[path = "models/db"] |
@@ -439,9 +427,6 @@ fn module_resolution_decl_inside_inline_module_3() { | |||
439 | //- /models/db/users.rs | 427 | //- /models/db/users.rs |
440 | pub struct Baz; | 428 | pub struct Baz; |
441 | "###, | 429 | "###, |
442 | crate_graph! { | ||
443 | "main": ("/main.rs", []), | ||
444 | }, | ||
445 | ); | 430 | ); |
446 | 431 | ||
447 | assert_snapshot!(map, @r###" | 432 | assert_snapshot!(map, @r###" |
@@ -458,7 +443,7 @@ fn module_resolution_decl_inside_inline_module_3() { | |||
458 | 443 | ||
459 | #[test] | 444 | #[test] |
460 | fn module_resolution_decl_inside_inline_module_empty_path() { | 445 | fn module_resolution_decl_inside_inline_module_empty_path() { |
461 | let map = def_map_with_crate_graph( | 446 | let map = def_map( |
462 | r###" | 447 | r###" |
463 | //- /main.rs | 448 | //- /main.rs |
464 | #[path = ""] | 449 | #[path = ""] |
@@ -467,12 +452,9 @@ fn module_resolution_decl_inside_inline_module_empty_path() { | |||
467 | mod bar; | 452 | mod bar; |
468 | } | 453 | } |
469 | 454 | ||
470 | //- /foo/users.rs | 455 | //- /users.rs |
471 | pub struct Baz; | 456 | pub struct Baz; |
472 | "###, | 457 | "###, |
473 | crate_graph! { | ||
474 | "main": ("/main.rs", []), | ||
475 | }, | ||
476 | ); | 458 | ); |
477 | 459 | ||
478 | assert_snapshot!(map, @r###" | 460 | assert_snapshot!(map, @r###" |
@@ -489,32 +471,25 @@ fn module_resolution_decl_inside_inline_module_empty_path() { | |||
489 | 471 | ||
490 | #[test] | 472 | #[test] |
491 | fn module_resolution_decl_empty_path() { | 473 | fn module_resolution_decl_empty_path() { |
492 | let map = def_map_with_crate_graph( | 474 | let map = def_map( |
493 | r###" | 475 | r###" |
494 | //- /main.rs | 476 | //- /main.rs |
495 | #[path = ""] | 477 | #[path = ""] // Should try to read `/` (a directory) |
496 | mod foo; | 478 | mod foo; |
497 | 479 | ||
498 | //- /foo.rs | 480 | //- /foo.rs |
499 | pub struct Baz; | 481 | pub struct Baz; |
500 | "###, | 482 | "###, |
501 | crate_graph! { | ||
502 | "main": ("/main.rs", []), | ||
503 | }, | ||
504 | ); | 483 | ); |
505 | 484 | ||
506 | assert_snapshot!(map, @r###" | 485 | assert_snapshot!(map, @r###" |
507 | ⋮crate | 486 | ⋮crate |
508 | ⋮foo: t | ||
509 | ⋮ | ||
510 | ⋮crate::foo | ||
511 | ⋮Baz: t v | ||
512 | "###); | 487 | "###); |
513 | } | 488 | } |
514 | 489 | ||
515 | #[test] | 490 | #[test] |
516 | fn module_resolution_decl_inside_inline_module_relative_path() { | 491 | fn module_resolution_decl_inside_inline_module_relative_path() { |
517 | let map = def_map_with_crate_graph( | 492 | let map = def_map( |
518 | r###" | 493 | r###" |
519 | //- /main.rs | 494 | //- /main.rs |
520 | #[path = "./models"] | 495 | #[path = "./models"] |
@@ -525,9 +500,6 @@ fn module_resolution_decl_inside_inline_module_relative_path() { | |||
525 | //- /models/bar.rs | 500 | //- /models/bar.rs |
526 | pub struct Baz; | 501 | pub struct Baz; |
527 | "###, | 502 | "###, |
528 | crate_graph! { | ||
529 | "main": ("/main.rs", []), | ||
530 | }, | ||
531 | ); | 503 | ); |
532 | 504 | ||
533 | assert_snapshot!(map, @r###" | 505 | assert_snapshot!(map, @r###" |
@@ -544,7 +516,7 @@ fn module_resolution_decl_inside_inline_module_relative_path() { | |||
544 | 516 | ||
545 | #[test] | 517 | #[test] |
546 | fn module_resolution_decl_inside_inline_module_in_crate_root() { | 518 | fn module_resolution_decl_inside_inline_module_in_crate_root() { |
547 | let map = def_map_with_crate_graph( | 519 | let map = def_map( |
548 | r###" | 520 | r###" |
549 | //- /main.rs | 521 | //- /main.rs |
550 | mod foo { | 522 | mod foo { |
@@ -556,9 +528,6 @@ fn module_resolution_decl_inside_inline_module_in_crate_root() { | |||
556 | //- /foo/baz.rs | 528 | //- /foo/baz.rs |
557 | pub struct Baz; | 529 | pub struct Baz; |
558 | "###, | 530 | "###, |
559 | crate_graph! { | ||
560 | "main": ("/main.rs", []), | ||
561 | }, | ||
562 | ); | 531 | ); |
563 | 532 | ||
564 | assert_snapshot!(map, @r###" | 533 | assert_snapshot!(map, @r###" |
@@ -576,7 +545,7 @@ fn module_resolution_decl_inside_inline_module_in_crate_root() { | |||
576 | 545 | ||
577 | #[test] | 546 | #[test] |
578 | fn module_resolution_decl_inside_inline_module_in_mod_rs() { | 547 | fn module_resolution_decl_inside_inline_module_in_mod_rs() { |
579 | let map = def_map_with_crate_graph( | 548 | let map = def_map( |
580 | r###" | 549 | r###" |
581 | //- /main.rs | 550 | //- /main.rs |
582 | mod foo; | 551 | mod foo; |
@@ -591,9 +560,6 @@ fn module_resolution_decl_inside_inline_module_in_mod_rs() { | |||
591 | //- /foo/bar/qwe.rs | 560 | //- /foo/bar/qwe.rs |
592 | pub struct Baz; | 561 | pub struct Baz; |
593 | "###, | 562 | "###, |
594 | crate_graph! { | ||
595 | "main": ("/main.rs", []), | ||
596 | }, | ||
597 | ); | 563 | ); |
598 | 564 | ||
599 | assert_snapshot!(map, @r###" | 565 | assert_snapshot!(map, @r###" |
@@ -614,7 +580,7 @@ fn module_resolution_decl_inside_inline_module_in_mod_rs() { | |||
614 | 580 | ||
615 | #[test] | 581 | #[test] |
616 | fn module_resolution_decl_inside_inline_module_in_non_crate_root() { | 582 | fn module_resolution_decl_inside_inline_module_in_non_crate_root() { |
617 | let map = def_map_with_crate_graph( | 583 | let map = def_map( |
618 | r###" | 584 | r###" |
619 | //- /main.rs | 585 | //- /main.rs |
620 | mod foo; | 586 | mod foo; |
@@ -626,12 +592,9 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root() { | |||
626 | } | 592 | } |
627 | use self::bar::baz::Baz; | 593 | use self::bar::baz::Baz; |
628 | 594 | ||
629 | //- /bar/qwe.rs | 595 | //- /foo/bar/qwe.rs |
630 | pub struct Baz; | 596 | pub struct Baz; |
631 | "###, | 597 | "###, |
632 | crate_graph! { | ||
633 | "main": ("/main.rs", []), | ||
634 | }, | ||
635 | ); | 598 | ); |
636 | 599 | ||
637 | assert_snapshot!(map, @r###" | 600 | assert_snapshot!(map, @r###" |
@@ -652,7 +615,7 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root() { | |||
652 | 615 | ||
653 | #[test] | 616 | #[test] |
654 | fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() { | 617 | fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() { |
655 | let map = def_map_with_crate_graph( | 618 | let map = def_map( |
656 | r###" | 619 | r###" |
657 | //- /main.rs | 620 | //- /main.rs |
658 | mod foo; | 621 | mod foo; |
@@ -667,9 +630,6 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() { | |||
667 | //- /bar/baz.rs | 630 | //- /bar/baz.rs |
668 | pub struct Baz; | 631 | pub struct Baz; |
669 | "###, | 632 | "###, |
670 | crate_graph! { | ||
671 | "main": ("/main.rs", []), | ||
672 | }, | ||
673 | ); | 633 | ); |
674 | 634 | ||
675 | assert_snapshot!(map, @r###" | 635 | assert_snapshot!(map, @r###" |
@@ -709,7 +669,7 @@ fn unresolved_module_diagnostics() { | |||
709 | 669 | ||
710 | #[test] | 670 | #[test] |
711 | fn module_resolution_decl_inside_module_in_non_crate_root_2() { | 671 | fn module_resolution_decl_inside_module_in_non_crate_root_2() { |
712 | let map = def_map_with_crate_graph( | 672 | let map = def_map( |
713 | r###" | 673 | r###" |
714 | //- /main.rs | 674 | //- /main.rs |
715 | #[path="module/m2.rs"] | 675 | #[path="module/m2.rs"] |
@@ -721,9 +681,6 @@ fn module_resolution_decl_inside_module_in_non_crate_root_2() { | |||
721 | //- /module/submod.rs | 681 | //- /module/submod.rs |
722 | pub struct Baz; | 682 | pub struct Baz; |
723 | "###, | 683 | "###, |
724 | crate_graph! { | ||
725 | "main": ("/main.rs", []), | ||
726 | }, | ||
727 | ); | 684 | ); |
728 | 685 | ||
729 | assert_snapshot!(map, @r###" | 686 | assert_snapshot!(map, @r###" |
@@ -737,3 +694,66 @@ fn module_resolution_decl_inside_module_in_non_crate_root_2() { | |||
737 | ⋮Baz: t v | 694 | ⋮Baz: t v |
738 | "###); | 695 | "###); |
739 | } | 696 | } |
697 | |||
698 | #[test] | ||
699 | fn nested_out_of_line_module() { | ||
700 | let map = def_map( | ||
701 | r###" | ||
702 | //- /lib.rs | ||
703 | mod a { | ||
704 | mod b { | ||
705 | mod c; | ||
706 | } | ||
707 | } | ||
708 | |||
709 | //- /a/b/c.rs | ||
710 | struct X; | ||
711 | "###, | ||
712 | ); | ||
713 | |||
714 | assert_snapshot!(map, @r###" | ||
715 | crate | ||
716 | a: t | ||
717 | |||
718 | crate::a | ||
719 | b: t | ||
720 | |||
721 | crate::a::b | ||
722 | c: t | ||
723 | |||
724 | crate::a::b::c | ||
725 | X: t v | ||
726 | "###); | ||
727 | } | ||
728 | |||
729 | #[test] | ||
730 | fn nested_out_of_line_module_with_path() { | ||
731 | let map = def_map( | ||
732 | r###" | ||
733 | //- /lib.rs | ||
734 | mod a { | ||
735 | #[path = "d/e"] | ||
736 | mod b { | ||
737 | mod c; | ||
738 | } | ||
739 | } | ||
740 | |||
741 | //- /a/d/e/c.rs | ||
742 | struct X; | ||
743 | "###, | ||
744 | ); | ||
745 | |||
746 | assert_snapshot!(map, @r###" | ||
747 | crate | ||
748 | a: t | ||
749 | |||
750 | crate::a | ||
751 | b: t | ||
752 | |||
753 | crate::a::b | ||
754 | c: t | ||
755 | |||
756 | crate::a::b::c | ||
757 | X: t v | ||
758 | "###); | ||
759 | } | ||