about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2017-07-07 00:02:35 +0200
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2017-07-28 15:46:23 +0200
commit0b5b0122ae283df567d1b2fddd7fc4ad17125fb5 (patch)
treeb448cf79361e767af553913cc7488b8b0bcb7a7d
parentb5449b73e65e4e9622a4558e84774cc22755a17d (diff)
downloadrust-0b5b0122ae283df567d1b2fddd7fc4ad17125fb5.tar.gz
rust-0b5b0122ae283df567d1b2fddd7fc4ad17125fb5.zip
Consider all implementations of Generator, not just built in ones
-rw-r--r--src/librustc/traits/select.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs
index 887edc50364..3fcd79f706b 100644
--- a/src/librustc/traits/select.rs
+++ b/src/librustc/traits/select.rs
@@ -1305,9 +1305,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
                                                    &mut candidates)?;
          } else if self.tcx().lang_items.unsize_trait() == Some(def_id) {
              self.assemble_candidates_for_unsizing(obligation, &mut candidates);
-         } else if self.tcx().lang_items.gen_trait() == Some(def_id) {
-             self.assemble_generator_candidates(obligation, &mut candidates)?;
          } else {
+             self.assemble_generator_candidates(obligation, &mut candidates)?;
              self.assemble_closure_candidates(obligation, &mut candidates)?;
              self.assemble_fn_pointer_candidates(obligation, &mut candidates)?;
              self.assemble_candidates_from_impls(obligation, &mut candidates)?;
@@ -1497,6 +1496,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
                                    candidates: &mut SelectionCandidateSet<'tcx>)
                                    -> Result<(),SelectionError<'tcx>>
     {
+        if self.tcx().lang_items.gen_trait() != Some(obligation.predicate.def_id()) {
+            return Ok(());
+        }
+
         let self_ty = *obligation.self_ty().skip_binder();
         let (closure_def_id, substs) = match self_ty.sty {
             ty::TyGenerator(id, substs, _) => (id, substs),