Prevent multiple incorrect case diagnostics in functions
This commit is contained in:
parent
3d5d21b602
commit
bfae2634b4
@ -374,8 +374,6 @@ pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) {
|
||||
let crate_def_map = db.crate_def_map(self.id.krate);
|
||||
crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink);
|
||||
for decl in self.declarations(db) {
|
||||
decl.diagnostics(db, sink);
|
||||
|
||||
match decl {
|
||||
crate::ModuleDef::Function(f) => f.diagnostics(db, sink),
|
||||
crate::ModuleDef::Module(m) => {
|
||||
@ -384,7 +382,9 @@ pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) {
|
||||
m.diagnostics(db, sink)
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
_ => {
|
||||
decl.diagnostics(db, sink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -895,4 +895,17 @@ pub fn some_fn() -> TestStruct {
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_single_incorrect_case_diagnostic_in_function_name_issue_6970() {
|
||||
let input = r#"fn FOO<|>() {}"#;
|
||||
let expected = r#"fn foo() {}"#;
|
||||
|
||||
let (analysis, file_position) = fixture::position(input);
|
||||
let diagnostics =
|
||||
analysis.diagnostics(&DiagnosticsConfig::default(), file_position.file_id).unwrap();
|
||||
assert_eq!(diagnostics.len(), 1);
|
||||
|
||||
check_fixes(input, expected);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user