clean up
This commit is contained in:
parent
145ebb1cd7
commit
503c03c558
@ -86,10 +86,11 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, method_name: Symbol,
|
||||
{
|
||||
return;
|
||||
},
|
||||
ExprKind::Call(hir_callee, _) => match hir_callee.kind {
|
||||
ExprKind::Path(QPath::LangItem(rustc_hir::LangItem::TryTraitBranch, _, _)) => true,
|
||||
_ => false,
|
||||
},
|
||||
// ? is a Call, makes sure not to rec *x?, but rather (*x)?
|
||||
ExprKind::Call(hir_callee, _) => matches!(
|
||||
hir_callee.kind,
|
||||
ExprKind::Path(QPath::LangItem(rustc_hir::LangItem::TryTraitBranch, _, _))
|
||||
),
|
||||
ExprKind::MethodCall(_, [self_arg, ..], _) if expr.hir_id == self_arg.hir_id => true,
|
||||
ExprKind::Match(_, _, MatchSource::TryDesugar | MatchSource::AwaitDesugar)
|
||||
| ExprKind::Field(..)
|
||||
|
@ -72,7 +72,8 @@ fn clone_on_copy() -> Option<(i32)> {
|
||||
let mut vec = Vec::new();
|
||||
vec.push(42);
|
||||
|
||||
// Issue #9277
|
||||
let opt: &Option<i32> = &None;
|
||||
let value = (*opt)?;
|
||||
let value = (*opt)?; // operator precedence needed (*opt)?
|
||||
None
|
||||
}
|
||||
|
@ -72,7 +72,8 @@ fn clone_on_copy() -> Option<(i32)> {
|
||||
let mut vec = Vec::new();
|
||||
vec.push(42.clone());
|
||||
|
||||
// Issue #9277
|
||||
let opt: &Option<i32> = &None;
|
||||
let value = opt.clone()?;
|
||||
let value = opt.clone()?; // operator precedence needed (*opt)?
|
||||
None
|
||||
}
|
||||
|
@ -49,9 +49,9 @@ LL | vec.push(42.clone());
|
||||
| ^^^^^^^^^^ help: try removing the `clone` call: `42`
|
||||
|
||||
error: using `clone` on type `std::option::Option<i32>` which implements the `Copy` trait
|
||||
--> $DIR/clone_on_copy.rs:76:17
|
||||
--> $DIR/clone_on_copy.rs:77:17
|
||||
|
|
||||
LL | let value = opt.clone()?;
|
||||
LL | let value = opt.clone()?; // operator precedence needed (*opt)?
|
||||
| ^^^^^^^^^^^ help: try dereferencing it: `(*opt)`
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
Loading…
x
Reference in New Issue
Block a user