Rollup merge of #104907 - compiler-errors:selcx-infcx, r=oli-obk
Remove `SelectionContext::infcx()` in favor of field access Encapsulation doesn't seem particularly important here, and having two choices is always more confusing than having one. r? types
This commit is contained in:
commit
9178bc059f
8 changed files with 75 additions and 92 deletions
|
@ -599,17 +599,17 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
computed_preds: &mut FxIndexSet<ty::Predicate<'tcx>>,
|
||||
fresh_preds: &mut FxHashSet<ty::Predicate<'tcx>>,
|
||||
predicates: &mut VecDeque<ty::PolyTraitPredicate<'tcx>>,
|
||||
select: &mut SelectionContext<'_, 'tcx>,
|
||||
selcx: &mut SelectionContext<'_, 'tcx>,
|
||||
only_projections: bool,
|
||||
) -> bool {
|
||||
let dummy_cause = ObligationCause::dummy();
|
||||
|
||||
for obligation in nested {
|
||||
let is_new_pred =
|
||||
fresh_preds.insert(self.clean_pred(select.infcx(), obligation.predicate));
|
||||
fresh_preds.insert(self.clean_pred(selcx.infcx, obligation.predicate));
|
||||
|
||||
// Resolve any inference variables that we can, to help selection succeed
|
||||
let predicate = select.infcx().resolve_vars_if_possible(obligation.predicate);
|
||||
let predicate = selcx.infcx.resolve_vars_if_possible(obligation.predicate);
|
||||
|
||||
// We only add a predicate as a user-displayable bound if
|
||||
// it involves a generic parameter, and doesn't contain
|
||||
|
@ -717,10 +717,8 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
// and turn them into an explicit negative impl for our type.
|
||||
debug!("Projecting and unifying projection predicate {:?}", predicate);
|
||||
|
||||
match project::poly_project_and_unify_type(
|
||||
select,
|
||||
&obligation.with(self.tcx, p),
|
||||
) {
|
||||
match project::poly_project_and_unify_type(selcx, &obligation.with(self.tcx, p))
|
||||
{
|
||||
ProjectAndUnifyResult::MismatchedProjectionTypes(e) => {
|
||||
debug!(
|
||||
"evaluate_nested_obligations: Unable to unify predicate \
|
||||
|
@ -745,7 +743,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
computed_preds,
|
||||
fresh_preds,
|
||||
predicates,
|
||||
select,
|
||||
selcx,
|
||||
only_projections,
|
||||
) {
|
||||
return false;
|
||||
|
@ -768,7 +766,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(binder)) => {
|
||||
let binder = bound_predicate.rebind(binder);
|
||||
select.infcx().region_outlives_predicate(&dummy_cause, binder)
|
||||
selcx.infcx.region_outlives_predicate(&dummy_cause, binder)
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(binder)) => {
|
||||
let binder = bound_predicate.rebind(binder);
|
||||
|
@ -777,14 +775,14 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
binder.map_bound_ref(|pred| pred.0).no_bound_vars(),
|
||||
) {
|
||||
(None, Some(t_a)) => {
|
||||
select.infcx().register_region_obligation_with_cause(
|
||||
selcx.infcx.register_region_obligation_with_cause(
|
||||
t_a,
|
||||
select.infcx().tcx.lifetimes.re_static,
|
||||
selcx.infcx.tcx.lifetimes.re_static,
|
||||
&dummy_cause,
|
||||
);
|
||||
}
|
||||
(Some(ty::OutlivesPredicate(t_a, r_b)), _) => {
|
||||
select.infcx().register_region_obligation_with_cause(
|
||||
selcx.infcx.register_region_obligation_with_cause(
|
||||
t_a,
|
||||
r_b,
|
||||
&dummy_cause,
|
||||
|
@ -796,13 +794,13 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
ty::PredicateKind::ConstEquate(c1, c2) => {
|
||||
let evaluate = |c: ty::Const<'tcx>| {
|
||||
if let ty::ConstKind::Unevaluated(unevaluated) = c.kind() {
|
||||
match select.infcx().const_eval_resolve(
|
||||
match selcx.infcx.const_eval_resolve(
|
||||
obligation.param_env,
|
||||
unevaluated,
|
||||
Some(obligation.cause.span),
|
||||
) {
|
||||
Ok(Some(valtree)) => {
|
||||
Ok(ty::Const::from_value(select.tcx(), valtree, c.ty()))
|
||||
Ok(ty::Const::from_value(selcx.tcx(), valtree, c.ty()))
|
||||
}
|
||||
Ok(None) => {
|
||||
let tcx = self.tcx;
|
||||
|
@ -823,10 +821,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
|
||||
match (evaluate(c1), evaluate(c2)) {
|
||||
(Ok(c1), Ok(c2)) => {
|
||||
match select
|
||||
.infcx()
|
||||
.at(&obligation.cause, obligation.param_env)
|
||||
.eq(c1, c2)
|
||||
match selcx.infcx.at(&obligation.cause, obligation.param_env).eq(c1, c2)
|
||||
{
|
||||
Ok(_) => (),
|
||||
Err(_) => return false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue