mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Map our diagnostics to rustc and clippy's ones
This commit is contained in:
parent
9c967d3809
commit
e55a1f1916
44 changed files with 628 additions and 251 deletions
|
|
@ -114,6 +114,8 @@ pub(crate) fn check_diagnostics_with_config(config: DiagnosticsConfig, ra_fixtur
|
|||
annotation.push_str(match d.severity {
|
||||
Severity::Error => "error",
|
||||
Severity::WeakWarning => "weak",
|
||||
Severity::Warning => "warn",
|
||||
Severity::Allow => "allow",
|
||||
});
|
||||
annotation.push_str(": ");
|
||||
annotation.push_str(&d.message);
|
||||
|
|
@ -130,14 +132,19 @@ pub(crate) fn check_diagnostics_with_config(config: DiagnosticsConfig, ra_fixtur
|
|||
)
|
||||
}
|
||||
}
|
||||
assert_eq!(expected, actual);
|
||||
if expected != actual {
|
||||
let fneg = expected.iter().filter(|x| !actual.contains(x)).collect::<Vec<_>>();
|
||||
let fpos = actual.iter().filter(|x| !expected.contains(x)).collect::<Vec<_>>();
|
||||
|
||||
panic!("Diagnostic test failed.\nFalse negatives: {fneg:?}\nFalse positives: {fpos:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_disabled_diagnostics() {
|
||||
let mut config = DiagnosticsConfig::test_sample();
|
||||
config.disabled.insert("unresolved-module".into());
|
||||
config.disabled.insert("E0583".into());
|
||||
|
||||
let (db, file_id) = RootDatabase::with_single_file(r#"mod foo;"#);
|
||||
|
||||
|
|
@ -159,7 +166,7 @@ fn minicore_smoke_test() {
|
|||
let source = minicore.source_code();
|
||||
let mut config = DiagnosticsConfig::test_sample();
|
||||
// This should be ignored since we conditionaly remove code which creates single item use with braces
|
||||
config.disabled.insert("unnecessary-braces".to_string());
|
||||
config.disabled.insert("unused_braces".to_string());
|
||||
check_diagnostics_with_config(config, &source);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue