about summary refs log tree commit diff
path: root/compiler/rustc_resolve
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-11-17 23:04:23 +0100
committerGitHub <noreply@github.com>2023-11-17 23:04:23 +0100
commit8792e81f29f105efff5ae926b5ae21e5ff7d3d56 (patch)
treee6f85d85837f90e6edbd4b228d5e7bb9baabfd24 /compiler/rustc_resolve
parent6227455345359fd16e959f45538e652a983da149 (diff)
parent890ce26213c1cdc12ae269a91a62e3502a3165cc (diff)
downloadrust-8792e81f29f105efff5ae926b5ae21e5ff7d3d56.tar.gz
rust-8792e81f29f105efff5ae926b5ae21e5ff7d3d56.zip
Rollup merge of #117964 - estebank:issue-81232, r=petrochenkov
When using existing fn as module, don't claim it doesn't exist

Tweak wording of module not found in resolve, when the name exists but belongs to a non-`mod` item.

Fix #81232.
Diffstat (limited to 'compiler/rustc_resolve')
-rw-r--r--compiler/rustc_resolve/src/diagnostics.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs
index 93db6cfc463..28e6fe9b4b7 100644
--- a/compiler/rustc_resolve/src/diagnostics.rs
+++ b/compiler/rustc_resolve/src/diagnostics.rs
@@ -2028,7 +2028,19 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                     },
                 )
             });
-            (format!("use of undeclared crate or module `{ident}`"), suggestion)
+            if let Ok(binding) = self.early_resolve_ident_in_lexical_scope(
+                ident,
+                ScopeSet::All(ValueNS),
+                parent_scope,
+                None,
+                false,
+                ignore_binding,
+            ) {
+                let descr = binding.res().descr();
+                (format!("{descr} `{ident}` is not a crate or module"), suggestion)
+            } else {
+                (format!("use of undeclared crate or module `{ident}`"), suggestion)
+            }
         }
     }