Skip to content

Commit bd2096c

Browse files
committed
Only test predicates if this is a default method, as a simple optimization.
1 parent 99a508b commit bd2096c

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/librustc_trans/trans/meth.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -842,13 +842,20 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
842842
return nullptr;
843843
}
844844

845-
let predicates =
846-
monomorphize::apply_param_substs(tcx,
847-
&substs,
848-
&impl_method_type.predicates.predicates);
849-
if !predicates_hold(ccx, predicates.into_vec()) {
850-
debug!("emit_vtable_methods: predicates do not hold");
851-
return nullptr;
845+
// If this is a default method, it's possible that it
846+
// relies on where clauses that do not hold for this
847+
// particular set of type parameters. Note that this
848+
// method could then never be called, so we do not want to
849+
// try and trans it, in that case. Issue #23435.
850+
if ty::provided_source(tcx, impl_method_def_id).is_some() {
851+
let predicates =
852+
monomorphize::apply_param_substs(tcx,
853+
&substs,
854+
&impl_method_type.predicates.predicates);
855+
if !predicates_hold(ccx, predicates.into_vec()) {
856+
debug!("emit_vtable_methods: predicates do not hold");
857+
return nullptr;
858+
}
852859
}
853860

854861
trans_fn_ref_with_substs(ccx,

0 commit comments

Comments
 (0)