1 use crate::{Diagnostic, DiagnosticsContext}
;
3 // Diagnostic: unresolved-import
5 // This diagnostic is triggered if rust-analyzer is unable to resolve a path in
6 // a `use` declaration.
7 pub(crate) fn unresolved_import(
8 ctx
: &DiagnosticsContext
<'_
>,
9 d
: &hir
::UnresolvedImport
,
14 ctx
.sema
.diagnostics_display_range(d
.decl
.clone().map(|it
| it
.into())).range
,
16 // This currently results in false positives in the following cases:
17 // - `cfg_if!`-generated code in libstd (we don't load the sysroot correctly)
18 // - `core::arch` (we don't handle `#[path = "../<path>"]` correctly)
19 // - proc macros and/or proc macro generated code
25 use crate::tests
::check_diagnostics
;
28 fn unresolved_import() {
33 //^^^^^^^^^^^^^^ error: unresolved import
41 fn unresolved_import_in_use_tree() {
42 // Only the relevant part of a nested `use` item should be highlighted.
45 use does_exist::{Exists, DoesntExist};
46 //^^^^^^^^^^^ error: unresolved import
48 use {does_not_exist::*, does_exist};
49 //^^^^^^^^^^^^^^^^^ error: unresolved import
53 //^ error: unresolved import
55 //^ error: unresolved import
57 //^ error: unresolved import
68 fn dedup_unresolved_import_from_unresolved_crate() {
71 //- /main.rs crate:main
73 extern crate doesnotexist;
74 //^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unresolved extern crate
76 // Should not error, since we already errored for the missing crate.
77 use doesnotexist::{self, bla, *};
79 use crate::doesnotexist;
80 //^^^^^^^^^^^^^^^^^^^ error: unresolved import
84 use super::doesnotexist;
85 //^^^^^^^^^^^^^^^^^^^ error: unresolved import