Add regression test for issue 13077

This commit is contained in:
Lzu Tao 2024-07-15 21:16:17 +07:00
parent c4125286ce
commit 4264548283
3 changed files with 35 additions and 1 deletions

View File

@ -52,3 +52,17 @@ 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) };
}
}
fn other(_maybe_side_effect: Option<&mut String>) {
unimplemented!()
}
pub struct S { pub field: () }
}

View File

@ -52,3 +52,17 @@ 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: () }
}

View File

@ -19,5 +19,11 @@ error: derefed type is same as origin
LL | let _ = x.as_deref_mut();
| ^^^^^^^^^^^^^^^^ help: try: `x`
error: aborting due to 3 previous errors
error: derefed type is same as origin
--> 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