question_mark: don't add as_ref() for a call expression

This commit is contained in:
Shotaro Yamada 2020-04-17 13:09:02 +09:00
parent eb9c15a6b3
commit f58bb5b234
4 changed files with 40 additions and 4 deletions

View file

@ -70,10 +70,12 @@ impl QuestionMark {
replacement = Some(format!("Some({}?)", receiver_str));
}
}
} else if Self::moves_by_default(cx, subject) {
replacement = Some(format!("{}.as_ref()?;", receiver_str));
} else if Self::moves_by_default(cx, subject)
&& !matches!(subject.kind, ExprKind::Call(..) | ExprKind::MethodCall(..))
{
replacement = Some(format!("{}.as_ref()?;", receiver_str));
} else {
replacement = Some(format!("{}?;", receiver_str));
replacement = Some(format!("{}?;", receiver_str));
}
if let Some(replacement_str) = replacement {