Remove unnecessary DefineOpaqueTypes from lub
This commit is contained in:
parent
da71dfbc51
commit
5d62afd2ba
@ -141,7 +141,7 @@ fn unify(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> InferResult<'tcx, Ty<'tcx>> {
|
||||
let at = self.at(&self.cause, self.fcx.param_env);
|
||||
|
||||
let res = if self.use_lub {
|
||||
at.lub(DefineOpaqueTypes::Yes, b, a)
|
||||
at.lub(b, a)
|
||||
} else {
|
||||
at.sup(DefineOpaqueTypes::Yes, b, a)
|
||||
.map(|InferOk { value: (), obligations }| InferOk { value: b, obligations })
|
||||
@ -1190,13 +1190,9 @@ fn try_find_coercion_lub<E>(
|
||||
(ty::FnDef(..), ty::FnDef(..)) => {
|
||||
// Don't reify if the function types have a LUB, i.e., they
|
||||
// are the same function and their parameters have a LUB.
|
||||
match self.commit_if_ok(|_| {
|
||||
self.at(cause, self.param_env).lub(
|
||||
DefineOpaqueTypes::Yes,
|
||||
prev_ty,
|
||||
new_ty,
|
||||
)
|
||||
}) {
|
||||
match self
|
||||
.commit_if_ok(|_| self.at(cause, self.param_env).lub(prev_ty, new_ty))
|
||||
{
|
||||
// We have a LUB of prev_ty and new_ty, just return it.
|
||||
Ok(ok) => return Ok(self.register_infer_ok_obligations(ok)),
|
||||
Err(_) => {
|
||||
@ -1239,7 +1235,7 @@ fn try_find_coercion_lub<E>(
|
||||
let (a_sig, b_sig) = self.normalize(new.span, (a_sig, b_sig));
|
||||
let sig = self
|
||||
.at(cause, self.param_env)
|
||||
.lub(DefineOpaqueTypes::Yes, a_sig, b_sig)
|
||||
.lub(a_sig, b_sig)
|
||||
.map(|ok| self.register_infer_ok_obligations(ok))?;
|
||||
|
||||
// Reify both sides and return the reified fn pointer type.
|
||||
@ -1330,9 +1326,7 @@ fn try_find_coercion_lub<E>(
|
||||
);
|
||||
|
||||
return Err(self
|
||||
.commit_if_ok(|_| {
|
||||
self.at(cause, self.param_env).lub(DefineOpaqueTypes::Yes, prev_ty, new_ty)
|
||||
})
|
||||
.commit_if_ok(|_| self.at(cause, self.param_env).lub(prev_ty, new_ty))
|
||||
.unwrap_err());
|
||||
}
|
||||
}
|
||||
@ -1344,13 +1338,7 @@ fn try_find_coercion_lub<E>(
|
||||
Err(e)
|
||||
} else {
|
||||
Err(self
|
||||
.commit_if_ok(|_| {
|
||||
self.at(cause, self.param_env).lub(
|
||||
DefineOpaqueTypes::Yes,
|
||||
prev_ty,
|
||||
new_ty,
|
||||
)
|
||||
})
|
||||
.commit_if_ok(|_| self.at(cause, self.param_env).lub(prev_ty, new_ty))
|
||||
.unwrap_err())
|
||||
}
|
||||
}
|
||||
|
@ -280,12 +280,7 @@ pub fn eq_structurally_relating_aliases_no_trace<T>(
|
||||
/// this can result in an error (e.g., if asked to compute LUB of
|
||||
/// u32 and i32), it is meaningful to call one of them the
|
||||
/// "expected type".
|
||||
pub fn lub<T>(
|
||||
self,
|
||||
define_opaque_types: DefineOpaqueTypes,
|
||||
expected: T,
|
||||
actual: T,
|
||||
) -> InferResult<'tcx, T>
|
||||
pub fn lub<T>(self, expected: T, actual: T) -> InferResult<'tcx, T>
|
||||
where
|
||||
T: ToTrace<'tcx>,
|
||||
{
|
||||
@ -293,7 +288,6 @@ pub fn lub<T>(
|
||||
self.infcx,
|
||||
ToTrace::to_trace(self.cause, expected, actual),
|
||||
self.param_env,
|
||||
define_opaque_types,
|
||||
LatticeOpKind::Lub,
|
||||
);
|
||||
let value = op.relate(expected, actual)?;
|
||||
@ -303,12 +297,7 @@ pub fn lub<T>(
|
||||
/// Computes the greatest-lower-bound, or mutual subtype, of two
|
||||
/// values. As with `lub` order doesn't matter, except for error
|
||||
/// cases.
|
||||
pub fn glb<T>(
|
||||
self,
|
||||
define_opaque_types: DefineOpaqueTypes,
|
||||
expected: T,
|
||||
actual: T,
|
||||
) -> InferResult<'tcx, T>
|
||||
pub fn glb<T>(self, expected: T, actual: T) -> InferResult<'tcx, T>
|
||||
where
|
||||
T: ToTrace<'tcx>,
|
||||
{
|
||||
@ -316,7 +305,6 @@ pub fn glb<T>(
|
||||
self.infcx,
|
||||
ToTrace::to_trace(self.cause, expected, actual),
|
||||
self.param_env,
|
||||
define_opaque_types,
|
||||
LatticeOpKind::Glb,
|
||||
);
|
||||
let value = op.relate(expected, actual)?;
|
||||
|
@ -49,7 +49,6 @@ pub(crate) struct LatticeOp<'infcx, 'tcx> {
|
||||
// Immutable fields
|
||||
trace: TypeTrace<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
define_opaque_types: DefineOpaqueTypes,
|
||||
// Mutable fields
|
||||
kind: LatticeOpKind,
|
||||
obligations: Vec<PredicateObligation<'tcx>>,
|
||||
@ -60,10 +59,9 @@ pub(crate) fn new(
|
||||
infcx: &'infcx InferCtxt<'tcx>,
|
||||
trace: TypeTrace<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
define_opaque_types: DefineOpaqueTypes,
|
||||
kind: LatticeOpKind,
|
||||
) -> LatticeOp<'infcx, 'tcx> {
|
||||
LatticeOp { infcx, trace, param_env, define_opaque_types, kind, obligations: vec![] }
|
||||
LatticeOp { infcx, trace, param_env, kind, obligations: vec![] }
|
||||
}
|
||||
|
||||
pub(crate) fn into_obligations(self) -> Vec<PredicateObligation<'tcx>> {
|
||||
@ -88,7 +86,7 @@ fn relate_with_variance<T: Relate<TyCtxt<'tcx>>>(
|
||||
self.obligations.extend(
|
||||
self.infcx
|
||||
.at(&self.trace.cause, self.param_env)
|
||||
.eq_trace(self.define_opaque_types, self.trace.clone(), a, b)?
|
||||
.eq_trace(DefineOpaqueTypes::Yes, self.trace.clone(), a, b)?
|
||||
.into_obligations(),
|
||||
);
|
||||
Ok(a)
|
||||
@ -154,9 +152,7 @@ fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
|
||||
|
||||
(&ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _)
|
||||
| (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }))
|
||||
if self.define_opaque_types == DefineOpaqueTypes::Yes
|
||||
&& def_id.is_local()
|
||||
&& !infcx.next_trait_solver() =>
|
||||
if def_id.is_local() && !infcx.next_trait_solver() =>
|
||||
{
|
||||
self.register_goals(infcx.handle_opaque_type(
|
||||
a,
|
||||
@ -235,12 +231,12 @@ fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResul
|
||||
let at = self.infcx.at(&self.trace.cause, self.param_env);
|
||||
match self.kind {
|
||||
LatticeOpKind::Glb => {
|
||||
self.obligations.extend(at.sub(self.define_opaque_types, v, a)?.into_obligations());
|
||||
self.obligations.extend(at.sub(self.define_opaque_types, v, b)?.into_obligations());
|
||||
self.obligations.extend(at.sub(DefineOpaqueTypes::Yes, v, a)?.into_obligations());
|
||||
self.obligations.extend(at.sub(DefineOpaqueTypes::Yes, v, b)?.into_obligations());
|
||||
}
|
||||
LatticeOpKind::Lub => {
|
||||
self.obligations.extend(at.sub(self.define_opaque_types, a, v)?.into_obligations());
|
||||
self.obligations.extend(at.sub(self.define_opaque_types, b, v)?.into_obligations());
|
||||
self.obligations.extend(at.sub(DefineOpaqueTypes::Yes, a, v)?.into_obligations());
|
||||
self.obligations.extend(at.sub(DefineOpaqueTypes::Yes, b, v)?.into_obligations());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user