about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Diebold <flodiebold@gmail.com>2022-03-17 17:08:43 +0100
committerFlorian Diebold <flodiebold@gmail.com>2022-03-17 17:08:43 +0100
commit60aeb8fa1a0432e50d880c8ba76cdea8f9344995 (patch)
tree0857e2fb325315bfb825056bf36fef98568184d2
parent9ea2e0bd5bdbc60de16e212434df06831551fa08 (diff)
downloadrust-60aeb8fa1a0432e50d880c8ba76cdea8f9344995.tar.gz
rust-60aeb8fa1a0432e50d880c8ba76cdea8f9344995.zip
Move fallback_bound_vars to the only place it's used now
-rw-r--r--crates/hir_ty/src/lower.rs28
-rw-r--r--crates/hir_ty/src/method_resolution.rs28
2 files changed, 28 insertions, 28 deletions
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index 0854d065483..41bb94c5d55 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -9,6 +9,8 @@ use std::cell::{Cell, RefCell};
 use std::{iter, sync::Arc};
 
 use base_db::CrateId;
+use chalk_ir::fold::Fold;
+use chalk_ir::interner::HasInterner;
 use chalk_ir::{cast::Cast, fold::Shift, Mutability, Safety};
 use hir_def::generics::TypeOrConstParamData;
 use hir_def::intern::Interned;
@@ -36,7 +38,6 @@ use stdx::{impl_from, never};
 use syntax::{ast, SmolStr};
 
 use crate::consteval::{path_to_const, unknown_const_as_generic, unknown_const_usize, usize_const};
-use crate::method_resolution::fallback_bound_vars;
 use crate::utils::Generics;
 use crate::{all_super_traits, make_binders, Const, GenericArgData, ParamKind};
 use crate::{
@@ -1701,3 +1702,28 @@ pub(crate) fn const_or_path_to_chalk(
         }
     }
 }
+
+/// This replaces any 'free' Bound vars in `s` (i.e. those with indices past
+/// num_vars_to_keep) by `TyKind::Unknown`.
+fn fallback_bound_vars<T: Fold<Interner> + HasInterner<Interner = Interner>>(
+    s: T,
+    num_vars_to_keep: usize,
+) -> T::Result {
+    crate::fold_free_vars(
+        s,
+        |bound, binders| {
+            if bound.index >= num_vars_to_keep && bound.debruijn == DebruijnIndex::INNERMOST {
+                TyKind::Error.intern(Interner)
+            } else {
+                bound.shifted_in_from(binders).to_ty(Interner)
+            }
+        },
+        |ty, bound, binders| {
+            if bound.index >= num_vars_to_keep && bound.debruijn == DebruijnIndex::INNERMOST {
+                consteval::unknown_const(ty.clone())
+            } else {
+                bound.shifted_in_from(binders).to_const(Interner, ty)
+            }
+        },
+    )
+}
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs
index 9120f80e2c5..1c939f3d8aa 100644
--- a/crates/hir_ty/src/method_resolution.rs
+++ b/crates/hir_ty/src/method_resolution.rs
@@ -6,7 +6,7 @@ use std::{iter, ops::ControlFlow, sync::Arc};
 
 use arrayvec::ArrayVec;
 use base_db::{CrateId, Edition};
-use chalk_ir::{cast::Cast, fold::Fold, interner::HasInterner, Mutability, UniverseIndex};
+use chalk_ir::{cast::Cast, Mutability, UniverseIndex};
 use hir_def::{
     item_scope::ItemScope, lang_item::LangItemTarget, nameres::DefMap, AssocItemId, BlockId,
     ConstId, FunctionId, GenericDefId, HasModule, ImplId, ItemContainerId, Lookup, ModuleDefId,
@@ -18,7 +18,6 @@ use stdx::never;
 
 use crate::{
     autoderef::{self, AutoderefKind},
-    consteval,
     db::HirDatabase,
     from_foreign_def_id,
     infer::{unify::InferenceTable, Adjust, Adjustment, AutoBorrow, OverloadedDeref, PointerCast},
@@ -1061,31 +1060,6 @@ fn is_valid_candidate(
     }
 }
 
-/// This replaces any 'free' Bound vars in `s` (i.e. those with indices past
-/// num_vars_to_keep) by `TyKind::Unknown`.
-pub(crate) fn fallback_bound_vars<T: Fold<Interner> + HasInterner<Interner = Interner>>(
-    s: T,
-    num_vars_to_keep: usize,
-) -> T::Result {
-    crate::fold_free_vars(
-        s,
-        |bound, binders| {
-            if bound.index >= num_vars_to_keep && bound.debruijn == DebruijnIndex::INNERMOST {
-                TyKind::Error.intern(Interner)
-            } else {
-                bound.shifted_in_from(binders).to_ty(Interner)
-            }
-        },
-        |ty, bound, binders| {
-            if bound.index >= num_vars_to_keep && bound.debruijn == DebruijnIndex::INNERMOST {
-                consteval::usize_const(None)
-            } else {
-                bound.shifted_in_from(binders).to_const(Interner, ty)
-            }
-        },
-    )
-}
-
 pub fn implements_trait(
     ty: &Canonical<Ty>,
     db: &dyn HirDatabase,