File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ fn replace_with_default() {
3030 let _ = std::mem::take(&mut s);
3131 let s = &mut String::from("foo");
3232 let _ = std::mem::take(s);
33+ let _ = std::mem::take(s);
3334}
3435
3536fn main() {
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ fn replace_with_default() {
3030 let _ = std:: mem:: replace ( & mut s, String :: default ( ) ) ;
3131 let s = & mut String :: from ( "foo" ) ;
3232 let _ = std:: mem:: replace ( s, String :: default ( ) ) ;
33+ let _ = std:: mem:: replace ( s, Default :: default ( ) ) ;
3334}
3435
3536fn main ( ) {
Original file line number Diff line number Diff line change @@ -26,5 +26,11 @@ error: replacing a value of type `T` with `T::default()` is better expressed usi
2626LL | let _ = std::mem::replace(s, String::default());
2727 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(s)`
2828
29- error: aborting due to 4 previous errors
29+ error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
30+ --> $DIR/mem_replace.rs:33:13
31+ |
32+ LL | let _ = std::mem::replace(s, Default::default());
33+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(s)`
34+
35+ error: aborting due to 5 previous errors
3036
You can’t perform that action at this time.
0 commit comments