Auto merge of #13006 - flip1995:manual-inspect-error-message, r=Jarcho
Add error message to manual_inspect lint r? `@Jarcho` changelog: none
This commit is contained in:
commit
1aa236d59b
2 changed files with 27 additions and 23 deletions
|
|
@ -167,14 +167,12 @@ pub(crate) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, arg: &Expr<'_>, name:
|
|||
} else {
|
||||
edits.extend(addr_of_edits);
|
||||
}
|
||||
edits.push((
|
||||
name_span,
|
||||
String::from(match name {
|
||||
"map" => "inspect",
|
||||
"map_err" => "inspect_err",
|
||||
_ => return,
|
||||
}),
|
||||
));
|
||||
let edit = match name {
|
||||
"map" => "inspect",
|
||||
"map_err" => "inspect_err",
|
||||
_ => return,
|
||||
};
|
||||
edits.push((name_span, edit.to_string()));
|
||||
edits.push((
|
||||
final_expr
|
||||
.span
|
||||
|
|
@ -187,9 +185,15 @@ pub(crate) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, arg: &Expr<'_>, name:
|
|||
} else {
|
||||
Applicability::MachineApplicable
|
||||
};
|
||||
span_lint_and_then(cx, MANUAL_INSPECT, name_span, "", |diag| {
|
||||
diag.multipart_suggestion("try", edits, app);
|
||||
});
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
MANUAL_INSPECT,
|
||||
name_span,
|
||||
format!("using `{name}` over `{edit}`"),
|
||||
|diag| {
|
||||
diag.multipart_suggestion("try", edits, app);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue