Commit graph

11 commits

Author SHA1 Message Date
Ada Alakbarova
eea4d6dc3c
{flat_,}map_identity: recognize (tuple) struct de- and restructuring
base check

same fields different struct

reordered fields

different paths to the same struct

same for tuple structs

style: use `zip`-the-function all over the place

makes the code a bit more concise by removing the need for explicit
`.iter()`

style: move precondition checking to the match guard

the match arms above put the "sanity" checks in the guard, and call only
`check_pat` in the body. With this commit, the (tuple) struct cases
follow that convention as well. Well, almost -- I think the ident check
belongs to the second category of checks, so I put it in the body as
well

misc: use `None` in the pattern directly

this'll probably be marginally faster thanks to the equality check being
now structural

move the tests to the right file
2025-08-01 11:24:44 +02:00
Ada Alakbarova
e610584a9a
{flat_,}map_identity: also recognize |[x, y]| [x, y] 2025-07-12 14:02:41 +02:00
Guillaume Gomez
f666fd6417 Update UI tests 2025-02-15 13:38:16 +01:00
Samuel Tardieu
a9fe04335a Do not remove identity mapping if mandatory mutability would be lost
Removing `.map(identity)` may result in invalid code if the receiver of
`map()` is an immutable binding, and the result of `map()` is used as
the receiver of a method call expecting a mutable reference.
2024-12-29 23:01:14 +01:00
y21
b2cf8f7a24 [map_identity]: respect match ergonomics 2023-11-11 13:48:26 +01:00
y21
d6fc606259 [map_identity]: recognize tuples 2023-10-21 15:40:34 +02:00
y21
0b60531e42 [map_identity]: allow closure with type annotations 2023-10-09 21:39:28 +02:00
Oli Scherer
3d88fae050 Update ui test crate 2023-08-11 14:02:28 +00:00
Oli Scherer
def1705a27 Update to a compiletest-rs version that requires //@ for commands 2023-04-20 14:44:03 +00:00
dswij
3d1f83efbd map_identity Add tests for needless .map_err 2022-03-01 13:11:40 +08:00
Teddy_Wang
40ee620e51 Added a lint for .map(|x| x) 2020-06-13 10:08:12 -04:00