mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 05:03:21 +00:00
Auto merge of #13102 - tesuji:fix-needless_option_as_deref, r=Alexendoo
Fix `needless_option_as_deref` false-positive on struct literals changelog: [`needless_option_as_deref`] Fix false-positive on struct literals. Fixes #13077 . r? Alexendoo
This commit is contained in:
commit
eb4d88e690
3 changed files with 37 additions and 1 deletions
|
@ -1408,7 +1408,7 @@ pub fn get_enclosing_loop_or_multi_call_closure<'tcx>(
|
|||
ExprKind::Closure { .. } | ExprKind::Loop(..) => return Some(e),
|
||||
_ => (),
|
||||
},
|
||||
Node::Stmt(_) | Node::Block(_) | Node::LetStmt(_) | Node::Arm(_) => (),
|
||||
Node::Stmt(_) | Node::Block(_) | Node::LetStmt(_) | Node::Arm(_) | Node::ExprField(_) => (),
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,3 +52,21 @@ struct S<'a> {
|
|||
fn from_field<'a>(s: &'a mut S<'a>) -> Option<&'a mut usize> {
|
||||
s.opt.as_deref_mut()
|
||||
}
|
||||
|
||||
mod issue_non_copy_13077 {
|
||||
pub fn something(mut maybe_side_effect: Option<&mut String>) {
|
||||
for _ in 0..10 {
|
||||
let _ = S {
|
||||
field: other(maybe_side_effect.as_deref_mut()),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn other(_maybe_side_effect: Option<&mut String>) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub struct S {
|
||||
pub field: (),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,3 +52,21 @@ struct S<'a> {
|
|||
fn from_field<'a>(s: &'a mut S<'a>) -> Option<&'a mut usize> {
|
||||
s.opt.as_deref_mut()
|
||||
}
|
||||
|
||||
mod issue_non_copy_13077 {
|
||||
pub fn something(mut maybe_side_effect: Option<&mut String>) {
|
||||
for _ in 0..10 {
|
||||
let _ = S {
|
||||
field: other(maybe_side_effect.as_deref_mut()),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn other(_maybe_side_effect: Option<&mut String>) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub struct S {
|
||||
pub field: (),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue