aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r--crates/ra_hir_def/src/nameres/tests/globs.rs155
1 files changed, 28 insertions, 127 deletions
diff --git a/crates/ra_hir_def/src/nameres/tests/globs.rs b/crates/ra_hir_def/src/nameres/tests/globs.rs
index f0d85d301..f117b0362 100644
--- a/crates/ra_hir_def/src/nameres/tests/globs.rs
+++ b/crates/ra_hir_def/src/nameres/tests/globs.rs
@@ -232,146 +232,47 @@ fn glob_enum_group() {
232 232
233#[test] 233#[test]
234fn glob_shadowed_def() { 234fn glob_shadowed_def() {
235 let db = TestDB::with_files( 235 mark::check!(import_shadowed);
236 let map = def_map(
236 r###" 237 r###"
237 //- /lib.rs 238 //- /lib.rs
238 mod foo; 239 mod foo;
239 mod bar; 240 mod bar;
240 241
241 use foo::*; 242 use foo::*;
242 use bar::Baz; 243 use bar::baz;
244
245 use baz::Bar;
243 246
244 //- /foo.rs 247 //- /foo.rs
245 pub struct Baz; 248 pub mod baz {
249 pub struct Foo;
250 }
246 251
247 //- /bar.rs 252 //- /bar.rs
248 pub struct Baz; 253 pub mod baz {
254 pub struct Bar;
255 }
249 "###, 256 "###,
250 ); 257 );
251 let krate = db.test_crate(); 258 assert_snapshot!(map, @r###"
259 crate
260 Bar: t v
261 bar: t
262 baz: t
263 foo: t
264
265 crate::bar
266 baz: t
267
268 crate::bar::baz
269 Bar: t v
270
271 crate::foo
272 baz: t
252 273
253 let crate_def_map = db.crate_def_map(krate); 274 crate::foo::baz
254 let (_, root_module) = crate_def_map 275 Foo: t v
255 .modules
256 .iter()
257 .find(|(_, module_data)| module_data.parent.is_none())
258 .expect("Root module not found");
259 let visible_entries = root_module.scope.entries().collect::<Vec<_>>();
260 insta::assert_debug_snapshot!(
261 visible_entries,
262 @r###"
263 [
264 (
265 Name(
266 Text(
267 "Baz",
268 ),
269 ),
270 PerNs {
271 types: Some(
272 (
273 AdtId(
274 StructId(
275 StructId(
276 1,
277 ),
278 ),
279 ),
280 Module(
281 ModuleId {
282 krate: CrateId(
283 0,
284 ),
285 local_id: Idx::<ModuleData>(0),
286 },
287 ),
288 ),
289 ),
290 values: Some(
291 (
292 AdtId(
293 StructId(
294 StructId(
295 1,
296 ),
297 ),
298 ),
299 Module(
300 ModuleId {
301 krate: CrateId(
302 0,
303 ),
304 local_id: Idx::<ModuleData>(0),
305 },
306 ),
307 ),
308 ),
309 macros: None,
310 },
311 ),
312 (
313 Name(
314 Text(
315 "bar",
316 ),
317 ),
318 PerNs {
319 types: Some(
320 (
321 ModuleId(
322 ModuleId {
323 krate: CrateId(
324 0,
325 ),
326 local_id: Idx::<ModuleData>(2),
327 },
328 ),
329 Module(
330 ModuleId {
331 krate: CrateId(
332 0,
333 ),
334 local_id: Idx::<ModuleData>(0),
335 },
336 ),
337 ),
338 ),
339 values: None,
340 macros: None,
341 },
342 ),
343 (
344 Name(
345 Text(
346 "foo",
347 ),
348 ),
349 PerNs {
350 types: Some(
351 (
352 ModuleId(
353 ModuleId {
354 krate: CrateId(
355 0,
356 ),
357 local_id: Idx::<ModuleData>(1),
358 },
359 ),
360 Module(
361 ModuleId {
362 krate: CrateId(
363 0,
364 ),
365 local_id: Idx::<ModuleData>(0),
366 },
367 ),
368 ),
369 ),
370 values: None,
371 macros: None,
372 },
373 ),
374 ]
375 "### 276 "###
376 ); 277 );
377} 278}