-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for unused ill-formed constant
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(); | ||
} |