Remove opaque type obligation and just register opaque types as they are encountered.
This also registers obligations for the hidden type immediately.
This commit is contained in:
parent
86e1860495
commit
1163aa7e72
60 changed files with 290 additions and 311 deletions
|
@ -2646,7 +2646,7 @@ impl NormalizeLocation for Location {
|
|||
pub(super) struct InstantiateOpaqueType<'tcx> {
|
||||
pub base_universe: Option<ty::UniverseIndex>,
|
||||
pub region_constraints: Option<RegionConstraintData<'tcx>>,
|
||||
pub obligation: PredicateObligation<'tcx>,
|
||||
pub obligations: Vec<PredicateObligation<'tcx>>,
|
||||
}
|
||||
|
||||
impl<'tcx> TypeOp<'tcx> for InstantiateOpaqueType<'tcx> {
|
||||
|
@ -2660,7 +2660,7 @@ impl<'tcx> TypeOp<'tcx> for InstantiateOpaqueType<'tcx> {
|
|||
|
||||
fn fully_perform(mut self, infcx: &InferCtxt<'_, 'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
|
||||
let (mut output, region_constraints) = scrape_region_constraints(infcx, || {
|
||||
Ok(InferOk { value: (), obligations: vec![self.obligation.clone()] })
|
||||
Ok(InferOk { value: (), obligations: self.obligations.clone() })
|
||||
})?;
|
||||
self.region_constraints = Some(region_constraints);
|
||||
output.error_info = Some(self);
|
||||
|
|
|
@ -2,6 +2,7 @@ use rustc_infer::infer::nll_relate::{NormalizationStrategy, TypeRelating, TypeRe
|
|||
use rustc_infer::infer::NllRegionVariableOrigin;
|
||||
use rustc_infer::traits::ObligationCause;
|
||||
use rustc_middle::mir::ConstraintCategory;
|
||||
use rustc_middle::ty::error::TypeError;
|
||||
use rustc_middle::ty::relate::TypeRelation;
|
||||
use rustc_middle::ty::{self, Const, Ty};
|
||||
use rustc_span::Span;
|
||||
|
@ -136,7 +137,12 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
|
|||
true
|
||||
}
|
||||
|
||||
fn register_opaque_type(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, a_is_expected: bool) {
|
||||
fn register_opaque_type(
|
||||
&mut self,
|
||||
a: Ty<'tcx>,
|
||||
b: Ty<'tcx>,
|
||||
a_is_expected: bool,
|
||||
) -> Result<(), TypeError<'tcx>> {
|
||||
let param_env = self.param_env();
|
||||
let span = self.span();
|
||||
let def_id = self.type_checker.body.source.def_id().expect_local();
|
||||
|
@ -147,18 +153,17 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
|
|||
self.locations,
|
||||
self.category,
|
||||
InstantiateOpaqueType {
|
||||
obligation: self.type_checker.infcx.opaque_ty_obligation(
|
||||
a,
|
||||
b,
|
||||
a_is_expected,
|
||||
param_env,
|
||||
cause,
|
||||
),
|
||||
obligations: self
|
||||
.type_checker
|
||||
.infcx
|
||||
.handle_opaque_type(a, b, a_is_expected, &cause, param_env)?
|
||||
.obligations,
|
||||
// These fields are filled in during exectuion of the operation
|
||||
base_universe: None,
|
||||
region_constraints: None,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue