Skip to content

Commit

Permalink
Add testcase for issue rust-lang#729 (rust-lang#730)
Browse files Browse the repository at this point in the history
Add a fixme testcase that can be used to reproduce the issue rust-lang#729.
  • Loading branch information
celinval authored and tedinski committed Jan 6, 2022
1 parent 0ff8e47 commit 3dc4982
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/test/rmc/Invariants/fixme_niche_opt.rs
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());
}

0 comments on commit 3dc4982

Please sign in to comment.