Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-diagnostics/src/handlers/unresolved_ident.rs')
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_ident.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_ident.rs b/crates/ide-diagnostics/src/handlers/unresolved_ident.rs
index 68f14a97f5..4f64dabeb5 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_ident.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_ident.rs
@@ -7,20 +7,19 @@ pub(crate) fn unresolved_ident(
ctx: &DiagnosticsContext<'_>,
d: &hir::UnresolvedIdent,
) -> Diagnostic {
- Diagnostic::new_with_syntax_node_ptr(
- ctx,
- DiagnosticCode::RustcHardError("E0425"),
- "no such value in this scope",
- d.expr_or_pat.map(Into::into),
- )
- .experimental()
+ let mut range =
+ ctx.sema.diagnostics_display_range(d.node.map(|(node, _)| node.syntax_node_ptr()));
+ if let Some(in_node_range) = d.node.value.1 {
+ range.range = in_node_range + range.range.start();
+ }
+ Diagnostic::new(DiagnosticCode::RustcHardError("E0425"), "no such value in this scope", range)
+ .experimental()
}
#[cfg(test)]
mod tests {
use crate::tests::check_diagnostics;
- // FIXME: This should show a diagnostic
#[test]
fn feature() {
check_diagnostics(
@@ -28,6 +27,7 @@ mod tests {
//- minicore: fmt
fn main() {
format_args!("{unresolved}");
+ // ^^^^^^^^^^ error: no such value in this scope
}
"#,
)