From 8baa05666c455b4dd6333fd5ac1a694136039f43 Mon Sep 17 00:00:00 2001 From: Matthias Einwag Date: Sat, 9 Nov 2019 17:38:08 -0800 Subject: Add tests for resolving types in core and std preludes --- crates/ra_hir_def/src/nameres/tests.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index 52bd0aa91..256f7d4be 100644 --- a/crates/ra_hir_def/src/nameres/tests.rs +++ b/crates/ra_hir_def/src/nameres/tests.rs @@ -463,6 +463,37 @@ fn values_dont_shadow_extern_crates() { "###); } +#[test] +fn std_prelude_takes_precedence_above_core_prelude() { + let map = def_map( + r#" + //- /main.rs crate:main deps:core,std + use {Foo, Bar}; + + //- /std.rs crate:std deps:core + #[prelude_import] + pub use self::prelude::*; + mod prelude { + pub struct Foo; + pub use core::prelude::Bar; + } + + //- /core.rs crate:core + #[prelude_import] + pub use self::prelude::*; + mod prelude { + pub struct Bar; + } + "#, + ); + + assert_snapshot!(map, @r###" + ⋮crate + ⋮Bar: t v + ⋮Foo: t v + "###); +} + #[test] fn cfg_not_test() { let map = def_map( -- cgit v1.2.3