forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add testcase for issue rust-lang#729 (rust-lang#730)
Add a fixme testcase that can be used to reproduce the issue rust-lang#729.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
/// This testcase is currently failing with the following error: | ||
/// | ||
/// [assertion.2] Reached assignment statement with unequal types Pointer { typ: | ||
/// StructTag("tag-Unit") } Pointer { typ: StructTag("tag-_3943305294634710273") }: FAILURE | ||
/// | ||
/// If you run: | ||
/// ``` | ||
/// RUSTFLAGS="--cfg=ok" rmc fixme_niche_opt.rs | ||
/// ``` | ||
/// This test will succeed. | ||
/// | ||
/// Issue: https://github.com/model-checking/rmc/issues/729 | ||
|
||
enum Error { | ||
Error1, | ||
Error2, | ||
} | ||
|
||
/// This version fails. | ||
#[cfg(not(ok))] | ||
fn to_option<T: Copy, E>(result: &Result<T, E>) -> Option<T> { | ||
if let Ok(v) = result { Some(*v) } else { None } | ||
} | ||
|
||
/// This version succeeds. | ||
#[cfg(ok)] | ||
fn to_option<T: Copy, E>(result: &Result<T, E>) -> Option<T> { | ||
if let Ok(v) = *result { Some(v) } else { None } | ||
} | ||
|
||
fn main() { | ||
let result: Result<(), Error> = Ok(()); | ||
assert!(to_option(&result).is_some()); | ||
} |