Rename probe_ty_var to try_resolve_ty_var

Co-authored-by: khyperia <953151+khyperia@users.noreply.github.com>
This commit is contained in:
Jana Dönszelmann
2026-03-30 13:08:08 +02:00
parent 8931f23941
commit 28b06a67b3
5 changed files with 16 additions and 13 deletions
@@ -341,7 +341,7 @@ fn fold_ty(&mut self, mut t: Ty<'tcx>) -> Ty<'tcx> {
}
debug!("canonical: type var found with vid {:?}", vid);
match self.infcx.unwrap().probe_ty_var(vid) {
match self.infcx.unwrap().try_resolve_ty_var(vid) {
// `t` could be a float / int variable; canonicalize that instead.
Ok(t) => {
debug!("(resolved to {:?})", t);
@@ -443,7 +443,7 @@ fn fold_const(&mut self, mut ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
}
debug!("canonical: const var found with vid {:?}", vid);
match self.infcx.unwrap().probe_const_var(vid) {
match self.infcx.unwrap().try_resolve_const_var(vid) {
Ok(c) => {
debug!("(resolved to {:?})", c);
return self.fold_const(c);
+6 -6
View File
@@ -35,7 +35,7 @@ fn create_next_universe(&self) -> ty::UniverseIndex {
}
fn universe_of_ty(&self, vid: ty::TyVid) -> Option<ty::UniverseIndex> {
match self.probe_ty_var(vid) {
match self.try_resolve_ty_var(vid) {
Err(universe) => Some(universe),
Ok(_) => None,
}
@@ -49,7 +49,7 @@ fn universe_of_lt(&self, lt: ty::RegionVid) -> Option<ty::UniverseIndex> {
}
fn universe_of_ct(&self, ct: ty::ConstVid) -> Option<ty::UniverseIndex> {
match self.probe_const_var(ct) {
match self.try_resolve_const_var(ct) {
Err(universe) => Some(universe),
Ok(_) => None,
}
@@ -68,7 +68,7 @@ fn root_const_var(&self, var: ty::ConstVid) -> ty::ConstVid {
}
fn opportunistic_resolve_ty_var(&self, vid: ty::TyVid) -> Ty<'tcx> {
match self.probe_ty_var(vid) {
match self.try_resolve_ty_var(vid) {
Ok(ty) => ty,
Err(_) => Ty::new_var(self.tcx, self.root_var(vid)),
}
@@ -83,7 +83,7 @@ fn opportunistic_resolve_float_var(&self, vid: ty::FloatVid) -> Ty<'tcx> {
}
fn opportunistic_resolve_ct_var(&self, vid: ty::ConstVid) -> ty::Const<'tcx> {
match self.probe_const_var(vid) {
match self.try_resolve_const_var(vid) {
Ok(ct) => ct,
Err(_) => ty::Const::new_var(self.tcx, self.root_const_var(vid)),
}
@@ -103,7 +103,7 @@ fn is_changed_arg(&self, arg: ty::GenericArg<'tcx>) -> bool {
if let ty::Infer(infer_ty) = *ty.kind() {
match infer_ty {
ty::InferTy::TyVar(vid) => {
!self.probe_ty_var(vid).is_err_and(|_| self.root_var(vid) == vid)
!self.try_resolve_ty_var(vid).is_err_and(|_| self.root_var(vid) == vid)
}
ty::InferTy::IntVar(vid) => {
let mut inner = self.inner.borrow_mut();
@@ -133,7 +133,7 @@ fn is_changed_arg(&self, arg: ty::GenericArg<'tcx>) -> bool {
if let ty::ConstKind::Infer(infer_ct) = ct.kind() {
match infer_ct {
ty::InferConst::Var(vid) => !self
.probe_const_var(vid)
.try_resolve_const_var(vid)
.is_err_and(|_| self.root_const_var(vid) == vid),
ty::InferConst::Fresh(_) => true,
}
+5 -2
View File
@@ -1074,7 +1074,7 @@ pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
/// If `TyVar(vid)` resolves to a type, return that type. Else, return the
/// universe index of `TyVar(vid)`.
pub fn probe_ty_var(&self, vid: TyVid) -> Result<Ty<'tcx>, ty::UniverseIndex> {
pub fn try_resolve_ty_var(&self, vid: TyVid) -> Result<Ty<'tcx>, ty::UniverseIndex> {
use self::type_variable::TypeVariableValue;
match self.inner.borrow_mut().type_variables().probe(vid) {
@@ -1228,7 +1228,10 @@ pub fn resolve_numeric_literals_with_default<T>(&self, value: T) -> T
value.fold_with(&mut r)
}
pub fn probe_const_var(&self, vid: ty::ConstVid) -> Result<ty::Const<'tcx>, ty::UniverseIndex> {
pub fn try_resolve_const_var(
&self,
vid: ty::ConstVid,
) -> Result<ty::Const<'tcx>, ty::UniverseIndex> {
match self.inner.borrow_mut().const_unification_table().probe_value(vid) {
ConstVariableValue::Known { value } => Ok(value),
ConstVariableValue::Unknown { origin: _, universe } => Err(universe),
@@ -300,10 +300,10 @@ fn generalize(
assert!(!source_term.has_escaping_bound_vars());
let (for_universe, root_vid) = match target_vid {
TermVid::Ty(ty_vid) => {
(self.probe_ty_var(ty_vid).unwrap_err(), TermVid::Ty(self.root_var(ty_vid)))
(self.try_resolve_ty_var(ty_vid).unwrap_err(), TermVid::Ty(self.root_var(ty_vid)))
}
TermVid::Const(ct_vid) => (
self.probe_const_var(ct_vid).unwrap_err(),
self.try_resolve_const_var(ct_vid).unwrap_err(),
TermVid::Const(self.inner.borrow_mut().const_unification_table().find(ct_vid).vid),
),
};
@@ -255,7 +255,7 @@ fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
fn fmt_printer<'a, 'tcx>(infcx: &'a InferCtxt<'tcx>, ns: Namespace) -> FmtPrinter<'a, 'tcx> {
let mut p = FmtPrinter::new(infcx.tcx, ns);
let ty_getter = move |ty_vid| {
if infcx.probe_ty_var(ty_vid).is_ok() {
if infcx.try_resolve_ty_var(ty_vid).is_ok() {
warn!("resolved ty var in error message");
}