Skip to content

Commit 74bc7fd

Browse files
committed
Overhaul coercion to use the lazy InferOk obligations passing.
1 parent 3198904 commit 74bc7fd

File tree

2 files changed

+99
-109
lines changed

2 files changed

+99
-109
lines changed

src/librustc_typeck/check/autoderef.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use astconv::AstConv;
1212

1313
use super::FnCtxt;
1414

15+
use rustc::infer::InferOk;
1516
use rustc::traits;
1617
use rustc::ty::{self, Ty, TraitRef};
1718
use rustc::ty::{ToPredicate, TypeFoldable};
@@ -149,6 +150,14 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
149150

150151
pub fn finalize<'b, I>(self, pref: LvaluePreference, exprs: I)
151152
where I: IntoIterator<Item = &'b hir::Expr>
153+
{
154+
let fcx = self.fcx;
155+
fcx.register_infer_ok_obligations(self.finalize_as_infer_ok(pref, exprs));
156+
}
157+
158+
pub fn finalize_as_infer_ok<'b, I>(self, pref: LvaluePreference, exprs: I)
159+
-> InferOk<'tcx, ()>
160+
where I: IntoIterator<Item = &'b hir::Expr>
152161
{
153162
let methods: Vec<_> = self.steps
154163
.iter()
@@ -176,8 +185,9 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
176185
}
177186
}
178187

179-
for obligation in self.obligations {
180-
self.fcx.register_predicate(obligation);
188+
InferOk {
189+
value: (),
190+
obligations: self.obligations
181191
}
182192
}
183193
}

0 commit comments

Comments
 (0)