Skip to content

Commit e6c8c63

Browse files
committed
use query boilerplate for prove-predicate -- slightly inefficient
This requires us to allocate a single entry vector we didn't use to allocate. I doubt this makes a difference in practice, as this only occurs for cache misses.
1 parent ac40d73 commit e6c8c63

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/librustc_traits/type_op_prove_predicate.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,31 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use rustc::infer::InferOk;
1112
use rustc::infer::canonical::{Canonical, QueryResult};
1213
use rustc::traits::query::type_op::prove_predicate::ProvePredicate;
1314
use rustc::traits::query::NoSolution;
14-
use rustc::traits::{FulfillmentContext, Obligation, ObligationCause, TraitEngine};
15+
use rustc::traits::{Obligation, ObligationCause};
1516
use rustc::ty::TyCtxt;
1617
use rustc_data_structures::sync::Lrc;
17-
use syntax::codemap::DUMMY_SP;
1818

1919
crate fn type_op_prove_predicate<'tcx>(
2020
tcx: TyCtxt<'_, 'tcx, 'tcx>,
2121
canonicalized: Canonical<'tcx, ProvePredicate<'tcx>>,
2222
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
23-
let tcx = tcx.global_tcx();
24-
tcx.infer_ctxt().enter(|ref infcx| {
25-
let (ProvePredicate { param_env, predicate }, canonical_inference_vars) =
26-
infcx.instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &canonicalized);
27-
let fulfill_cx = &mut FulfillmentContext::new();
28-
let obligation = Obligation::new(ObligationCause::dummy(), param_env, predicate);
29-
fulfill_cx.register_predicate_obligation(infcx, obligation);
30-
infcx.make_canonicalized_query_result(canonical_inference_vars, (), fulfill_cx)
31-
})
23+
tcx.infer_ctxt()
24+
.enter_canonical_trait_query(&canonicalized, |_infcx, key| {
25+
let ProvePredicate {
26+
param_env,
27+
predicate,
28+
} = key;
29+
Ok(InferOk {
30+
value: (),
31+
obligations: vec![Obligation::new(
32+
ObligationCause::dummy(),
33+
param_env,
34+
predicate,
35+
)],
36+
})
37+
})
3238
}

0 commit comments

Comments
 (0)