mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-04 01:08:47 +00:00
59 lines
1 KiB
Rust
59 lines
1 KiB
Rust
use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
|
|
|
|
// Diagnostic: unresolved-ident
|
|
//
|
|
// This diagnostic is triggered if an expr-position ident is invalid.
|
|
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.map(Into::into),
|
|
)
|
|
.experimental()
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use crate::tests::check_diagnostics;
|
|
|
|
// FIXME: This should show a diagnostic
|
|
#[test]
|
|
fn feature() {
|
|
check_diagnostics(
|
|
r#"
|
|
//- minicore: fmt
|
|
fn main() {
|
|
format_args!("{unresolved}");
|
|
}
|
|
"#,
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn missing() {
|
|
check_diagnostics(
|
|
r#"
|
|
fn main() {
|
|
let _ = x;
|
|
//^ error: no such value in this scope
|
|
}
|
|
"#,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn present() {
|
|
check_diagnostics(
|
|
r#"
|
|
fn main() {
|
|
let x = 5;
|
|
let _ = x;
|
|
}
|
|
"#,
|
|
);
|
|
}
|
|
}
|