File tree Expand file tree Collapse file tree 2 files changed +15
-35
lines changed
src/test/ui/rfc-2632-const-trait-impl Expand file tree Collapse file tree 2 files changed +15
-35
lines changed Original file line number Diff line number Diff line change 1+ // run-pass
12#![ feature( const_trait_impl) ]
23#![ feature( const_fn_trait_bound) ]
34#![ feature( const_mut_refs) ]
45#![ feature( const_panic) ]
56
6- struct S ;
7+ struct S < ' a > ( & ' a mut u8 ) ;
78
8- impl const Drop for S {
9+ impl < ' a > const Drop for S < ' a > {
910 fn drop ( & mut self ) {
10- // NB: There is no way to tell that a const destructor is ran,
11- // because even if we can operate on mutable variables, it will
12- // not be reflected because everything is `const`. So we panic
13- // here, attempting to make the CTFE engine error.
14- panic ! ( "much const drop" )
15- //~^ ERROR evaluation of constant value failed
11+ * self . 0 += 1 ;
1612 }
1713}
1814
1915const fn a < T : ~const Drop > ( _: T ) { }
2016
21- const _: ( ) = a ( S ) ;
17+ const fn b ( ) -> u8 {
18+ let mut c = 0 ;
19+ let _ = S ( & mut c) ;
20+ a ( S ( & mut c) ) ;
21+ c
22+ }
23+
24+ const C : u8 = b ( ) ;
2225
23- fn main ( ) { }
26+ fn main ( ) {
27+ assert_eq ! ( C , 2 ) ;
28+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments