Skip to content

Commit

Permalink
Overhaul coercion to use the lazy InferOk obligations passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Mar 9, 2017
1 parent 3198904 commit 74bc7fd
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 109 deletions.
14 changes: 12 additions & 2 deletions src/librustc_typeck/check/autoderef.rs
Expand Up @@ -12,6 +12,7 @@ use astconv::AstConv;

use super::FnCtxt;

use rustc::infer::InferOk;
use rustc::traits;
use rustc::ty::{self, Ty, TraitRef};
use rustc::ty::{ToPredicate, TypeFoldable};
Expand Down Expand Up @@ -149,6 +150,14 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {

pub fn finalize<'b, I>(self, pref: LvaluePreference, exprs: I)
where I: IntoIterator<Item = &'b hir::Expr>
{
let fcx = self.fcx;
fcx.register_infer_ok_obligations(self.finalize_as_infer_ok(pref, exprs));
}

pub fn finalize_as_infer_ok<'b, I>(self, pref: LvaluePreference, exprs: I)
-> InferOk<'tcx, ()>
where I: IntoIterator<Item = &'b hir::Expr>
{
let methods: Vec<_> = self.steps
.iter()
Expand Down Expand Up @@ -176,8 +185,9 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
}
}

for obligation in self.obligations {
self.fcx.register_predicate(obligation);
InferOk {
value: (),
obligations: self.obligations
}
}
}
Expand Down

0 comments on commit 74bc7fd

Please sign in to comment.