// SPDX-License-Identifier: Apache-2.0 OR MIT // // Modifications Copyright Kani Contributors // See GitHub history for details. //! Tests that check handling of opaque casts. Tests were adapted from the rustc repository. #![feature(type_alias_impl_trait)] #[derive(Copy, Clone)] struct Foo((u32, u32)); /// Adapted from: /// #[kani::proof] fn check_unconstrained_upvar() { type T = impl Copy; let foo: T = Foo((1u32, 2u32)); let x = move || { let Foo((a, b)) = foo; assert_eq!(a, 1u32); assert_eq!(b, 2u32); }; } /// Adapted from: /// #[kani::proof] fn check_unconstrained_struct() { type U = impl Copy; let foo: U = Foo((1u32, 2u32)); let Foo((a, b)) = foo; assert_eq!(a, 1u32); assert_eq!(b, 2u32); } /// Adapted from: /// #[kani::proof] fn check_unpack_option_tuple() { type T = impl Copy; let foo: T = Some((1u32, 2u32)); match foo { None => (), Some((a, b)) => { assert_eq!(a, 1u32); assert_eq!(b, 2u32) } } }