aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-06-24 03:10:01 +0100
committerPaul Daniel Faria <[email protected]>2020-06-24 03:10:01 +0100
commit38af81f183504145bd3bf6ba5bc40b3e41e04593 (patch)
tree61850b0c2a839af097c528d2b91baec3acd9cb8e /crates/ra_hir_def/src/nameres
parent471d44e72c54882cff2e00c662ee74d8c7c94234 (diff)
Account for updated module ids when determining whether a resolution is "changed"
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r--crates/ra_hir_def/src/nameres/tests/globs.rs146
1 files changed, 146 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/nameres/tests/globs.rs b/crates/ra_hir_def/src/nameres/tests/globs.rs
index 2b12c0daa..f0d85d301 100644
--- a/crates/ra_hir_def/src/nameres/tests/globs.rs
+++ b/crates/ra_hir_def/src/nameres/tests/globs.rs
@@ -229,3 +229,149 @@ fn glob_enum_group() {
229 "### 229 "###
230 ); 230 );
231} 231}
232
233#[test]
234fn glob_shadowed_def() {
235 let db = TestDB::with_files(
236 r###"
237 //- /lib.rs
238 mod foo;
239 mod bar;
240
241 use foo::*;
242 use bar::Baz;
243
244 //- /foo.rs
245 pub struct Baz;
246
247 //- /bar.rs
248 pub struct Baz;
249 "###,
250 );
251 let krate = db.test_crate();
252
253 let crate_def_map = db.crate_def_map(krate);
254 let (_, root_module) = crate_def_map
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 "###
376 );
377}