Skip to content

Commit

Permalink
add test for unused ill-formed constant
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 10, 2020
1 parent 52c7b8e commit ff136bd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/compile-fail/erroneous_const.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//! Make sure we detect erroneous constants post-monomorphization even when they are unused.
//! (https://github.com/rust-lang/miri/issues/1382)
#![feature(const_panic)]
#![feature(never_type)]
#![warn(const_err)]

struct PrintName<T>(T);
impl<T> PrintName<T> {
const VOID: ! = panic!(); //~WARN any use of this value will cause an error
}

fn no_codegen<T>() {
if false {
let _ = PrintName::<T>::VOID; //~ERROR referenced constant has errors
}
}
fn main() {
no_codegen::<i32>();
}

0 comments on commit ff136bd

Please sign in to comment.