This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -52,3 +52,17 @@ struct S<'a> {
5252fn 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+ }
Original file line number Diff line number Diff line change @@ -52,3 +52,17 @@ struct S<'a> {
5252fn 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+ }
Original file line number Diff line number Diff line change @@ -19,5 +19,11 @@ error: derefed type is same as origin
1919LL | 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
You can’t perform that action at this time.
0 commit comments