2024-03-13 09:07:47 -05:00
|
|
|
//@revisions: noopt opt
|
2024-03-17 07:28:31 -05:00
|
|
|
//@ build-fail
|
2024-03-18 11:54:48 -05:00
|
|
|
//@[noopt] compile-flags: -Copt-level=0
|
2024-03-13 09:07:47 -05:00
|
|
|
//@[opt] compile-flags: -O
|
2024-03-17 03:02:18 -05:00
|
|
|
//! This fails without optimizations, so it should also fail with optimizations.
|
2024-03-13 09:07:47 -05:00
|
|
|
|
|
|
|
struct Fail<T>(T);
|
|
|
|
impl<T> Fail<T> {
|
2024-03-17 07:28:31 -05:00
|
|
|
const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed
|
2024-03-13 09:07:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
trait MyTrait {
|
|
|
|
fn not_called(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This function is not actually called, but it is mentioned in a vtable in a function that is
|
|
|
|
// called. Make sure we still find this error.
|
2024-03-17 07:28:31 -05:00
|
|
|
// This ensures that we are properly considering vtables when gathering "mentioned" items.
|
2024-03-13 09:07:47 -05:00
|
|
|
impl<T> MyTrait for Vec<T> {
|
|
|
|
fn not_called(&self) {
|
|
|
|
if false {
|
|
|
|
let _ = Fail::<T>::C;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline(never)]
|
|
|
|
fn called<T>() {
|
|
|
|
if false {
|
|
|
|
let v: Vec<T> = Vec::new();
|
2024-03-17 07:28:31 -05:00
|
|
|
let gen_vtable: &dyn MyTrait = &v; // vtable is "mentioned" here
|
2024-03-13 09:07:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
called::<i32>();
|
|
|
|
}
|