diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2021-04-25 22:02:48 -0700 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2021-05-06 11:37:45 -0700 |
| commit | 47b99485a391e21caf3e0312969ed00ccbc6c167 (patch) | |
| tree | 86bcceae0b8d41db37cdc215a30116afaf272f87 /src/test/codegen | |
| parent | 266a72637a5bb79eeaaa741950a6f9501bfd2f8d (diff) | |
mir-opt & codegen test updates
`SimplifyArm` and such are currently in `-Zunsound-mir-opts` and thus weren't running by default, so having something like them for the new desugar shouldn't be necessary for switching.
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/try_identity.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/test/codegen/try_identity.rs b/src/test/codegen/try_identity.rs index 81e2435e5b8..78da06b2fe4 100644 --- a/src/test/codegen/try_identity.rs +++ b/src/test/codegen/try_identity.rs @@ -7,11 +7,28 @@ type R = Result<u64, i32>; +// This was written to the `?` from `try_trait`, +// but `try_trait_v2` uses a different structure, +// so the relevant desugar is copied inline +// in order to keep the test testing the same thing. #[no_mangle] -fn try_identity(x: R) -> R { +pub fn try_identity(x: R) -> R { // CHECK: start: // CHECK-NOT: br {{.*}} // CHECK ret void - let y = x?; + let y = match into_result(x) { + Err(e) => return from_error(From::from(e)), + Ok(v) => v, + }; Ok(y) } + +#[inline] +fn into_result<T, E>(r: Result<T, E>) -> Result<T, E> { + r +} + +#[inline] +fn from_error<T, E>(e: E) -> Result<T, E> { + Err(e) +} |
