-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add unresolved-ident diagnostic
- Loading branch information
1 parent
d818b53
commit a492d9d
Showing
12 changed files
with
113 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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; | ||
|
||
#[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; | ||
} | ||
"#, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.