move code to InferCtxt
method
This commit is contained in:
parent
ab61e722ee
commit
c2b61fbafe
3 changed files with 18 additions and 16 deletions
|
@ -670,6 +670,22 @@ pub struct CombinedSnapshot<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
|
/// calls `tcx.try_unify_abstract_consts` after
|
||||||
|
/// canonicalizing the consts.
|
||||||
|
pub fn try_unify_abstract_consts(
|
||||||
|
&self,
|
||||||
|
a: ty::Unevaluated<'tcx>,
|
||||||
|
b: ty::Unevaluated<'tcx>,
|
||||||
|
) -> bool {
|
||||||
|
let canonical = self.canonicalize_query(
|
||||||
|
((a.def, a.substs), (b.def, b.substs)),
|
||||||
|
&mut OriginalQueryValues::default(),
|
||||||
|
);
|
||||||
|
debug!("canonical consts: {:?}", &canonical.value);
|
||||||
|
|
||||||
|
self.tcx.try_unify_abstract_consts(canonical.value)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_in_snapshot(&self) -> bool {
|
pub fn is_in_snapshot(&self) -> bool {
|
||||||
self.in_snapshot.get()
|
self.in_snapshot.get()
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ use rustc_data_structures::obligation_forest::{Error, ForestObligation, Outcome}
|
||||||
use rustc_data_structures::obligation_forest::{ObligationForest, ObligationProcessor};
|
use rustc_data_structures::obligation_forest::{ObligationForest, ObligationProcessor};
|
||||||
use rustc_errors::ErrorReported;
|
use rustc_errors::ErrorReported;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_infer::infer::canonical::OriginalQueryValues;
|
|
||||||
use rustc_infer::traits::{SelectionError, TraitEngine, TraitEngineExt as _, TraitObligation};
|
use rustc_infer::traits::{SelectionError, TraitEngine, TraitEngineExt as _, TraitObligation};
|
||||||
use rustc_middle::mir::abstract_const::NotConstEvaluatable;
|
use rustc_middle::mir::abstract_const::NotConstEvaluatable;
|
||||||
use rustc_middle::mir::interpret::ErrorHandled;
|
use rustc_middle::mir::interpret::ErrorHandled;
|
||||||
|
@ -553,13 +552,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||||
if let (ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b)) =
|
if let (ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b)) =
|
||||||
(c1.val, c2.val)
|
(c1.val, c2.val)
|
||||||
{
|
{
|
||||||
let canonical = infcx.canonicalize_query(
|
if infcx.try_unify_abstract_consts(a, b) {
|
||||||
((a.def, a.substs), (b.def, b.substs)),
|
|
||||||
&mut OriginalQueryValues::default(),
|
|
||||||
);
|
|
||||||
debug!("canonical consts: {:?}", &canonical.value);
|
|
||||||
|
|
||||||
if self.selcx.tcx().try_unify_abstract_consts(canonical.value) {
|
|
||||||
return ProcessResult::Changed(vec![]);
|
return ProcessResult::Changed(vec![]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ use rustc_errors::ErrorReported;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::Constness;
|
use rustc_hir::Constness;
|
||||||
use rustc_infer::infer::canonical::OriginalQueryValues;
|
|
||||||
use rustc_infer::infer::LateBoundRegionConversionTime;
|
use rustc_infer::infer::LateBoundRegionConversionTime;
|
||||||
use rustc_middle::dep_graph::{DepKind, DepNodeIndex};
|
use rustc_middle::dep_graph::{DepKind, DepNodeIndex};
|
||||||
use rustc_middle::mir::abstract_const::NotConstEvaluatable;
|
use rustc_middle::mir::abstract_const::NotConstEvaluatable;
|
||||||
|
@ -609,13 +608,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
if let (ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b)) =
|
if let (ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b)) =
|
||||||
(c1.val, c2.val)
|
(c1.val, c2.val)
|
||||||
{
|
{
|
||||||
let canonical = self.infcx.canonicalize_query(
|
if self.infcx.try_unify_abstract_consts(a, b) {
|
||||||
((a.def, a.substs), (b.def, b.substs)),
|
|
||||||
&mut OriginalQueryValues::default(),
|
|
||||||
);
|
|
||||||
debug!("canonical consts: {:?}", &canonical.value);
|
|
||||||
|
|
||||||
if self.tcx().try_unify_abstract_consts(canonical.value) {
|
|
||||||
return Ok(EvaluatedToOk);
|
return Ok(EvaluatedToOk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue