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
1
2
#![ feature( const_trait_impl) ]
2
3
#![ feature( const_fn_trait_bound) ]
3
4
#![ feature( const_mut_refs) ]
4
5
#![ feature( const_panic) ]
5
6
6
- struct S ;
7
+ struct S < ' a > ( & ' a mut u8 ) ;
7
8
8
- impl const Drop for S {
9
+ impl < ' a > const Drop for S < ' a > {
9
10
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 ;
16
12
}
17
13
}
18
14
19
15
const fn a < T : ~const Drop > ( _: T ) { }
20
16
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 ( ) ;
22
25
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