diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2021-09-01 11:55:16 +0000 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2021-09-09 05:21:29 +0000 |
| commit | f6f5180d5fef3b3a4cc8a383eb20b83716935e6a (patch) | |
| tree | 6dc7e9775c1882ca00b6b69896e7b3c962265ac7 | |
| parent | 9125fbfd60afd9dafca843857498232503be365a (diff) | |
| download | rust-f6f5180d5fef3b3a4cc8a383eb20b83716935e6a.tar.gz rust-f6f5180d5fef3b3a4cc8a383eb20b83716935e6a.zip | |
Add a simple test case
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/const-drop.rs | 23 | ||||
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/const-drop.stderr | 25 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs b/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs new file mode 100644 index 00000000000..90fe28c7367 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs @@ -0,0 +1,23 @@ +#![feature(const_trait_impl)] +#![feature(const_fn_trait_bound)] +#![feature(const_mut_refs)] +#![feature(const_panic)] + +struct S; + +impl const Drop for S { + fn drop(&mut self) { + // NB: There is no way to tell that a const destructor is ran, + // because even if we can operate on mutable variables, it will + // not be reflected because everything is `const`. So we panic + // here, attempting to make the CTFE engine error. + panic!("much const drop") + //~^ ERROR evaluation of constant value failed + } +} + +const fn a<T: ~const Drop>(_: T) {} + +const _: () = a(S); + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-drop.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-drop.stderr new file mode 100644 index 00000000000..33eba4f4d25 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/const-drop.stderr @@ -0,0 +1,25 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const-drop.rs:14:9 + | +LL | panic!("much const drop") + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | the evaluated program panicked at 'much const drop', $DIR/const-drop.rs:14:9 + | inside `<S as Drop>::drop` at $SRC_DIR/std/src/panic.rs:LL:COL +... +LL | const fn a<T: ~const Drop>(_: T) {} + | - inside `a::<S>` at $DIR/const-drop.rs:19:35 +LL | +LL | const _: () = a(S); + | ---- inside `_` at $DIR/const-drop.rs:21:15 + | + ::: $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | +LL | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { + | ------------------------------------------------------- inside `std::ptr::drop_in_place::<S> - shim(Some(S))` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. |
