File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
src/test/ui/rfc-2632-const-trait-impl Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ feature( const_trait_impl) ]
2+ #![ feature( const_fn_trait_bound) ]
3+ #![ feature( const_mut_refs) ]
4+ #![ feature( const_panic) ]
5+
6+ struct S ;
7+
8+ impl const Drop for S {
9+ 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
16+ }
17+ }
18+
19+ const fn a < T : ~const Drop > ( _: T ) { }
20+
21+ const _: ( ) = a ( S ) ;
22+
23+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0080]: evaluation of constant value failed
2+ --> $DIR/const-drop.rs:14:9
3+ |
4+ LL | panic!("much const drop")
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
6+ | |
7+ | the evaluated program panicked at 'much const drop', $DIR/const-drop.rs:14:9
8+ | inside `<S as Drop>::drop` at $SRC_DIR/std/src/panic.rs:LL:COL
9+ ...
10+ LL | const fn a<T: ~const Drop>(_: T) {}
11+ | - inside `a::<S>` at $DIR/const-drop.rs:19:35
12+ LL |
13+ LL | const _: () = a(S);
14+ | ---- inside `_` at $DIR/const-drop.rs:21:15
15+ |
16+ ::: $SRC_DIR/core/src/ptr/mod.rs:LL:COL
17+ |
18+ LL | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
19+ | ------------------------------------------------------- inside `std::ptr::drop_in_place::<S> - shim(Some(S))` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
20+ |
21+ = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
22+
23+ error: aborting due to previous error
24+
25+ For more information about this error, try `rustc --explain E0080`.
You can’t perform that action at this time.
0 commit comments