@@ -2035,3 +2035,139 @@ test_verify_one_file_with_options! {
20352035 }
20362036 } => Err ( err) => assert_fails( err, 2 )
20372037}
2038+
2039+ test_verify_one_file_with_options ! {
2040+ #[ test] binders_in_pattern_copy_vs_no_copy [ "new-mut-ref" ] => verus_code! {
2041+ enum Option <A > {
2042+ Some ( A ) ,
2043+ None ,
2044+ }
2045+ use crate :: Option :: Some ;
2046+ use crate :: Option :: None ;
2047+
2048+ fn consume<X >( x: X ) { }
2049+
2050+ fn test_copy<X : Copy >( x: X , y: X ) {
2051+ let t = ( x, y) ;
2052+
2053+ match t {
2054+ ( x, _) => { consume( x) ; }
2055+ }
2056+
2057+ assert( has_resolved( t) ) ;
2058+ }
2059+
2060+ fn test_no_copy<X >( x: X , y: X ) {
2061+ let t = ( x, y) ;
2062+
2063+ match t {
2064+ ( x, _) => { consume( x) ; }
2065+ }
2066+
2067+ assert( has_resolved( t) ) ; // FAILS
2068+ }
2069+
2070+ fn test_option_copy<X : Copy >( x: X , y: X ) {
2071+ let t = Some ( ( x, y) ) ;
2072+
2073+ match t {
2074+ Some ( ( x, _) ) => { consume( x) ; }
2075+ None => { }
2076+ }
2077+
2078+ assert( has_resolved( t) ) ;
2079+ }
2080+
2081+ fn test_option_no_copy<X >( x: X , y: X ) {
2082+ let t = Some ( ( x, y) ) ;
2083+
2084+ match t {
2085+ Some ( ( x, _) ) => { consume( x) ; }
2086+ None => { }
2087+ }
2088+
2089+ assert( has_resolved( t) ) ; // FAILS
2090+ }
2091+
2092+ fn test_let_copy<X : Copy >( x: X , y: X ) {
2093+ let t = ( x, y) ;
2094+
2095+ let ( x, _) = t;
2096+ consume( x) ;
2097+
2098+ assert( has_resolved( t) ) ;
2099+ }
2100+
2101+ fn test_let_no_copy<X >( x: X , y: X ) {
2102+ let t = ( x, y) ;
2103+
2104+ let ( x, _) = t;
2105+ consume( x) ;
2106+
2107+ assert( has_resolved( t) ) ; // FAILS
2108+ }
2109+
2110+
2111+
2112+
2113+ fn atbinder_test_copy<X : Copy >( x: X , y: X ) {
2114+ let t = ( x, y) ;
2115+
2116+ match t {
2117+ x @ ( _, _) => { consume( x) ; }
2118+ }
2119+
2120+ assert( has_resolved( t) ) ;
2121+ }
2122+
2123+ fn atbinder_test_no_copy<X >( x: X , y: X ) {
2124+ let t = ( x, y) ;
2125+
2126+ match t {
2127+ x @ ( _, _) => { consume( x) ; }
2128+ }
2129+
2130+ assert( has_resolved( t) ) ; // FAILS
2131+ }
2132+
2133+ fn atbinder_test_option_copy<X : Copy >( x: X , y: X ) {
2134+ let t = Some ( ( x, y) ) ;
2135+
2136+ match t {
2137+ Some ( x @ ( _, _) ) => { consume( x) ; }
2138+ None => { }
2139+ }
2140+
2141+ assert( has_resolved( t) ) ;
2142+ }
2143+
2144+ fn atbinder_test_option_no_copy<X >( x: X , y: X ) {
2145+ let t = Some ( ( x, y) ) ;
2146+
2147+ match t {
2148+ Some ( x @ ( _, _) ) => { consume( x) ; }
2149+ None => { }
2150+ }
2151+
2152+ assert( has_resolved( t) ) ; // FAILS
2153+ }
2154+
2155+ fn atbinder_test_let_copy<X : Copy >( x: X , y: X ) {
2156+ let t = ( x, y) ;
2157+
2158+ let x @ ( _, _) = t;
2159+ consume( x) ;
2160+
2161+ assert( has_resolved( t) ) ;
2162+ }
2163+
2164+ fn atbinder_test_let_no_copy<X >( x: X , y: X ) {
2165+ let t = ( x, y) ;
2166+
2167+ let x @ ( _, _) = t;
2168+ consume( x) ;
2169+
2170+ assert( has_resolved( t) ) ; // FAILS
2171+ }
2172+ } => Err ( err) => assert_fails( err, 6 )
2173+ }
0 commit comments