aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/diagnostics/unresolved_extern_crate.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/diagnostics/unresolved_extern_crate.rs')
-rw-r--r--crates/ide/src/diagnostics/unresolved_extern_crate.rs49
1 files changed, 0 insertions, 49 deletions
diff --git a/crates/ide/src/diagnostics/unresolved_extern_crate.rs b/crates/ide/src/diagnostics/unresolved_extern_crate.rs
deleted file mode 100644
index 2ea79c2ee..000000000
--- a/crates/ide/src/diagnostics/unresolved_extern_crate.rs
+++ /dev/null
@@ -1,49 +0,0 @@
1use crate::diagnostics::{Diagnostic, DiagnosticsContext};
2
3// Diagnostic: unresolved-extern-crate
4//
5// This diagnostic is triggered if rust-analyzer is unable to discover referred extern crate.
6pub(super) fn unresolved_extern_crate(
7 ctx: &DiagnosticsContext<'_>,
8 d: &hir::UnresolvedExternCrate,
9) -> Diagnostic {
10 Diagnostic::new(
11 "unresolved-extern-crate",
12 "unresolved extern crate",
13 ctx.sema.diagnostics_display_range(d.decl.clone().map(|it| it.into())).range,
14 )
15}
16
17#[cfg(test)]
18mod tests {
19 use crate::diagnostics::tests::check_diagnostics;
20
21 #[test]
22 fn unresolved_extern_crate() {
23 check_diagnostics(
24 r#"
25//- /main.rs crate:main deps:core
26extern crate core;
27 extern crate doesnotexist;
28//^^^^^^^^^^^^^^^^^^^^^^^^^^ unresolved extern crate
29//- /lib.rs crate:core
30"#,
31 );
32 }
33
34 #[test]
35 fn extern_crate_self_as() {
36 cov_mark::check!(extern_crate_self_as);
37 check_diagnostics(
38 r#"
39//- /lib.rs
40 extern crate doesnotexist;
41//^^^^^^^^^^^^^^^^^^^^^^^^^^ unresolved extern crate
42// Should not error.
43extern crate self as foo;
44struct Foo;
45use foo::Foo as Bar;
46"#,
47 );
48 }
49}