blob: df06e358f296e090d8954d9f2508455bd036e42a [file] [log] [blame] [edit]
error: manual implementation of `Option::as_ref`
--> tests/ui/match_as_ref.rs:6:33
|
LL | let borrowed: Option<&()> = match owned {
| _________________________________^
LL | |
LL | | None => None,
LL | | Some(ref v) => Some(v),
LL | | };
| |_____^
|
= note: `-D clippy::match-as-ref` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::match_as_ref)]`
help: use `Option::as_ref()` directly
|
LL - let borrowed: Option<&()> = match owned {
LL -
LL - None => None,
LL - Some(ref v) => Some(v),
LL - };
LL + let borrowed: Option<&()> = owned.as_ref();
|
error: manual implementation of `Option::as_mut`
--> tests/ui/match_as_ref.rs:13:39
|
LL | let borrow_mut: Option<&mut ()> = match mut_owned {
| _______________________________________^
LL | |
LL | | None => None,
LL | | Some(ref mut v) => Some(v),
LL | | };
| |_____^
|
help: use `Option::as_mut()` directly
|
LL - let borrow_mut: Option<&mut ()> = match mut_owned {
LL -
LL - None => None,
LL - Some(ref mut v) => Some(v),
LL - };
LL + let borrow_mut: Option<&mut ()> = mut_owned.as_mut();
|
error: manual implementation of `Option::as_ref`
--> tests/ui/match_as_ref.rs:32:13
|
LL | / match self.source {
LL | |
LL | | Some(ref s) => Some(s),
LL | | None => None,
LL | | }
| |_____________^
|
help: use `Option::as_ref()` directly
|
LL - match self.source {
LL -
LL - Some(ref s) => Some(s),
LL - None => None,
LL - }
LL + self.source.as_ref().map(|x| x as _)
|
error: manual implementation of `Option::as_ref`
--> tests/ui/match_as_ref.rs:97:13
|
LL | let _ = match !S {
| _____________^
LL | |
LL | | None => None,
LL | | Some(ref v) => Some(v),
LL | | };
| |_____^
|
help: use `Option::as_ref()` directly
|
LL - let _ = match !S {
LL -
LL - None => None,
LL - Some(ref v) => Some(v),
LL - };
LL + let _ = (!S).as_ref();
|
error: manual implementation of `Option::as_mut`
--> tests/ui/match_as_ref.rs:105:27
|
LL | let _: Option<&u32> = match Some(0) {
| ___________________________^
LL | |
LL | | None => None,
LL | | Some(ref mut v) => Some(v),
LL | | };
| |_____^
|
= note: but the type is coerced to a non-mutable reference, and so `as_ref` can used instead
help: use `Option::as_ref()`
|
LL - let _: Option<&u32> = match Some(0) {
LL -
LL - None => None,
LL - Some(ref mut v) => Some(v),
LL - };
LL + let _: Option<&u32> = Some(0).as_ref();
|
error: manual implementation of `Option::as_mut`
--> tests/ui/match_as_ref.rs:111:43
|
LL | let _: Option<&dyn std::fmt::Debug> = match Some(0) {
| ___________________________________________^
LL | |
LL | | None => None,
LL | | Some(ref mut v) => Some(v),
LL | | };
| |_____^
|
= note: but the type is coerced to a non-mutable reference, and so `as_ref` can used instead
help: use `Option::as_ref()`
|
LL - let _: Option<&dyn std::fmt::Debug> = match Some(0) {
LL -
LL - None => None,
LL - Some(ref mut v) => Some(v),
LL - };
LL + let _: Option<&dyn std::fmt::Debug> = Some(0).as_ref().map(|x| x as _);
|
error: aborting due to 6 previous errors