Repository: rust-lang/rust
Pull request: Rename `probe_ty_var` to `try_resolve_ty_var`

<!-- homu-ignore:start -->
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r? <reviewer name>
-->
<!-- homu-ignore:end -->
r? @lcnr

Changed files:
filename: compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
patch: @@ -341,7 +341,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, '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 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, '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);

filename: compiler/rustc_infer/src/infer/context.rs
patch: @@ -35,7 +35,7 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
     }
 
     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 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
     }
 
     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 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
     }
 
     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 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'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 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
                 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 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
                 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,
                     }

filename: compiler/rustc_infer/src/infer/mod.rs
patch: @@ -1074,7 +1074,7 @@ impl<'tcx> InferCtxt<'tcx> {
 
     /// 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 @@ impl<'tcx> InferCtxt<'tcx> {
         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),

filename: compiler/rustc_infer/src/infer/relate/generalize.rs
patch: @@ -300,10 +300,10 @@ impl<'tcx> InferCtxt<'tcx> {
         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),
             ),
         };

filename: compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs
patch: @@ -255,7 +255,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ClosureEraser<'a, '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");
         }