Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-diagnostics/src/handlers/macro_error.rs')
| -rw-r--r-- | crates/ide-diagnostics/src/handlers/macro_error.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/crates/ide-diagnostics/src/handlers/macro_error.rs b/crates/ide-diagnostics/src/handlers/macro_error.rs index 6a1ecae651..a44b043f43 100644 --- a/crates/ide-diagnostics/src/handlers/macro_error.rs +++ b/crates/ide-diagnostics/src/handlers/macro_error.rs @@ -13,7 +13,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, Severity}; // This diagnostic is shown for proc macros that have been specifically disabled via `rust-analyzer.procMacro.ignored`. pub(crate) fn macro_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroError) -> Diagnostic { // Use more accurate position if available. - let display_range = ctx.resolve_precise_location(&d.node, d.precise_location); + let display_range = ctx.sema.diagnostics_display_range_for_range(d.range); Diagnostic::new( DiagnosticCode::Ra(d.kind, if d.error { Severity::Error } else { Severity::WeakWarning }), d.message.clone(), @@ -27,8 +27,10 @@ pub(crate) fn macro_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroError) -> // This diagnostic is shown for macro expansion errors. pub(crate) fn macro_def_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroDefError) -> Diagnostic { // Use more accurate position if available. - let display_range = - ctx.resolve_precise_location(&d.node.map(|it| it.syntax_node_ptr()), d.name); + let display_range = match d.name { + Some(name) => ctx.sema.diagnostics_display_range_for_range(d.node.with_value(name)), + None => ctx.sema.diagnostics_display_range(d.node.map(|it| it.syntax_node_ptr())), + }; Diagnostic::new( DiagnosticCode::Ra("macro-def-error", Severity::Error), d.message.clone(), @@ -135,10 +137,12 @@ macro_rules! env { () => {} } #[rustc_builtin_macro] macro_rules! concat { () => {} } - include!(concat!(env!("OUT_DIR"), "/out.rs")); - //^^^^^^^^^ error: `OUT_DIR` not set, build scripts may have failed to run - //^^^^^^^^^^^^^^^ error: `OUT_DIR` not set, build scripts may have failed to run - //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `OUT_DIR` not set, build scripts may have failed to run + include!(concat!( + // ^^^^^^ error: `OUT_DIR` not set, build scripts may have failed to run + env!( + //^^^ error: `OUT_DIR` not set, build scripts may have failed to run + "OUT_DIR"), "/out.rs")); + //^^^^^^^^^ error: `OUT_DIR` not set, build scripts may have failed to run "#, ); } @@ -182,7 +186,7 @@ fn main() { //^^^^^^^^^^^^^^^^ error: failed to load file `does not exist` include!(concat!("does ", "not ", "exist")); - //^^^^^^^^^^^^^^^^^^^^^^^^^^ error: failed to load file `does not exist` + // ^^^^^^^^^^^^^^^^^^^^^^^^ error: failed to load file `does not exist` env!(invalid); //^^^^^^^ error: expected string literal @@ -289,7 +293,7 @@ include!("include-me.rs"); //- /include-me.rs /// long doc that pushes the diagnostic range beyond the first file's text length #[err] -//^^^^^^error: unresolved macro `err` + // ^^^ error: unresolved macro `err` mod prim_never {} "#, ); |