Skip to content

Commit 786777f

Browse files
committed
Fix an ICE in the vtable iteration for a trait reference in const eval when a supertrait not implemented
compiler/rustc_trait_selection/src/traits/vtable.rs@`vtable_entries`: The impossible predicates check in `vtable_entries` used `instantiate_own` which only includes the method's own where-clauses, not the parent trait's bounds. Replace it with `instantiate_and_check_impossible_predicates` which also checks the trait ref itself, so unsatisfied supertrait bounds are caught and the method is marked `Vacant` instead of ICEing.
1 parent e8f92f5 commit 786777f

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

  • compiler/rustc_trait_selection/src/traits

compiler/rustc_trait_selection/src/traits/vtable.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_span::DUMMY_SP;
1313
use smallvec::{SmallVec, smallvec};
1414
use tracing::debug;
1515

16-
use crate::traits::{impossible_predicates, is_vtable_safe_method};
16+
use crate::traits::is_vtable_safe_method;
1717

1818
#[derive(Clone, Debug)]
1919
pub enum VtblSegment<'tcx> {
@@ -283,11 +283,7 @@ fn vtable_entries<'tcx>(
283283
// do not hold for this particular set of type parameters.
284284
// Note that this method could then never be called, so we
285285
// do not want to try and codegen it, in that case (see #23435).
286-
let predicates = tcx.predicates_of(def_id).instantiate_own(tcx, args);
287-
if impossible_predicates(
288-
tcx,
289-
predicates.map(|(predicate, _)| predicate.skip_norm_wip()).collect(),
290-
) {
286+
if tcx.instantiate_and_check_impossible_predicates((def_id, args)) {
291287
debug!("vtable_entries: predicates do not hold");
292288
return VtblEntry::Vacant;
293289
}

0 commit comments

Comments
 (0)