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, 9 insertions, 13 deletions
diff --git a/crates/ide-diagnostics/src/handlers/macro_error.rs b/crates/ide-diagnostics/src/handlers/macro_error.rs index a44b043f43..6a1ecae651 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.sema.diagnostics_display_range_for_range(d.range); + let display_range = ctx.resolve_precise_location(&d.node, d.precise_location); Diagnostic::new( DiagnosticCode::Ra(d.kind, if d.error { Severity::Error } else { Severity::WeakWarning }), d.message.clone(), @@ -27,10 +27,8 @@ 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 = 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())), - }; + let display_range = + ctx.resolve_precise_location(&d.node.map(|it| it.syntax_node_ptr()), d.name); Diagnostic::new( DiagnosticCode::Ra("macro-def-error", Severity::Error), d.message.clone(), @@ -137,12 +135,10 @@ macro_rules! env { () => {} } #[rustc_builtin_macro] macro_rules! concat { () => {} } - 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 + 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 "#, ); } @@ -186,7 +182,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 @@ -293,7 +289,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 {} "#, ); |