diff options
| author | Ralf Jung <post@ralfj.de> | 2019-12-24 12:20:36 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-12-24 12:21:05 +0100 |
| commit | db20f248ebcd2a6cb5230b3bde7f400a380b0b87 (patch) | |
| tree | 5e39d2f0eb6437363da30188aa8f247bf6ce7fc7 /src/test | |
| parent | 625375400cdd172877e81c3ce44ce68f2011af2d (diff) | |
| download | rust-db20f248ebcd2a6cb5230b3bde7f400a380b0b87.tar.gz rust-db20f248ebcd2a6cb5230b3bde7f400a380b0b87.zip | |
add test for dropping in const
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/consts/miri_unleashed/drop.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/consts/miri_unleashed/drop.stderr | 24 |
2 files changed, 43 insertions, 0 deletions
diff --git a/src/test/ui/consts/miri_unleashed/drop.rs b/src/test/ui/consts/miri_unleashed/drop.rs new file mode 100644 index 00000000000..ab9d874d579 --- /dev/null +++ b/src/test/ui/consts/miri_unleashed/drop.rs @@ -0,0 +1,19 @@ +// compile-flags: -Zunleash-the-miri-inside-of-you +#![deny(const_err)] + +use std::mem::ManuallyDrop; + +fn main() {} + +static TEST_OK: () = { + let v: Vec<i32> = Vec::new(); + let _v = ManuallyDrop::new(v); +}; + +// Make sure we catch executing bad drop functions. +// The actual error is located in `real_drop_in_place` so we can't capture it with the +// error annotations here. +static TEST_BAD: () = { + let _v: Vec<i32> = Vec::new(); + //~^ WARN skipping const check +}; diff --git a/src/test/ui/consts/miri_unleashed/drop.stderr b/src/test/ui/consts/miri_unleashed/drop.stderr new file mode 100644 index 00000000000..b8fc6a0271d --- /dev/null +++ b/src/test/ui/consts/miri_unleashed/drop.stderr @@ -0,0 +1,24 @@ +warning: skipping const checks + --> $DIR/drop.rs:17:9 + | +LL | let _v: Vec<i32> = Vec::new(); + | ^^ + +error[E0080]: could not evaluate static initializer + --> $SRC_DIR/libcore/ptr/mod.rs:LL:COL + | +LL | / unsafe fn real_drop_in_place<T: ?Sized>(to_drop: &mut T) { +LL | | // Code here does not matter - this is replaced by the +LL | | // real drop glue by the compiler. +LL | | real_drop_in_place(to_drop) +LL | | } + | |_^ calling non-const function `<std::vec::Vec<i32> as std::ops::Drop>::drop` + | + ::: $DIR/drop.rs:19:1 + | +LL | }; + | - inside call to `std::ptr::real_drop_in_place::<std::vec::Vec<i32>> - shim(Some(std::vec::Vec<i32>))` at $DIR/drop.rs:19:1 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. |
