Dont stop find loop node at struct field node

This commit is contained in:
Lzu Tao 2024-07-15 15:56:17 +00:00
parent 4264548283
commit dcee2e8a0f
4 changed files with 14 additions and 12 deletions

View File

@ -1407,7 +1407,7 @@ pub fn get_enclosing_loop_or_multi_call_closure<'tcx>(
ExprKind::Closure { .. } | ExprKind::Loop(..) => return Some(e), 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, _ => break,
} }
} }

View File

@ -56,7 +56,9 @@ fn from_field<'a>(s: &'a mut S<'a>) -> Option<&'a mut usize> {
mod issue_non_copy_13077 { mod issue_non_copy_13077 {
pub fn something(mut maybe_side_effect: Option<&mut String>) { pub fn something(mut maybe_side_effect: Option<&mut String>) {
for _ in 0..10 { for _ in 0..10 {
let _ = S { field: other(maybe_side_effect) }; let _ = S {
field: other(maybe_side_effect.as_deref_mut()),
};
} }
} }
@ -64,5 +66,7 @@ mod issue_non_copy_13077 {
unimplemented!() unimplemented!()
} }
pub struct S { pub field: () } pub struct S {
pub field: (),
}
} }

View File

@ -56,7 +56,9 @@ fn from_field<'a>(s: &'a mut S<'a>) -> Option<&'a mut usize> {
mod issue_non_copy_13077 { mod issue_non_copy_13077 {
pub fn something(mut maybe_side_effect: Option<&mut String>) { pub fn something(mut maybe_side_effect: Option<&mut String>) {
for _ in 0..10 { for _ in 0..10 {
let _ = S { field: other(maybe_side_effect.as_deref_mut()) }; let _ = S {
field: other(maybe_side_effect.as_deref_mut()),
};
} }
} }
@ -64,5 +66,7 @@ fn other(_maybe_side_effect: Option<&mut String>) {
unimplemented!() unimplemented!()
} }
pub struct S { pub field: () } pub struct S {
pub field: (),
}
} }

View File

@ -19,11 +19,5 @@ error: derefed type is same as origin
LL | let _ = x.as_deref_mut(); LL | let _ = x.as_deref_mut();
| ^^^^^^^^^^^^^^^^ help: try: `x` | ^^^^^^^^^^^^^^^^ help: try: `x`
error: derefed type is same as origin error: aborting due to 3 previous errors
--> tests/ui/needless_option_as_deref.rs:59:38
|
LL | let _ = S { field: other(maybe_side_effect.as_deref_mut()) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `maybe_side_effect`
error: aborting due to 4 previous errors