diff options
| author | dswij <dswijj@gmail.com> | 2022-03-01 12:54:08 +0800 |
|---|---|---|
| committer | dswij <dswijj@gmail.com> | 2022-03-01 13:11:40 +0800 |
| commit | 3d1f83efbd7227da1f259f071ab1af294df8d36e (patch) | |
| tree | 321033284b53fe1f536130e60fe88b3a00369b5c | |
| parent | 35b145389526ffd7b0f7c6df830245e3ea51353b (diff) | |
| download | rust-3d1f83efbd7227da1f259f071ab1af294df8d36e.tar.gz rust-3d1f83efbd7227da1f259f071ab1af294df8d36e.zip | |
`map_identity` Add tests for needless `.map_err`
| -rw-r--r-- | tests/ui/map_identity.fixed | 2 | ||||
| -rw-r--r-- | tests/ui/map_identity.rs | 2 | ||||
| -rw-r--r-- | tests/ui/map_identity.stderr | 8 |
3 files changed, 11 insertions, 1 deletions
diff --git a/tests/ui/map_identity.fixed b/tests/ui/map_identity.fixed index 4a1452b25f3..2256e51f2d0 100644 --- a/tests/ui/map_identity.fixed +++ b/tests/ui/map_identity.fixed @@ -16,6 +16,8 @@ fn main() { let _: Result<i8, f32> = Err(2.3).map(|x: i8| { return x + 3; }); + let _: Result<u32, u32> = Ok(1); + let _: Result<u32, u32> = Ok(1).map_err(|a: u32| a * 42); } fn not_identity(x: &u16) -> u16 { diff --git a/tests/ui/map_identity.rs b/tests/ui/map_identity.rs index 65c7e6e1ea5..ccfdc9ea76d 100644 --- a/tests/ui/map_identity.rs +++ b/tests/ui/map_identity.rs @@ -18,6 +18,8 @@ fn main() { let _: Result<i8, f32> = Err(2.3).map(|x: i8| { return x + 3; }); + let _: Result<u32, u32> = Ok(1).map_err(|a| a); + let _: Result<u32, u32> = Ok(1).map_err(|a: u32| a * 42); } fn not_identity(x: &u16) -> u16 { diff --git a/tests/ui/map_identity.stderr b/tests/ui/map_identity.stderr index e4a0320cbda..b6a77281f6d 100644 --- a/tests/ui/map_identity.stderr +++ b/tests/ui/map_identity.stderr @@ -33,5 +33,11 @@ LL | | return x; LL | | }); | |______^ help: remove the call to `map` -error: aborting due to 5 previous errors +error: unnecessary map of the identity function + --> $DIR/map_identity.rs:21:36 + | +LL | let _: Result<u32, u32> = Ok(1).map_err(|a| a); + | ^^^^^^^^^^^^^^^ help: remove the call to `map_err` + +error: aborting due to 6 previous errors |
