aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-13 17:35:30 +0100
committerAleksey Kladov <[email protected]>2021-06-13 17:35:30 +0100
commitd3621eeb02652038a8185f60d78fb4791a732dc6 (patch)
tree0e200e563949977ffd0a857555d4ff874ab758dd /crates/ide
parentdec207f56a7b16075f68dcb89138d93a7eecdf43 (diff)
internal: refactor unimplemented builtin macro diagnostic
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/diagnostics.rs7
-rw-r--r--crates/ide/src/diagnostics/unimplemented_builtin_macro.rs19
2 files changed, 21 insertions, 5 deletions
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs
index aeccf1164..3fbd21c30 100644
--- a/crates/ide/src/diagnostics.rs
+++ b/crates/ide/src/diagnostics.rs
@@ -9,6 +9,7 @@ mod unresolved_extern_crate;
9mod unresolved_import; 9mod unresolved_import;
10mod unresolved_macro_call; 10mod unresolved_macro_call;
11mod unresolved_proc_macro; 11mod unresolved_proc_macro;
12mod unimplemented_builtin_macro;
12mod macro_error; 13mod macro_error;
13mod inactive_code; 14mod inactive_code;
14mod missing_fields; 15mod missing_fields;
@@ -185,11 +186,6 @@ pub(crate) fn diagnostics(
185 .with_code(Some(d.code())), 186 .with_code(Some(d.code())),
186 ); 187 );
187 }) 188 })
188 .on::<hir::diagnostics::UnimplementedBuiltinMacro, _>(|d| {
189 let display_range = sema.diagnostics_display_range(d.display_source()).range;
190 res.borrow_mut()
191 .push(Diagnostic::hint(display_range, d.message()).with_code(Some(d.code())));
192 })
193 // Only collect experimental diagnostics when they're enabled. 189 // Only collect experimental diagnostics when they're enabled.
194 .filter(|diag| !(diag.is_experimental() && config.disable_experimental)) 190 .filter(|diag| !(diag.is_experimental() && config.disable_experimental))
195 .filter(|diag| !config.disabled.contains(diag.code().as_str())); 191 .filter(|diag| !config.disabled.contains(diag.code().as_str()));
@@ -229,6 +225,7 @@ pub(crate) fn diagnostics(
229 AnyDiagnostic::UnresolvedImport(d) => unresolved_import::unresolved_import(&ctx, &d), 225 AnyDiagnostic::UnresolvedImport(d) => unresolved_import::unresolved_import(&ctx, &d),
230 AnyDiagnostic::UnresolvedMacroCall(d) => unresolved_macro_call::unresolved_macro_call(&ctx, &d), 226 AnyDiagnostic::UnresolvedMacroCall(d) => unresolved_macro_call::unresolved_macro_call(&ctx, &d),
231 AnyDiagnostic::UnresolvedProcMacro(d) => unresolved_proc_macro::unresolved_proc_macro(&ctx, &d), 227 AnyDiagnostic::UnresolvedProcMacro(d) => unresolved_proc_macro::unresolved_proc_macro(&ctx, &d),
228 AnyDiagnostic::UnimplementedBuiltinMacro(d) => unimplemented_builtin_macro::unimplemented_builtin_macro(&ctx, &d),
232 AnyDiagnostic::MissingFields(d) => missing_fields::missing_fields(&ctx, &d), 229 AnyDiagnostic::MissingFields(d) => missing_fields::missing_fields(&ctx, &d),
233 AnyDiagnostic::MacroError(d) => macro_error::macro_error(&ctx, &d), 230 AnyDiagnostic::MacroError(d) => macro_error::macro_error(&ctx, &d),
234 231
diff --git a/crates/ide/src/diagnostics/unimplemented_builtin_macro.rs b/crates/ide/src/diagnostics/unimplemented_builtin_macro.rs
new file mode 100644
index 000000000..09faa3bbc
--- /dev/null
+++ b/crates/ide/src/diagnostics/unimplemented_builtin_macro.rs
@@ -0,0 +1,19 @@
1use crate::{
2 diagnostics::{Diagnostic, DiagnosticsContext},
3 Severity,
4};
5
6// Diagnostic: unimplemented-builtin-macro
7//
8// This diagnostic is shown for builtin macros which are not yet implemented by rust-analyzer
9pub(super) fn unimplemented_builtin_macro(
10 ctx: &DiagnosticsContext<'_>,
11 d: &hir::UnimplementedBuiltinMacro,
12) -> Diagnostic {
13 Diagnostic::new(
14 "unimplemented-builtin-macro",
15 "unimplemented built-in macro".to_string(),
16 ctx.sema.diagnostics_display_range(d.node.clone()).range,
17 )
18 .severity(Severity::WeakWarning)
19}