Add regression test for issue 13077
This commit is contained in:
parent
c4125286ce
commit
4264548283
@ -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: () }
|
||||
}
|
||||
|
@ -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: () }
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user