Skip to content
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
tcx,
self.infcx.typing_env(self.infcx.param_env),
fn_did,
self.infcx.resolve_vars_if_possible(args.no_bound_vars().unwrap()),
self.infcx.deep_resolve_non_region_vars(args.no_bound_vars().unwrap()),
) else {
return;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub(crate) fn clone_and_resolve_opaque_types<'tcx>(
let opaque_types = opaque_types
.into_iter()
.map(|entry| {
fold_regions(infcx.tcx, infcx.resolve_vars_if_possible(entry), |r, _| {
fold_regions(infcx.tcx, infcx.deep_resolve_non_region_vars(entry), |r, _| {
let vid = if let ty::RePlaceholder(placeholder) = r.kind() {
constraints.placeholder_region(infcx, placeholder).as_var()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {

GenericArgKind::Type(mut t1) => {
// Scraped constraints may have had inference vars.
t1 = self.infcx.resolve_vars_if_possible(t1);
t1 = self.infcx.deep_resolve_non_region_vars(t1);

let implicit_region_bound =
ty::Region::new_var(tcx, universal_regions.implicit_region_bound());
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/relate_tys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl<'a, 'b, 'tcx> NllTypeRelating<'a, 'b, 'tcx> {
variance,
ty,
)?;
Ok(infcx.resolve_vars_if_possible(Ty::new_infer(infcx.tcx, ty::TyVar(ty_vid))))
Ok(infcx.deep_resolve_non_region_vars(Ty::new_infer(infcx.tcx, ty::TyVar(ty_vid))))
};

let (a, b) = match (a.kind(), b.kind()) {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_analysis/src/autoderef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> {
// and Deref, and this has benefits for const and the emitted MIR.
let (kind, new_ty) =
if let Some(ty) = self.state.cur_ty.builtin_deref(self.include_raw_pointers) {
debug_assert_eq!(ty, self.infcx.resolve_vars_if_possible(ty));
debug_assert_eq!(ty, self.infcx.deep_resolve_non_region_vars(ty));
(AutoderefKind::Builtin, ty)
} else if let Some(ty) = self.overloaded_deref_ty(self.state.cur_ty) {
// The overloaded deref check already normalizes the pointee type.
Expand Down Expand Up @@ -123,7 +123,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
param_env,
state: AutoderefSnapshot {
steps: vec![],
cur_ty: infcx.resolve_vars_if_possible(base_ty),
cur_ty: infcx.deep_resolve_non_region_vars(base_ty),
obligations: PredicateObligations::new(),
at_start: true,
reached_recursion_limit: false,
Expand Down Expand Up @@ -171,7 +171,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
debug!("overloaded_deref_ty({:?}) = ({:?}, {:?})", ty, normalized_ty, obligations);
self.state.obligations.extend(obligations);

Some(self.infcx.resolve_vars_if_possible(normalized_ty))
Some(self.infcx.deep_resolve_non_region_vars(normalized_ty))
}

#[instrument(level = "debug", skip(self), ret)]
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ fn check_opaque_meets_bounds<'tcx>(
} else {
// Check that any hidden types found during wf checking match the hidden types that `type_of` sees.
for (mut key, mut ty) in infcx.take_opaque_types() {
ty.ty = infcx.resolve_vars_if_possible(ty.ty);
key = infcx.resolve_vars_if_possible(key);
ty.ty = infcx.deep_resolve_non_region_vars(ty.ty);
key = infcx.deep_resolve_non_region_vars(key);
sanity_check_found_hidden_type(tcx, key, ty)?;
}
Ok(())
Expand Down Expand Up @@ -2301,8 +2301,8 @@ pub(super) fn check_coroutine_obligations(
// Check that any hidden types found when checking these stalled coroutine obligations
// are valid.
for (key, ty) in infcx.take_opaque_types() {
let hidden_type = infcx.resolve_vars_if_possible(ty);
let key = infcx.resolve_vars_if_possible(key);
let hidden_type = infcx.deep_resolve_non_region_vars(ty);
let key = infcx.deep_resolve_non_region_vars(key);
sanity_check_found_hidden_type(tcx, key, hidden_type)?;
}
} else {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
.iter()
.map(|(_, &(ty, _))| {
assert!(
infcx.resolve_vars_if_possible(ty) == ty && ty.is_ty_var(),
infcx.deep_resolve_non_region_vars(ty) == ty && ty.is_ty_var(),
"{ty:?} should not have been constrained via normalization",
ty = infcx.resolve_vars_if_possible(ty)
ty = infcx.deep_resolve_non_region_vars(ty)
);
idx += 1;
(
Expand Down Expand Up @@ -1296,7 +1296,7 @@ fn check_region_late_boundedness<'tcx>(
.inner
.borrow_mut()
.unwrap_region_constraints()
.opportunistic_resolve_var(tcx, vid)
.shallow_resolve_region_var(tcx, vid)
&& let ty::ReLateParam(ty::LateParamRegion {
kind: ty::LateParamRegionKind::Named(trait_param_def_id),
..
Expand All @@ -1321,7 +1321,7 @@ fn check_region_late_boundedness<'tcx>(
.inner
.borrow_mut()
.unwrap_region_constraints()
.opportunistic_resolve_var(tcx, vid)
.shallow_resolve_region_var(tcx, vid)
&& let ty::ReLateParam(ty::LateParamRegion {
kind: ty::LateParamRegionKind::Named(impl_param_def_id),
..
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ fn orphan_check<'tcx>(

let ocx = traits::ObligationCtxt::new(&infcx);
let ty = ocx.normalize(&cause, ty::ParamEnv::empty(), Unnormalized::new_wip(user_ty));
let ty = infcx.resolve_vars_if_possible(ty);
let ty = infcx.deep_resolve_non_region_vars(ty);
let errors = ocx.try_evaluate_obligations();
if !errors.no_errors() {
return Ok(user_ty);
Expand Down Expand Up @@ -374,7 +374,7 @@ fn orphan_check<'tcx>(
id_arg,
);
}
infcx.resolve_vars_if_possible(tys)
infcx.deep_resolve_non_region_vars(tys)
});
OrphanCheckErr::NonLocalInputType(tys)
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1374,11 +1374,11 @@ pub fn suggest_impl_trait<'tcx>(
);
// FIXME(compiler-errors): We may benefit from resolving regions here.
if ocx.try_evaluate_obligations().no_errors()
&& let item_ty = infcx.resolve_vars_if_possible(item_ty)
&& let item_ty = infcx.deep_resolve_non_region_vars(item_ty)
&& let Some(item_ty) = item_ty.make_suggestable(infcx.tcx, false, None)
&& let Some(sugg) = formatter(
infcx.tcx,
infcx.resolve_vars_if_possible(args),
infcx.deep_resolve_non_region_vars(args),
trait_def_id,
assoc_item_def_id,
item_ty,
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => self.check_expr(callee_expr),
};

let expr_ty = self.resolve_vars_with_obligations(original_callee_ty);
let expr_ty = self.deep_resolve_non_regionvars_with_obligations(original_callee_ty);

let mut autoderef = self.autoderef(callee_expr.span, expr_ty);
let mut result = None;
Expand Down Expand Up @@ -237,7 +237,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
arg_exprs: &'tcx [hir::Expr<'tcx>],
autoderef: &Autoderef<'a, 'tcx>,
) -> Option<CallStep<'tcx>> {
let adjusted_ty = self.resolve_vars_with_obligations(autoderef.final_ty());
let adjusted_ty = self.deep_resolve_non_regionvars_with_obligations(autoderef.final_ty());

// If the callee is a function pointer or a closure, then we're all set.
match *adjusted_ty.kind() {
Expand Down Expand Up @@ -736,7 +736,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return do_check();
}

resolved_inputs = self.resolve_vars_if_possible(formal_input_tys.to_vec());
resolved_inputs = self.deep_resolve_non_region_vars(formal_input_tys.to_vec());
}

// Fool typechecker by placing an adjusted type of the first arg to avoid errors.
Expand Down Expand Up @@ -873,7 +873,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(rest_span, format!(").{}({rest_snippet}", segment.ident)),
]
};
let self_ty = self.resolve_vars_if_possible(pick.callee.sig.inputs()[0]);
let self_ty = self.deep_resolve_non_region_vars(pick.callee.sig.inputs()[0]);
diag.multipart_suggestion(
format!(
"use the `.` operator to call the method `{}{}` on `{self_ty}`",
Expand Down Expand Up @@ -925,7 +925,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Some((removal_span, descr, rustc_hir_pretty::qpath_to_string(self, qpath)));
}

let callee_ty = self.resolve_vars_if_possible(callee_ty);
let callee_ty = self.deep_resolve_non_region_vars(callee_ty);
let mut path = None;
let mut err = self.dcx().create_err(diagnostics::InvalidCallee {
span: callee_expr.span,
Expand Down
36 changes: 18 additions & 18 deletions compiler/rustc_hir_typeck/src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) -> Result<Option<PointerKind<'tcx>>, ErrorGuaranteed> {
debug!("pointer_kind({:?}, {:?})", t, span);

let t = self.resolve_vars_if_possible(t);
let t = self.deep_resolve_non_region_vars(t);
t.error_reported()?;

if self.type_is_sized_modulo_regions(self.param_env, t) {
return Ok(Some(PointerKind::Thin));
}

let t = self.resolve_vars_with_obligations(t);
let t = self.deep_resolve_non_regionvars_with_obligations(t);

Ok(match *t.kind() {
ty::Slice(_) | ty::Str => Some(PointerKind::Length),
Expand Down Expand Up @@ -394,7 +394,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
err.emit();
}
CastError::CastToBool => {
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
let expr_ty = fcx.deep_resolve_non_region_vars(self.expr_ty);
let help = if self.expr_ty.is_numeric() {
diagnostics::CannotCastToBoolHelp::Numeric(
self.expr_span.shrink_to_hi().with_hi(self.span.hi()),
Expand Down Expand Up @@ -537,8 +537,8 @@ impl<'a, 'tcx> CastCheck<'tcx> {
) {
// Check `impl From<self.expr_ty> for self.cast_ty {}` for accurate suggestion:
if let Some(from_trait) = fcx.tcx.get_diagnostic_item(sym::From) {
let ty = fcx.resolve_vars_if_possible(self.cast_ty);
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
let ty = fcx.deep_resolve_non_region_vars(self.cast_ty);
let expr_ty = fcx.deep_resolve_non_region_vars(self.expr_ty);
if fcx
.infcx
.type_implements_trait(from_trait, [ty, expr_ty], fcx.param_env)
Expand Down Expand Up @@ -602,8 +602,8 @@ impl<'a, 'tcx> CastCheck<'tcx> {
err.emit();
}
CastError::SizedUnsizedCast => {
let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty);
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
let cast_ty = fcx.deep_resolve_non_region_vars(self.cast_ty);
let expr_ty = fcx.deep_resolve_non_region_vars(self.expr_ty);
fcx.dcx().emit_err(diagnostics::CastThinPointerToWidePointer {
span: self.span,
expr_ty,
Expand All @@ -613,8 +613,8 @@ impl<'a, 'tcx> CastCheck<'tcx> {
}
CastError::IntToWideCast(known_metadata) => {
let expr_if_nightly = fcx.tcx.sess.is_nightly_build().then_some(self.expr_span);
let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty);
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
let cast_ty = fcx.deep_resolve_non_region_vars(self.cast_ty);
let expr_ty = fcx.deep_resolve_non_region_vars(self.expr_ty);
let metadata = known_metadata.unwrap_or("type-specific metadata");
let known_wide = known_metadata.is_some();
let span = self.cast_span;
Expand Down Expand Up @@ -657,8 +657,8 @@ impl<'a, 'tcx> CastCheck<'tcx> {
});
}
CastError::CastEnumDrop => {
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty);
let expr_ty = fcx.deep_resolve_non_region_vars(self.expr_ty);
let cast_ty = fcx.deep_resolve_non_region_vars(self.cast_ty);

fcx.dcx().emit_err(diagnostics::CastEnumDrop { span: self.span, expr_ty, cast_ty });
}
Expand Down Expand Up @@ -705,7 +705,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
self.expr_ty,
E0620,
"cast to unsized type: `{}` as `{}`",
fcx.resolve_vars_if_possible(self.expr_ty),
fcx.deep_resolve_non_region_vars(self.expr_ty),
tstr
);
match self.expr_ty.kind() {
Expand Down Expand Up @@ -745,8 +745,8 @@ impl<'a, 'tcx> CastCheck<'tcx> {
} else {
(false, lint::builtin::TRIVIAL_CASTS)
};
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty);
let expr_ty = fcx.deep_resolve_non_region_vars(self.expr_ty);
let cast_ty = fcx.deep_resolve_non_region_vars(self.cast_ty);
fcx.tcx.emit_node_span_lint(
lint,
self.expr.hir_id,
Expand Down Expand Up @@ -786,8 +786,8 @@ impl<'a, 'tcx> CastCheck<'tcx> {

fn expr_span_for_type_resolution(&self, fcx: &FnCtxt<'a, 'tcx>) -> Span {
if let hir::ExprKind::Index(_, idx, _) = self.expr.kind
&& fcx.resolve_vars_if_possible(self.expr_ty).is_ty_var()
&& fcx.resolve_vars_if_possible(fcx.node_ty(idx.hir_id)).is_ty_var()
&& fcx.deep_resolve_non_region_vars(self.expr_ty).is_ty_var()
&& fcx.deep_resolve_non_region_vars(fcx.node_ty(idx.hir_id)).is_ty_var()
{
index_operand_ambiguity_span(idx)
} else {
Expand Down Expand Up @@ -1134,8 +1134,8 @@ impl<'a, 'tcx> CastCheck<'tcx> {
mut m_cast: ty::TypeAndMut<'tcx>,
) -> Result<CastKind, CastError<'tcx>> {
// array-ptr-cast: allow mut-to-mut, mut-to-const, const-to-const
m_expr.ty = fcx.resolve_vars_with_obligations(m_expr.ty);
m_cast.ty = fcx.resolve_vars_with_obligations(m_cast.ty);
m_expr.ty = fcx.deep_resolve_non_regionvars_with_obligations(m_expr.ty);
m_cast.ty = fcx.deep_resolve_non_regionvars_with_obligations(m_cast.ty);

if m_expr.mutbl >= m_cast.mutbl
&& let ty::Array(ety, _) = m_expr.ty.kind()
Expand Down
Loading
Loading