diff options
| author | Mara <m-ou.se@m-ou.se> | 2021-03-05 10:57:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-05 10:57:23 +0100 |
| commit | 04045cc83f59e08be5d12d7ca4ac4d6364a02ff1 (patch) | |
| tree | a344474d23628d27137c40905cb00c62d5108e4e /compiler/rustc_codegen_cranelift/src/optimize/mod.rs | |
| parent | 232caad39581118619c5168284b15457d1c72900 (diff) | |
| parent | 80fcdef3b53c43f3d7bace1db3e3ef9ffebd757e (diff) | |
| download | rust-04045cc83f59e08be5d12d7ca4ac4d6364a02ff1.tar.gz rust-04045cc83f59e08be5d12d7ca4ac4d6364a02ff1.zip | |
Rollup merge of #82770 - m-ou-se:assert-match, r=joshtriplett
Add assert_matches macro.
This adds `assert_matches!(expression, pattern)`.
Unlike the other asserts, this one ~~consumes the expression~~ may consume the expression, to be able to match the pattern. (It could add a `&` implicitly, but that's noticable in the pattern, and will make a consuming guard impossible.)
See https://github.com/rust-lang/rust/issues/62633#issuecomment-790737853
This re-uses the same `left: .. right: ..` output as the `assert_eq` and `assert_ne` macros, but with the pattern as the right part:
assert_eq:
```
assertion failed: `(left == right)`
left: `Some("asdf")`,
right: `None`
```
assert_matches:
```
assertion failed: `(left matches right)`
left: `Ok("asdf")`,
right: `Err(_)`
```
cc ```@cuviper```
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/optimize/mod.rs')
0 files changed, 0 insertions, 0 deletions
