Bubble the opaque type ordering int opaque type handling
This commit is contained in:
parent
196a429a67
commit
f3bd222ad9
1 changed files with 8 additions and 5 deletions
|
@ -103,7 +103,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
return Ok(InferOk { value: (), obligations: vec![] });
|
return Ok(InferOk { value: (), obligations: vec![] });
|
||||||
}
|
}
|
||||||
let (a, b) = if a_is_expected { (a, b) } else { (b, a) };
|
let (a, b) = if a_is_expected { (a, b) } else { (b, a) };
|
||||||
let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() {
|
let process = |a: Ty<'tcx>, b: Ty<'tcx>, a_is_expected| match *a.kind() {
|
||||||
ty::Opaque(def_id, substs) if def_id.is_local() => {
|
ty::Opaque(def_id, substs) if def_id.is_local() => {
|
||||||
let def_id = def_id.expect_local();
|
let def_id = def_id.expect_local();
|
||||||
let origin = match self.defining_use_anchor {
|
let origin = match self.defining_use_anchor {
|
||||||
|
@ -169,13 +169,14 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
param_env,
|
param_env,
|
||||||
b,
|
b,
|
||||||
origin,
|
origin,
|
||||||
|
a_is_expected,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
if let Some(res) = process(a, b) {
|
if let Some(res) = process(a, b, true) {
|
||||||
res
|
res
|
||||||
} else if let Some(res) = process(b, a) {
|
} else if let Some(res) = process(b, a, false) {
|
||||||
res
|
res
|
||||||
} else {
|
} else {
|
||||||
let (a, b) = self.resolve_vars_if_possible((a, b));
|
let (a, b) = self.resolve_vars_if_possible((a, b));
|
||||||
|
@ -514,13 +515,14 @@ impl UseKind {
|
||||||
|
|
||||||
impl<'tcx> InferCtxt<'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
#[instrument(skip(self), level = "debug")]
|
#[instrument(skip(self), level = "debug")]
|
||||||
pub fn register_hidden_type(
|
fn register_hidden_type(
|
||||||
&self,
|
&self,
|
||||||
opaque_type_key: OpaqueTypeKey<'tcx>,
|
opaque_type_key: OpaqueTypeKey<'tcx>,
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
hidden_ty: Ty<'tcx>,
|
hidden_ty: Ty<'tcx>,
|
||||||
origin: hir::OpaqueTyOrigin,
|
origin: hir::OpaqueTyOrigin,
|
||||||
|
a_is_expected: bool,
|
||||||
) -> InferResult<'tcx, ()> {
|
) -> InferResult<'tcx, ()> {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
|
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
|
||||||
|
@ -539,7 +541,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
origin,
|
origin,
|
||||||
);
|
);
|
||||||
if let Some(prev) = prev {
|
if let Some(prev) = prev {
|
||||||
obligations = self.at(&cause, param_env).eq(prev, hidden_ty)?.obligations;
|
obligations =
|
||||||
|
self.at(&cause, param_env).eq_exp(a_is_expected, prev, hidden_ty)?.obligations;
|
||||||
}
|
}
|
||||||
|
|
||||||
let item_bounds = tcx.bound_explicit_item_bounds(def_id.to_def_id());
|
let item_bounds = tcx.bound_explicit_item_bounds(def_id.to_def_id());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue