From c2622c922887368788674d1735a7705fc345a5b9 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 10 Mar 2021 16:33:18 +0100 Subject: Prefer names from outer DefMap over extern prelude --- crates/hir_ty/src/diagnostics.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'crates/hir_ty/src/diagnostics.rs') diff --git a/crates/hir_ty/src/diagnostics.rs b/crates/hir_ty/src/diagnostics.rs index 6bca7aa0d..86f937e1d 100644 --- a/crates/hir_ty/src/diagnostics.rs +++ b/crates/hir_ty/src/diagnostics.rs @@ -705,6 +705,35 @@ fn x(a: S) { ) } + #[test] + fn import_extern_crate_clash_with_inner_item() { + // This is more of a resolver test, but doesn't really work with the hir_def testsuite. + + check_diagnostics( + r#" +//- /lib.rs crate:lib deps:jwt +mod permissions; + +use permissions::jwt; + +fn f() { + fn inner() {} + jwt::Claims {}; // should resolve to the local one with 0 fields, and not get a diagnostic +} + +//- /permissions.rs +pub mod jwt { + pub struct Claims {} +} + +//- /jwt/lib.rs crate:jwt +pub struct Claims { + field: u8, +} + "#, + ); + } + #[test] fn break_outside_of_loop() { check_diagnostics( -- cgit v1.2.3