mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
internal: refactor find_map diagnostic
This commit is contained in:
parent
24262f9ff6
commit
de1fc70ccd
6 changed files with 192 additions and 193 deletions
|
@ -41,6 +41,7 @@ diagnostics![
|
|||
MissingUnsafe,
|
||||
NoSuchField,
|
||||
RemoveThisSemicolon,
|
||||
ReplaceFilterMapNextWithFindMap,
|
||||
UnimplementedBuiltinMacro,
|
||||
UnresolvedExternCrate,
|
||||
UnresolvedImport,
|
||||
|
@ -121,9 +122,6 @@ pub struct MissingFields {
|
|||
pub missed_fields: Vec<Name>,
|
||||
}
|
||||
|
||||
// Diagnostic: replace-filter-map-next-with-find-map
|
||||
//
|
||||
// This diagnostic is triggered when `.filter_map(..).next()` is used, rather than the more concise `.find_map(..)`.
|
||||
#[derive(Debug)]
|
||||
pub struct ReplaceFilterMapNextWithFindMap {
|
||||
pub file: HirFileId,
|
||||
|
@ -131,21 +129,6 @@ pub struct ReplaceFilterMapNextWithFindMap {
|
|||
pub next_expr: AstPtr<ast::Expr>,
|
||||
}
|
||||
|
||||
impl Diagnostic for ReplaceFilterMapNextWithFindMap {
|
||||
fn code(&self) -> DiagnosticCode {
|
||||
DiagnosticCode("replace-filter-map-next-with-find-map")
|
||||
}
|
||||
fn message(&self) -> String {
|
||||
"replace filter_map(..).next() with find_map(..)".to_string()
|
||||
}
|
||||
fn display_source(&self) -> InFile<SyntaxNodePtr> {
|
||||
InFile { file_id: self.file, value: self.next_expr.clone().into() }
|
||||
}
|
||||
fn as_any(&self) -> &(dyn Any + Send + 'static) {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MismatchedArgCount {
|
||||
pub call_expr: InFile<AstPtr<ast::Expr>>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue