about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2015-03-17 07:36:42 -0400
committerNiko Matsakis <niko@alum.mit.edu>2015-03-17 07:36:42 -0400
commitbd2096c497580da263c20e8231666a995722ac29 (patch)
tree2ab6e9e225e56bfb681385388a586679a572de25 /src
parent99a508bc1795a7913ad790a3bf60f68dc782f282 (diff)
downloadrust-bd2096c497580da263c20e8231666a995722ac29.tar.gz
rust-bd2096c497580da263c20e8231666a995722ac29.zip
Only test predicates if this is a default method, as a simple optimization.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trans/trans/meth.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs
index 735a7162f04..b1d705e8683 100644
--- a/src/librustc_trans/trans/meth.rs
+++ b/src/librustc_trans/trans/meth.rs
@@ -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,