From 28b06a67b36694f5840773f8b128104b09d4a700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Mon, 30 Mar 2026 13:08:08 +0200 Subject: [PATCH] Rename probe_ty_var to try_resolve_ty_var Co-authored-by: khyperia <953151+khyperia@users.noreply.github.com> --- .../rustc_infer/src/infer/canonical/canonicalizer.rs | 4 ++-- compiler/rustc_infer/src/infer/context.rs | 12 ++++++------ compiler/rustc_infer/src/infer/mod.rs | 7 +++++-- compiler/rustc_infer/src/infer/relate/generalize.rs | 4 ++-- .../src/error_reporting/infer/need_type_info.rs | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index 89ea6324d854..87d389a5dea5 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -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); diff --git a/compiler/rustc_infer/src/infer/context.rs b/compiler/rustc_infer/src/infer/context.rs index 09403513aa08..fada30ff3063 100644 --- a/compiler/rustc_infer/src/infer/context.rs +++ b/compiler/rustc_infer/src/infer/context.rs @@ -35,7 +35,7 @@ fn create_next_universe(&self) -> ty::UniverseIndex { } fn universe_of_ty(&self, vid: ty::TyVid) -> Option { - 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 { } fn universe_of_ct(&self, ct: ty::ConstVid) -> Option { - 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, } diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index e15b25500bb5..2057eeb87597 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -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::UniverseIndex> { + pub fn try_resolve_ty_var(&self, vid: TyVid) -> Result, 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(&self, value: T) -> T value.fold_with(&mut r) } - pub fn probe_const_var(&self, vid: ty::ConstVid) -> Result, ty::UniverseIndex> { + pub fn try_resolve_const_var( + &self, + vid: ty::ConstVid, + ) -> Result, ty::UniverseIndex> { match self.inner.borrow_mut().const_unification_table().probe_value(vid) { ConstVariableValue::Known { value } => Ok(value), ConstVariableValue::Unknown { origin: _, universe } => Err(universe), diff --git a/compiler/rustc_infer/src/infer/relate/generalize.rs b/compiler/rustc_infer/src/infer/relate/generalize.rs index 3ab39e83f312..0b29421a8da8 100644 --- a/compiler/rustc_infer/src/infer/relate/generalize.rs +++ b/compiler/rustc_infer/src/infer/relate/generalize.rs @@ -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), ), }; diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs index 46bc9bdee04b..d891cb3fb800 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs @@ -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"); }