diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres/tests/globs.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/globs.rs | 137 |
1 files changed, 137 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..7f3d7509c 100644 --- a/crates/ra_hir_def/src/nameres/tests/globs.rs +++ b/crates/ra_hir_def/src/nameres/tests/globs.rs | |||
@@ -229,3 +229,140 @@ fn glob_enum_group() { | |||
229 | "### | 229 | "### |
230 | ); | 230 | ); |
231 | } | 231 | } |
232 | |||
233 | #[test] | ||
234 | fn glob_shadowed_def() { | ||
235 | mark::check!(import_shadowed); | ||
236 | let map = def_map( | ||
237 | r###" | ||
238 | //- /lib.rs | ||
239 | mod foo; | ||
240 | mod bar; | ||
241 | |||
242 | use foo::*; | ||
243 | use bar::baz; | ||
244 | |||
245 | use baz::Bar; | ||
246 | |||
247 | //- /foo.rs | ||
248 | pub mod baz { | ||
249 | pub struct Foo; | ||
250 | } | ||
251 | |||
252 | //- /bar.rs | ||
253 | pub mod baz { | ||
254 | pub struct Bar; | ||
255 | } | ||
256 | "###, | ||
257 | ); | ||
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 | ||
273 | ⋮ | ||
274 | ⋮crate::foo::baz | ||
275 | ⋮Foo: t v | ||
276 | "### | ||
277 | ); | ||
278 | } | ||
279 | |||
280 | #[test] | ||
281 | fn glob_shadowed_def_reversed() { | ||
282 | let map = def_map( | ||
283 | r###" | ||
284 | //- /lib.rs | ||
285 | mod foo; | ||
286 | mod bar; | ||
287 | |||
288 | use bar::baz; | ||
289 | use foo::*; | ||
290 | |||
291 | use baz::Bar; | ||
292 | |||
293 | //- /foo.rs | ||
294 | pub mod baz { | ||
295 | pub struct Foo; | ||
296 | } | ||
297 | |||
298 | //- /bar.rs | ||
299 | pub mod baz { | ||
300 | pub struct Bar; | ||
301 | } | ||
302 | "###, | ||
303 | ); | ||
304 | assert_snapshot!(map, @r###" | ||
305 | ⋮crate | ||
306 | ⋮Bar: t v | ||
307 | ⋮bar: t | ||
308 | ⋮baz: t | ||
309 | ⋮foo: t | ||
310 | ⋮ | ||
311 | ⋮crate::bar | ||
312 | ⋮baz: t | ||
313 | ⋮ | ||
314 | ⋮crate::bar::baz | ||
315 | ⋮Bar: t v | ||
316 | ⋮ | ||
317 | ⋮crate::foo | ||
318 | ⋮baz: t | ||
319 | ⋮ | ||
320 | ⋮crate::foo::baz | ||
321 | ⋮Foo: t v | ||
322 | "### | ||
323 | ); | ||
324 | } | ||
325 | |||
326 | #[test] | ||
327 | fn glob_shadowed_def_dependencies() { | ||
328 | let map = def_map( | ||
329 | r###" | ||
330 | //- /lib.rs | ||
331 | mod a { pub mod foo { pub struct X; } } | ||
332 | mod b { pub use super::a::foo; } | ||
333 | mod c { pub mod foo { pub struct Y; } } | ||
334 | mod d { | ||
335 | use super::c::foo; | ||
336 | use super::b::*; | ||
337 | use foo::Y; | ||
338 | } | ||
339 | "###, | ||
340 | ); | ||
341 | assert_snapshot!(map, @r###" | ||
342 | ⋮crate | ||
343 | ⋮a: t | ||
344 | ⋮b: t | ||
345 | ⋮c: t | ||
346 | ⋮d: t | ||
347 | ⋮ | ||
348 | ⋮crate::d | ||
349 | ⋮Y: t v | ||
350 | ⋮foo: t | ||
351 | ⋮ | ||
352 | ⋮crate::c | ||
353 | ⋮foo: t | ||
354 | ⋮ | ||
355 | ⋮crate::c::foo | ||
356 | ⋮Y: t v | ||
357 | ⋮ | ||
358 | ⋮crate::b | ||
359 | ⋮foo: t | ||
360 | ⋮ | ||
361 | ⋮crate::a | ||
362 | ⋮foo: t | ||
363 | ⋮ | ||
364 | ⋮crate::a::foo | ||
365 | ⋮X: t v | ||
366 | "### | ||
367 | ); | ||
368 | } | ||