Skip to content

Commit 4264548

Browse files
committed
Add regression test for issue 13077
1 parent c412528 commit 4264548

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

tests/ui/needless_option_as_deref.fixed

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,17 @@ struct S<'a> {
5252
fn from_field<'a>(s: &'a mut S<'a>) -> Option<&'a mut usize> {
5353
s.opt.as_deref_mut()
5454
}
55+
56+
mod issue_non_copy_13077 {
57+
pub fn something(mut maybe_side_effect: Option<&mut String>) {
58+
for _ in 0..10 {
59+
let _ = S { field: other(maybe_side_effect) };
60+
}
61+
}
62+
63+
fn other(_maybe_side_effect: Option<&mut String>) {
64+
unimplemented!()
65+
}
66+
67+
pub struct S { pub field: () }
68+
}

tests/ui/needless_option_as_deref.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,17 @@ struct S<'a> {
5252
fn from_field<'a>(s: &'a mut S<'a>) -> Option<&'a mut usize> {
5353
s.opt.as_deref_mut()
5454
}
55+
56+
mod issue_non_copy_13077 {
57+
pub fn something(mut maybe_side_effect: Option<&mut String>) {
58+
for _ in 0..10 {
59+
let _ = S { field: other(maybe_side_effect.as_deref_mut()) };
60+
}
61+
}
62+
63+
fn other(_maybe_side_effect: Option<&mut String>) {
64+
unimplemented!()
65+
}
66+
67+
pub struct S { pub field: () }
68+
}

tests/ui/needless_option_as_deref.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@ error: derefed type is same as origin
1919
LL | let _ = x.as_deref_mut();
2020
| ^^^^^^^^^^^^^^^^ help: try: `x`
2121

22-
error: aborting due to 3 previous errors
22+
error: derefed type is same as origin
23+
--> tests/ui/needless_option_as_deref.rs:59:38
24+
|
25+
LL | let _ = S { field: other(maybe_side_effect.as_deref_mut()) };
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `maybe_side_effect`
27+
28+
error: aborting due to 4 previous errors
2329

0 commit comments

Comments
 (0)