Skip to content

Commit ac40d73

Browse files
committed
use query boilerplate for subtype
1 parent fa71af4 commit ac40d73

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/librustc_traits/type_op_subtype.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@
1111
use rustc::infer::canonical::{Canonical, QueryResult};
1212
use rustc::traits::query::type_op::subtype::Subtype;
1313
use rustc::traits::query::NoSolution;
14-
use rustc::traits::{FulfillmentContext, ObligationCause};
14+
use rustc::traits::ObligationCause;
1515
use rustc::ty::TyCtxt;
1616
use rustc_data_structures::sync::Lrc;
17-
use syntax::codemap::DUMMY_SP;
1817

1918
crate fn type_op_subtype<'tcx>(
2019
tcx: TyCtxt<'_, 'tcx, 'tcx>,
2120
canonicalized: Canonical<'tcx, Subtype<'tcx>>,
2221
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
23-
let tcx = tcx.global_tcx();
24-
tcx.infer_ctxt().enter(|ref infcx| {
25-
let (Subtype { param_env, sub, sup }, canonical_inference_vars) =
26-
infcx.instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &canonicalized);
27-
let fulfill_cx = &mut FulfillmentContext::new();
28-
let obligations = match infcx.at(&ObligationCause::dummy(), param_env).sup(sup, sub) {
29-
Ok(v) => v.into_obligations(),
30-
Err(_) => return Err(NoSolution),
31-
};
32-
fulfill_cx.register_predicate_obligations(infcx, obligations);
33-
infcx.make_canonicalized_query_result(canonical_inference_vars, (), fulfill_cx)
34-
})
22+
tcx.infer_ctxt().enter_canonical_trait_query(
23+
&canonicalized,
24+
|infcx,
25+
Subtype {
26+
param_env,
27+
sub,
28+
sup,
29+
}| {
30+
Ok(infcx
31+
.at(&ObligationCause::dummy(), param_env)
32+
.sup(sup, sub)?)
33+
},
34+
)
3535
}

0 commit comments

Comments
 (0)