//@revisions: noopt opt //@[noopt] build-fail //@[opt] compile-flags: -O //FIXME: `opt` revision currently does not stop with an error due to //. //@[opt] build-pass //! Make sure we detect erroneous constants post-monomorphization even when they are unused. This is //! crucial, people rely on it for soundness. (https://github.com/rust-lang/rust/issues/112090) struct Fail(T); impl Fail { const C: () = panic!(); //[noopt]~ERROR evaluation of `Fail::::C` failed } // This function is not actually called, but it is mentioned in dead code in a function that is // called. Make sure we still find this error. // This relies on mono-item collection checking `required_consts` in functions that syntactically // are called in collected functions (even inside dead code). #[inline(never)] fn not_called() { if false { let _ = Fail::::C; } } #[inline(never)] fn called() { if false { not_called::(); } } pub fn main() { called::(); }