Skip to content

Commit

Permalink
Only test predicates if this is a default method, as a simple optimiz…
Browse files Browse the repository at this point in the history
…ation.
  • Loading branch information
nikomatsakis committed Mar 17, 2015
1 parent 99a508b commit bd2096c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/librustc_trans/trans/meth.rs
Expand Up @@ -842,13 +842,20 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
return nullptr;
}

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

trans_fn_ref_with_substs(ccx,
Expand Down

0 comments on commit bd2096c

Please sign in to comment.