Also suggest as_mut for match_as_ref

This commit is contained in:
Wilco Kusee 2017-12-20 10:39:48 +01:00
parent 919601bc51
commit a6ccc6fe3d
3 changed files with 29 additions and 22 deletions

View file

@ -316,14 +316,14 @@ fn match_wild_err_arm() {
}
fn match_as_ref() {
let owned : Option<()> = None;
let borrowed = match owned {
let owned: Option<()> = None;
let borrowed: Option<&()> = match owned {
None => None,
Some(ref v) => Some(v),
};
let mut mut_owned : Option<()> = None;
let mut mut_borrowed = match mut_owned {
let mut mut_owned: Option<()> = None;
let borrow_mut: Option<&mut ()> = match mut_owned {
None => None,
Some(ref mut v) => Some(v),
};

View file

@ -427,10 +427,10 @@ note: consider refactoring into `Ok(3) | Ok(_)`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: use as_ref() instead
--> $DIR/matches.rs:320:20
--> $DIR/matches.rs:320:33
|
320 | let borrowed = match owned {
| ____________________^
320 | let borrowed: Option<&()> = match owned {
| _________________________________^
321 | | None => None,
322 | | Some(ref v) => Some(v),
323 | | };
@ -438,13 +438,13 @@ error: use as_ref() instead
|
= note: `-D match-as-ref` implied by `-D warnings`
error: use as_ref() instead
--> $DIR/matches.rs:326:28
error: use as_mut() instead
--> $DIR/matches.rs:326:39
|
326 | let mut mut_borrowed = match mut_owned {
| ____________________________^
326 | let borrow_mut: Option<&mut ()> = match mut_owned {
| _______________________________________^
327 | | None => None,
328 | | Some(ref mut v) => Some(v),
329 | | };
| |_____^ help: try this: `mut_owned.as_ref()`
| |_____^ help: try this: `mut_owned.as_mut()`