Fix suggestion for unnecessary_ref lint
This commit is contained in:
parent
3f978afe8d
commit
298aedf2f8
4 changed files with 8 additions and 11 deletions
|
@ -98,7 +98,7 @@ impl LintPass for DerefPass {
|
|||
impl EarlyLintPass for DerefPass {
|
||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) {
|
||||
if_chain! {
|
||||
if let ExprKind::Field(ref object, ref field_name) = e.node;
|
||||
if let ExprKind::Field(ref object, _) = e.node;
|
||||
if let ExprKind::Paren(ref parened) = object.node;
|
||||
if let ExprKind::AddrOf(_, ref inner) = parened.node;
|
||||
then {
|
||||
|
@ -109,11 +109,7 @@ impl EarlyLintPass for DerefPass {
|
|||
object.span,
|
||||
"Creating a reference that is immediately dereferenced.",
|
||||
"try this",
|
||||
format!(
|
||||
"{}.{}",
|
||||
snippet_with_applicability(cx, inner.span, "_", &mut applicability),
|
||||
snippet_with_applicability(cx, field_name.span, "_", &mut applicability)
|
||||
),
|
||||
snippet_with_applicability(cx, inner.span, "_", &mut applicability).to_string(),
|
||||
applicability,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue