5270: Add argument count mismatch diagnostic r=matklad a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/4025.

This currently has one false positive on this line, where `max` is resolved to `Iterator::max` instead of `Ord::max`:

8aa10c00a4/crates/expect/src/lib.rs (L263)

(I have no idea why it thinks that `usize` is an `Iterator`)

TODO:
* [x] Tests
* [x] Improve diagnostic text for method calls

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
This commit is contained in:
bors[bot] 2020-07-09 15:34:43 +00:00 committed by GitHub
commit 89c7c55995
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 230 additions and 14 deletions

View file

@ -99,14 +99,6 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
fix,
})
})
.on::<hir::diagnostics::MissingMatchArms, _>(|d| {
res.borrow_mut().push(Diagnostic {
range: sema.diagnostics_range(d).range,
message: d.message(),
severity: Severity::Error,
fix: None,
})
})
.on::<hir::diagnostics::MissingOkInTailExpr, _>(|d| {
let node = d.ast(db);
let replacement = format!("Ok({})", node.syntax());