mentioned items: also handle vtables
This commit is contained in:
parent
ee4b758161
commit
347ca50bc8
6 changed files with 106 additions and 44 deletions
|
|
@ -1,21 +1,21 @@
|
|||
error[E0080]: evaluation of `Fail::<i32>::C` failed
|
||||
--> $DIR/collect-in-dead-vtable.rs:11:19
|
||||
--> $DIR/collect-in-dead-vtable.rs:8:19
|
||||
|
|
||||
LL | const C: () = panic!();
|
||||
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-vtable.rs:11:19
|
||||
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-vtable.rs:8:19
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/collect-in-dead-vtable.rs:25:21
|
||||
--> $DIR/collect-in-dead-vtable.rs:21:21
|
||||
|
|
||||
LL | let _ = Fail::<T>::C;
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
note: the above error was encountered while instantiating `fn <std::vec::Vec<i32> as MyTrait>::not_called`
|
||||
--> $DIR/collect-in-dead-vtable.rs:34:40
|
||||
--> $DIR/collect-in-dead-vtable.rs:30:40
|
||||
|
|
||||
LL | let gen_vtable: &dyn MyTrait = &v; // vtable "appears" here
|
||||
LL | let gen_vtable: &dyn MyTrait = &v; // vtable is "mentioned" here
|
||||
| ^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
error[E0080]: evaluation of `Fail::<i32>::C` failed
|
||||
--> $DIR/collect-in-dead-vtable.rs:8:19
|
||||
|
|
||||
LL | const C: () = panic!();
|
||||
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-vtable.rs:8:19
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/collect-in-dead-vtable.rs:21:21
|
||||
|
|
||||
LL | let _ = Fail::<T>::C;
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
note: the above error was encountered while instantiating `fn <std::vec::Vec<i32> as MyTrait>::not_called`
|
||||
--> $DIR/collect-in-dead-vtable.rs:30:40
|
||||
|
|
||||
LL | let gen_vtable: &dyn MyTrait = &v; // vtable is "mentioned" here
|
||||
| ^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
//@revisions: noopt opt
|
||||
//@[noopt] build-fail
|
||||
//@ build-fail
|
||||
//@[opt] compile-flags: -O
|
||||
//FIXME: `opt` revision currently does not stop with an error due to
|
||||
//<https://github.com/rust-lang/rust/issues/107503>.
|
||||
//@[opt] build-pass
|
||||
//! This fails without optimizations, so it should also fail with optimizations.
|
||||
|
||||
struct Fail<T>(T);
|
||||
impl<T> Fail<T> {
|
||||
const C: () = panic!(); //[noopt]~ERROR evaluation of `Fail::<i32>::C` failed
|
||||
const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed
|
||||
}
|
||||
|
||||
trait MyTrait {
|
||||
|
|
@ -17,8 +14,7 @@ trait MyTrait {
|
|||
|
||||
// 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.
|
||||
// This relies on mono-item collection checking `required_consts` in functions that are referenced
|
||||
// in vtables that syntactically appear in collected functions (even inside dead code).
|
||||
// This ensures that we are properly considering vtables when gathering "mentioned" items.
|
||||
impl<T> MyTrait for Vec<T> {
|
||||
fn not_called(&self) {
|
||||
if false {
|
||||
|
|
@ -31,7 +27,7 @@ impl<T> MyTrait for Vec<T> {
|
|||
fn called<T>() {
|
||||
if false {
|
||||
let v: Vec<T> = Vec::new();
|
||||
let gen_vtable: &dyn MyTrait = &v; // vtable "appears" here
|
||||
let gen_vtable: &dyn MyTrait = &v; // vtable is "mentioned" here
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue