Rename Ty::interned to Ty::kind

... since that's the actual method on Chalk side that matches the signature.
This commit is contained in:
Florian Diebold 2021-04-03 13:08:29 +02:00
parent 8289b96216
commit c551604b5a
17 changed files with 73 additions and 75 deletions

View File

@ -1711,22 +1711,22 @@ impl Type {
}
pub fn is_unit(&self) -> bool {
matches!(self.ty.interned(&Interner), TyKind::Tuple(0, ..))
matches!(self.ty.kind(&Interner), TyKind::Tuple(0, ..))
}
pub fn is_bool(&self) -> bool {
matches!(self.ty.interned(&Interner), TyKind::Scalar(Scalar::Bool))
matches!(self.ty.kind(&Interner), TyKind::Scalar(Scalar::Bool))
}
pub fn is_mutable_reference(&self) -> bool {
matches!(self.ty.interned(&Interner), TyKind::Ref(hir_ty::Mutability::Mut, ..))
matches!(self.ty.kind(&Interner), TyKind::Ref(hir_ty::Mutability::Mut, ..))
}
pub fn is_usize(&self) -> bool {
matches!(self.ty.interned(&Interner), TyKind::Scalar(Scalar::Uint(UintTy::Usize)))
matches!(self.ty.kind(&Interner), TyKind::Scalar(Scalar::Uint(UintTy::Usize)))
}
pub fn remove_ref(&self) -> Option<Type> {
match &self.ty.interned(&Interner) {
match &self.ty.kind(&Interner) {
TyKind::Ref(.., ty) => Some(self.derived(ty.clone())),
_ => None,
}
@ -1855,15 +1855,15 @@ impl Type {
}
pub fn is_closure(&self) -> bool {
matches!(&self.ty.interned(&Interner), TyKind::Closure { .. })
matches!(&self.ty.kind(&Interner), TyKind::Closure { .. })
}
pub fn is_fn(&self) -> bool {
matches!(&self.ty.interned(&Interner), TyKind::FnDef(..) | TyKind::Function { .. })
matches!(&self.ty.kind(&Interner), TyKind::FnDef(..) | TyKind::Function { .. })
}
pub fn is_packed(&self, db: &dyn HirDatabase) -> bool {
let adt_id = match self.ty.interned(&Interner) {
let adt_id = match self.ty.kind(&Interner) {
&TyKind::Adt(hir_ty::AdtId(adt_id), ..) => adt_id,
_ => return false,
};
@ -1876,14 +1876,14 @@ impl Type {
}
pub fn is_raw_ptr(&self) -> bool {
matches!(&self.ty.interned(&Interner), TyKind::Raw(..))
matches!(&self.ty.kind(&Interner), TyKind::Raw(..))
}
pub fn contains_unknown(&self) -> bool {
return go(&self.ty);
fn go(ty: &Ty) -> bool {
match ty.interned(&Interner) {
match ty.kind(&Interner) {
TyKind::Unknown => true,
TyKind::Adt(_, substs)
@ -1914,7 +1914,7 @@ impl Type {
}
pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(Field, Type)> {
let (variant_id, substs) = match self.ty.interned(&Interner) {
let (variant_id, substs) = match self.ty.kind(&Interner) {
&TyKind::Adt(hir_ty::AdtId(AdtId::StructId(s)), ref substs) => (s.into(), substs),
&TyKind::Adt(hir_ty::AdtId(AdtId::UnionId(u)), ref substs) => (u.into(), substs),
_ => return Vec::new(),
@ -1931,7 +1931,7 @@ impl Type {
}
pub fn tuple_fields(&self, _db: &dyn HirDatabase) -> Vec<Type> {
if let TyKind::Tuple(_, substs) = &self.ty.interned(&Interner) {
if let TyKind::Tuple(_, substs) = &self.ty.kind(&Interner) {
substs
.iter(&Interner)
.map(|ty| self.derived(ty.assert_ty_ref(&Interner).clone()))
@ -2120,7 +2120,7 @@ impl Type {
fn walk_type(db: &dyn HirDatabase, type_: &Type, cb: &mut impl FnMut(Type)) {
let ty = type_.ty.strip_references();
match ty.interned(&Interner) {
match ty.kind(&Interner) {
TyKind::Adt(..) => {
cb(type_.derived(ty.clone()));
}

View File

@ -131,7 +131,7 @@ fn deref_by_trait(
// new variables in that case
for i in 1..vars.0.binders.len(&Interner) {
if vars.0.value.at(&Interner, i - 1).assert_ty_ref(&Interner).interned(&Interner)
if vars.0.value.at(&Interner, i - 1).assert_ty_ref(&Interner).kind(&Interner)
!= &TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, i - 1))
{
warn!("complex solution for derefing {:?}: {:?}, ignoring", ty.goal, solution);

View File

@ -378,7 +378,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
_ => return,
};
let (params, required) = match mismatch.expected.interned(&Interner) {
let (params, required) = match mismatch.expected.kind(&Interner) {
TyKind::Adt(AdtId(hir_def::AdtId::EnumId(enum_id)), ref parameters)
if *enum_id == core_result_enum =>
{

View File

@ -626,7 +626,7 @@ pub(super) fn is_useful(
// - enum with no variants
// - `!` type
// In those cases, no match arm is useful.
match cx.infer[cx.match_expr].strip_references().interned(&Interner) {
match cx.infer[cx.match_expr].strip_references().kind(&Interner) {
TyKind::Adt(AdtId(hir_def::AdtId::EnumId(enum_id)), ..) => {
if cx.db.enum_data(*enum_id).variants.is_empty() {
return Ok(Usefulness::NotUseful);

View File

@ -110,7 +110,7 @@ fn walk_unsafe(
}
}
Expr::UnaryOp { expr, op: UnaryOp::Deref } => {
if let TyKind::Raw(..) = &infer[*expr].interned(&Interner) {
if let TyKind::Raw(..) = &infer[*expr].kind(&Interner) {
unsafe_exprs.push(UnsafeExpr { expr: current, inside_unsafe_block });
}
}

View File

@ -292,7 +292,7 @@ impl HirDisplay for Ty {
return write!(f, "{}", TYPE_HINT_TRUNCATION);
}
match self.interned(&Interner) {
match self.kind(&Interner) {
TyKind::Never => write!(f, "!")?,
TyKind::Str => write!(f, "str")?,
TyKind::Scalar(Scalar::Bool) => write!(f, "bool")?,
@ -314,7 +314,7 @@ impl HirDisplay for Ty {
let ty_display =
t.into_displayable(f.db, f.max_size, f.omit_verbose_types, f.display_target);
if matches!(self.interned(&Interner), TyKind::Raw(..)) {
if matches!(self.kind(&Interner), TyKind::Raw(..)) {
write!(
f,
"*{}",
@ -336,7 +336,7 @@ impl HirDisplay for Ty {
// FIXME: all this just to decide whether to use parentheses...
let datas;
let predicates: Vec<_> = match t.interned(&Interner) {
let predicates: Vec<_> = match t.kind(&Interner) {
TyKind::Dyn(dyn_ty) if dyn_ty.bounds.skip_binders().interned().len() > 1 => {
dyn_ty.bounds.skip_binders().interned().iter().cloned().collect()
}
@ -473,7 +473,7 @@ impl HirDisplay for Ty {
let mut default_from = 0;
for (i, parameter) in parameters.iter(&Interner).enumerate() {
match (
parameter.assert_ty_ref(&Interner).interned(&Interner),
parameter.assert_ty_ref(&Interner).kind(&Interner),
default_parameters.get(i),
) {
(&TyKind::Unknown, _) | (_, None) => {

View File

@ -325,7 +325,7 @@ impl<'a> InferenceContext<'a> {
/// Replaces Ty::Unknown by a new type var, so we can maybe still infer it.
fn insert_type_vars_shallow(&mut self, ty: Ty) -> Ty {
match ty.interned(&Interner) {
match ty.kind(&Interner) {
TyKind::Unknown => self.table.new_type_var(),
_ => ty,
}
@ -438,7 +438,7 @@ impl<'a> InferenceContext<'a> {
/// to do it as well.
fn normalize_associated_types_in(&mut self, ty: Ty) -> Ty {
let ty = self.resolve_ty_as_possible(ty);
ty.fold(&mut |ty| match ty.interned(&Interner) {
ty.fold(&mut |ty| match ty.kind(&Interner) {
TyKind::Alias(AliasTy::Projection(proj_ty)) => {
self.normalize_projection_ty(proj_ty.clone())
}

View File

@ -36,7 +36,7 @@ impl<'a> InferenceContext<'a> {
ty1.clone()
} else {
if let (TyKind::FnDef(..), TyKind::FnDef(..)) =
(ty1.interned(&Interner), ty2.interned(&Interner))
(ty1.kind(&Interner), ty2.kind(&Interner))
{
cov_mark::hit!(coerce_fn_reification);
// Special case: two function types. Try to coerce both to
@ -55,7 +55,7 @@ impl<'a> InferenceContext<'a> {
}
fn coerce_inner(&mut self, mut from_ty: Ty, to_ty: &Ty) -> bool {
match (from_ty.interned(&Interner), to_ty.interned(&Interner)) {
match (from_ty.kind(&Interner), to_ty.kind(&Interner)) {
// Never type will make type variable to fallback to Never Type instead of Unknown.
(TyKind::Never, TyKind::InferenceVar(tv, TyVariableKind::General)) => {
self.table.type_variable_table.set_diverging(*tv, true);
@ -73,7 +73,7 @@ impl<'a> InferenceContext<'a> {
}
// Pointer weakening and function to pointer
match (from_ty.interned_mut(), to_ty.interned(&Interner)) {
match (from_ty.interned_mut(), to_ty.kind(&Interner)) {
// `*mut T` -> `*const T`
// `&mut T` -> `&T`
(TyKind::Raw(m1, ..), TyKind::Raw(m2 @ Mutability::Not, ..))
@ -111,7 +111,7 @@ impl<'a> InferenceContext<'a> {
}
// Auto Deref if cannot coerce
match (from_ty.interned(&Interner), to_ty.interned(&Interner)) {
match (from_ty.kind(&Interner), to_ty.kind(&Interner)) {
// FIXME: DerefMut
(TyKind::Ref(_, st1), TyKind::Ref(_, st2)) => self.unify_autoderef_behind_ref(st1, st2),

View File

@ -455,7 +455,7 @@ impl<'a> InferenceContext<'a> {
})
.unwrap_or(true)
};
match canonicalized.decanonicalize_ty(derefed_ty.value).interned(&Interner) {
match canonicalized.decanonicalize_ty(derefed_ty.value).kind(&Interner) {
TyKind::Tuple(_, substs) => name.as_tuple_index().and_then(|idx| {
substs
.interned(&Interner)
@ -577,7 +577,7 @@ impl<'a> InferenceContext<'a> {
None => self.err_ty(),
},
UnaryOp::Neg => {
match inner_ty.interned(&Interner) {
match inner_ty.kind(&Interner) {
// Fast path for builtins
TyKind::Scalar(Scalar::Int(_))
| TyKind::Scalar(Scalar::Uint(_))
@ -590,7 +590,7 @@ impl<'a> InferenceContext<'a> {
}
}
UnaryOp::Not => {
match inner_ty.interned(&Interner) {
match inner_ty.kind(&Interner) {
// Fast path for builtins
TyKind::Scalar(Scalar::Bool)
| TyKind::Scalar(Scalar::Int(_))
@ -696,7 +696,7 @@ impl<'a> InferenceContext<'a> {
}
}
Expr::Tuple { exprs } => {
let mut tys = match expected.ty.interned(&Interner) {
let mut tys = match expected.ty.kind(&Interner) {
TyKind::Tuple(_, substs) => substs
.iter(&Interner)
.map(|a| a.assert_ty_ref(&Interner).clone())
@ -713,7 +713,7 @@ impl<'a> InferenceContext<'a> {
TyKind::Tuple(tys.len(), Substitution::from_iter(&Interner, tys)).intern(&Interner)
}
Expr::Array(array) => {
let elem_ty = match expected.ty.interned(&Interner) {
let elem_ty = match expected.ty.kind(&Interner) {
TyKind::Array(st) | TyKind::Slice(st) => st.clone(),
_ => self.table.new_type_var(),
};
@ -961,7 +961,7 @@ impl<'a> InferenceContext<'a> {
}
fn register_obligations_for_call(&mut self, callable_ty: &Ty) {
if let TyKind::FnDef(fn_def, parameters) = callable_ty.interned(&Interner) {
if let TyKind::FnDef(fn_def, parameters) = callable_ty.kind(&Interner) {
let def: CallableDefId = from_chalk(self.db, *fn_def);
let generic_predicates = self.db.generic_predicates(def.into());
for predicate in generic_predicates.iter() {

View File

@ -211,7 +211,7 @@ impl<'a> InferenceContext<'a> {
return inner_ty;
}
Pat::Slice { prefix, slice, suffix } => {
let (container_ty, elem_ty): (fn(_) -> _, _) = match expected.interned(&Interner) {
let (container_ty, elem_ty): (fn(_) -> _, _) = match expected.kind(&Interner) {
TyKind::Array(st) => (TyKind::Array, st.clone()),
TyKind::Slice(st) => (TyKind::Slice, st.clone()),
_ => (TyKind::Slice, self.err_ty()),

View File

@ -147,7 +147,7 @@ impl<'a> InferenceContext<'a> {
remaining_segments_for_ty,
true,
);
if let TyKind::Unknown = ty.interned(&Interner) {
if let TyKind::Unknown = ty.kind(&Interner) {
return None;
}
@ -212,7 +212,7 @@ impl<'a> InferenceContext<'a> {
name: &Name,
id: ExprOrPatId,
) -> Option<(ValueNs, Option<Substitution>)> {
if let TyKind::Unknown = ty.interned(&Interner) {
if let TyKind::Unknown = ty.kind(&Interner) {
return None;
}

View File

@ -49,7 +49,7 @@ impl<'a, 'b> Canonicalizer<'a, 'b> {
fn do_canonicalize<T: TypeWalk>(&mut self, t: T, binders: DebruijnIndex) -> T {
t.fold_binders(
&mut |ty, binders| match ty.interned(&Interner) {
&mut |ty, binders| match ty.kind(&Interner) {
&TyKind::InferenceVar(var, kind) => {
let inner = var.to_inner();
if self.var_stack.contains(&inner) {
@ -304,7 +304,7 @@ impl InferenceTable {
let ty1 = self.resolve_ty_shallow(ty1);
let ty2 = self.resolve_ty_shallow(ty2);
if ty1.equals_ctor(&ty2) {
match (ty1.interned(&Interner), ty2.interned(&Interner)) {
match (ty1.kind(&Interner), ty2.kind(&Interner)) {
(TyKind::Adt(_, substs1), TyKind::Adt(_, substs2))
| (TyKind::FnDef(_, substs1), TyKind::FnDef(_, substs2))
| (
@ -329,7 +329,7 @@ impl InferenceTable {
}
pub(super) fn unify_inner_trivial(&mut self, ty1: &Ty, ty2: &Ty, depth: usize) -> bool {
match (ty1.interned(&Interner), ty2.interned(&Interner)) {
match (ty1.kind(&Interner), ty2.kind(&Interner)) {
(TyKind::Unknown, _) | (_, TyKind::Unknown) => true,
(TyKind::Placeholder(p1), TyKind::Placeholder(p2)) if *p1 == *p2 => true,
@ -458,7 +458,7 @@ impl InferenceTable {
if i > 0 {
cov_mark::hit!(type_var_resolves_to_int_var);
}
match ty.interned(&Interner) {
match ty.kind(&Interner) {
TyKind::InferenceVar(tv, _) => {
let inner = tv.to_inner();
match self.var_unification_table.inlined_probe_value(inner).known() {
@ -481,7 +481,7 @@ impl InferenceTable {
/// be resolved as far as possible, i.e. contain no type variables with
/// known type.
fn resolve_ty_as_possible_inner(&mut self, tv_stack: &mut Vec<TypeVarId>, ty: Ty) -> Ty {
ty.fold(&mut |ty| match ty.interned(&Interner) {
ty.fold(&mut |ty| match ty.kind(&Interner) {
&TyKind::InferenceVar(tv, kind) => {
let inner = tv.to_inner();
if tv_stack.contains(&inner) {
@ -508,7 +508,7 @@ impl InferenceTable {
/// Resolves the type completely; type variables without known type are
/// replaced by TyKind::Unknown.
fn resolve_ty_completely_inner(&mut self, tv_stack: &mut Vec<TypeVarId>, ty: Ty) -> Ty {
ty.fold(&mut |ty| match ty.interned(&Interner) {
ty.fold(&mut |ty| match ty.kind(&Interner) {
&TyKind::InferenceVar(tv, kind) => {
let inner = tv.to_inner();
if tv_stack.contains(&inner) {

View File

@ -312,7 +312,7 @@ impl TyKind {
}
impl Ty {
pub fn interned(&self, _interner: &Interner) -> &TyKind {
pub fn kind(&self, _interner: &Interner) -> &TyKind {
&self.0
}
@ -846,14 +846,14 @@ impl Ty {
}
pub fn as_reference(&self) -> Option<(&Ty, Mutability)> {
match self.interned(&Interner) {
match self.kind(&Interner) {
TyKind::Ref(mutability, ty) => Some((ty, *mutability)),
_ => None,
}
}
pub fn as_reference_or_ptr(&self) -> Option<(&Ty, Rawness, Mutability)> {
match self.interned(&Interner) {
match self.kind(&Interner) {
TyKind::Ref(mutability, ty) => Some((ty, Rawness::Ref, *mutability)),
TyKind::Raw(mutability, ty) => Some((ty, Rawness::RawPtr, *mutability)),
_ => None,
@ -863,7 +863,7 @@ impl Ty {
pub fn strip_references(&self) -> &Ty {
let mut t: &Ty = self;
while let TyKind::Ref(_mutability, ty) = t.interned(&Interner) {
while let TyKind::Ref(_mutability, ty) = t.kind(&Interner) {
t = ty;
}
@ -871,21 +871,21 @@ impl Ty {
}
pub fn as_adt(&self) -> Option<(hir_def::AdtId, &Substitution)> {
match self.interned(&Interner) {
match self.kind(&Interner) {
TyKind::Adt(AdtId(adt), parameters) => Some((*adt, parameters)),
_ => None,
}
}
pub fn as_tuple(&self) -> Option<&Substitution> {
match self.interned(&Interner) {
match self.kind(&Interner) {
TyKind::Tuple(_, substs) => Some(substs),
_ => None,
}
}
pub fn as_generic_def(&self, db: &dyn HirDatabase) -> Option<GenericDefId> {
match *self.interned(&Interner) {
match *self.kind(&Interner) {
TyKind::Adt(AdtId(adt), ..) => Some(adt.into()),
TyKind::FnDef(callable, ..) => {
Some(db.lookup_intern_callable_def(callable.into()).into())
@ -897,15 +897,15 @@ impl Ty {
}
pub fn is_never(&self) -> bool {
matches!(self.interned(&Interner), TyKind::Never)
matches!(self.kind(&Interner), TyKind::Never)
}
pub fn is_unknown(&self) -> bool {
matches!(self.interned(&Interner), TyKind::Unknown)
matches!(self.kind(&Interner), TyKind::Unknown)
}
pub fn equals_ctor(&self, other: &Ty) -> bool {
match (self.interned(&Interner), other.interned(&Interner)) {
match (self.kind(&Interner), other.kind(&Interner)) {
(TyKind::Adt(adt, ..), TyKind::Adt(adt2, ..)) => adt == adt2,
(TyKind::Slice(_), TyKind::Slice(_)) | (TyKind::Array(_), TyKind::Array(_)) => true,
(TyKind::FnDef(def_id, ..), TyKind::FnDef(def_id2, ..)) => def_id == def_id2,
@ -934,7 +934,7 @@ impl Ty {
/// If this is a `dyn Trait` type, this returns the `Trait` part.
fn dyn_trait_ref(&self) -> Option<&TraitRef> {
match self.interned(&Interner) {
match self.kind(&Interner) {
TyKind::Dyn(dyn_ty) => {
dyn_ty.bounds.value.interned().get(0).and_then(|b| match b.skip_binders() {
WhereClause::Implemented(trait_ref) => Some(trait_ref),
@ -951,7 +951,7 @@ impl Ty {
}
fn builtin_deref(&self) -> Option<Ty> {
match self.interned(&Interner) {
match self.kind(&Interner) {
TyKind::Ref(.., ty) => Some(ty.clone()),
TyKind::Raw(.., ty) => Some(ty.clone()),
_ => None,
@ -959,7 +959,7 @@ impl Ty {
}
pub fn callable_def(&self, db: &dyn HirDatabase) -> Option<CallableDefId> {
match self.interned(&Interner) {
match self.kind(&Interner) {
&TyKind::FnDef(def, ..) => Some(db.lookup_intern_callable_def(def.into())),
_ => None,
}
@ -974,7 +974,7 @@ impl Ty {
}
pub fn callable_sig(&self, db: &dyn HirDatabase) -> Option<CallableSig> {
match self.interned(&Interner) {
match self.kind(&Interner) {
TyKind::Function(fn_ptr) => Some(CallableSig::from_fn_ptr(fn_ptr)),
TyKind::FnDef(def, parameters) => {
let callable_def = db.lookup_intern_callable_def((*def).into());
@ -992,7 +992,7 @@ impl Ty {
/// Returns the type parameters of this type if it has some (i.e. is an ADT
/// or function); so if `self` is `Option<u32>`, this returns the `u32`.
pub fn substs(&self) -> Option<&Substitution> {
match self.interned(&Interner) {
match self.kind(&Interner) {
TyKind::Adt(_, substs)
| TyKind::FnDef(_, substs)
| TyKind::Function(FnPointer { substs, .. })
@ -1018,7 +1018,7 @@ impl Ty {
}
pub fn impl_trait_bounds(&self, db: &dyn HirDatabase) -> Option<Vec<QuantifiedWhereClause>> {
match self.interned(&Interner) {
match self.kind(&Interner) {
TyKind::OpaqueType(opaque_ty_id, ..) => {
match db.lookup_intern_impl_trait_id((*opaque_ty_id).into()) {
ImplTraitId::AsyncBlockTypeImplTrait(def, _expr) => {
@ -1093,7 +1093,7 @@ impl Ty {
}
pub fn associated_type_parent_trait(&self, db: &dyn HirDatabase) -> Option<TraitId> {
match self.interned(&Interner) {
match self.kind(&Interner) {
TyKind::AssociatedType(id, ..) => {
match from_assoc_type_id(*id).lookup(db.upcast()).container {
AssocContainerId::TraitId(trait_id) => Some(trait_id),
@ -1201,7 +1201,7 @@ pub trait TypeWalk {
Self: Sized,
{
self.fold_binders(
&mut |ty, binders| match ty.interned(&Interner) {
&mut |ty, binders| match ty.kind(&Interner) {
TyKind::BoundVar(bound) if bound.debruijn >= binders => {
TyKind::BoundVar(bound.shifted_in_from(n)).intern(&Interner)
}
@ -1217,7 +1217,7 @@ pub trait TypeWalk {
Self: Sized + std::fmt::Debug,
{
self.fold_binders(
&mut |ty, binders| match ty.interned(&Interner) {
&mut |ty, binders| match ty.kind(&Interner) {
TyKind::BoundVar(bound) if bound.debruijn >= binders => {
TyKind::BoundVar(bound.shifted_out_to(n).unwrap_or(bound.clone()))
.intern(&Interner)
@ -1231,7 +1231,7 @@ pub trait TypeWalk {
impl TypeWalk for Ty {
fn walk(&self, f: &mut impl FnMut(&Ty)) {
match self.interned(&Interner) {
match self.kind(&Interner) {
TyKind::Alias(AliasTy::Projection(p_ty)) => {
for t in p_ty.substitution.iter(&Interner) {
t.walk(f);

View File

@ -47,7 +47,7 @@ impl TyFingerprint {
/// have impls: if we have some `struct S`, we can have an `impl S`, but not
/// `impl &S`. Hence, this will return `None` for reference types and such.
pub fn for_impl(ty: &Ty) -> Option<TyFingerprint> {
let fp = match *ty.interned(&Interner) {
let fp = match *ty.kind(&Interner) {
TyKind::Str => TyFingerprint::Str,
TyKind::Never => TyFingerprint::Never,
TyKind::Slice(..) => TyFingerprint::Slice,
@ -243,7 +243,7 @@ impl Ty {
let mod_to_crate_ids = |module: ModuleId| Some(std::iter::once(module.krate()).collect());
let lang_item_targets = match self.interned(&Interner) {
let lang_item_targets = match self.kind(&Interner) {
TyKind::Adt(AdtId(def_id), _) => {
return mod_to_crate_ids(def_id.module(db.upcast()));
}
@ -563,7 +563,7 @@ fn iterate_trait_method_candidates(
// if ty is `dyn Trait`, the trait doesn't need to be in scope
let inherent_trait =
self_ty.value.dyn_trait().into_iter().flat_map(|t| all_super_traits(db.upcast(), t));
let env_traits = if let TyKind::Placeholder(_) = self_ty.value.interned(&Interner) {
let env_traits = if let TyKind::Placeholder(_) = self_ty.value.kind(&Interner) {
// if we have `T: Trait` in the param env, the trait doesn't need to be in scope
env.traits_in_scope_from_clauses(&self_ty.value)
.flat_map(|t| all_super_traits(db.upcast(), t))
@ -741,7 +741,7 @@ pub(crate) fn inherent_impl_substs(
fn fallback_bound_vars(s: Substitution, num_vars_to_keep: usize) -> Substitution {
s.fold_binders(
&mut |ty, binders| {
if let TyKind::BoundVar(bound) = ty.interned(&Interner) {
if let TyKind::BoundVar(bound) = ty.kind(&Interner) {
if bound.index >= num_vars_to_keep && bound.debruijn >= binders {
TyKind::Unknown.intern(&Interner)
} else {
@ -839,9 +839,7 @@ fn autoderef_method_receiver(
) -> Vec<Canonical<Ty>> {
let mut deref_chain: Vec<_> = autoderef::autoderef(db, Some(krate), ty).collect();
// As a last step, we can do array unsizing (that's the only unsizing that rustc does for method receivers!)
if let Some(TyKind::Array(parameters)) =
deref_chain.last().map(|ty| ty.value.interned(&Interner))
{
if let Some(TyKind::Array(parameters)) = deref_chain.last().map(|ty| ty.value.kind(&Interner)) {
let kinds = deref_chain.last().unwrap().binders.clone();
let unsized_ty = TyKind::Slice(parameters.clone()).intern(&Interner);
deref_chain.push(Canonical { value: unsized_ty, binders: kinds })

View File

@ -9,7 +9,7 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, lhs_ty: Ty, rhs_ty: Ty) -> Ty {
BinaryOp::LogicOp(_) | BinaryOp::CmpOp(_) => TyKind::Scalar(Scalar::Bool).intern(&Interner),
BinaryOp::Assignment { .. } => Ty::unit(),
BinaryOp::ArithOp(ArithOp::Shl) | BinaryOp::ArithOp(ArithOp::Shr) => {
match lhs_ty.interned(&Interner) {
match lhs_ty.kind(&Interner) {
TyKind::Scalar(Scalar::Int(_))
| TyKind::Scalar(Scalar::Uint(_))
| TyKind::Scalar(Scalar::Float(_)) => lhs_ty,
@ -18,7 +18,7 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, lhs_ty: Ty, rhs_ty: Ty) -> Ty {
_ => TyKind::Unknown.intern(&Interner),
}
}
BinaryOp::ArithOp(_) => match rhs_ty.interned(&Interner) {
BinaryOp::ArithOp(_) => match rhs_ty.kind(&Interner) {
TyKind::Scalar(Scalar::Int(_))
| TyKind::Scalar(Scalar::Uint(_))
| TyKind::Scalar(Scalar::Float(_)) => rhs_ty,
@ -33,7 +33,7 @@ pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty {
match op {
BinaryOp::LogicOp(..) => TyKind::Scalar(Scalar::Bool).intern(&Interner),
BinaryOp::Assignment { op: None } => lhs_ty,
BinaryOp::CmpOp(CmpOp::Eq { .. }) => match lhs_ty.interned(&Interner) {
BinaryOp::CmpOp(CmpOp::Eq { .. }) => match lhs_ty.kind(&Interner) {
TyKind::Scalar(_) | TyKind::Str => lhs_ty,
TyKind::InferenceVar(_, TyVariableKind::Integer)
| TyKind::InferenceVar(_, TyVariableKind::Float) => lhs_ty,
@ -44,7 +44,7 @@ pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty {
}
BinaryOp::CmpOp(CmpOp::Ord { .. })
| BinaryOp::Assignment { op: Some(_) }
| BinaryOp::ArithOp(_) => match lhs_ty.interned(&Interner) {
| BinaryOp::ArithOp(_) => match lhs_ty.kind(&Interner) {
TyKind::Scalar(Scalar::Int(_))
| TyKind::Scalar(Scalar::Uint(_))
| TyKind::Scalar(Scalar::Float(_)) => lhs_ty,

View File

@ -138,7 +138,7 @@ pub(crate) fn trait_solve_query(
..
})) = &goal.value.goal
{
if let TyKind::BoundVar(_) = projection_ty.self_type_parameter().interned(&Interner) {
if let TyKind::BoundVar(_) = projection_ty.self_type_parameter().kind(&Interner) {
// Hack: don't ask Chalk to normalize with an unknown self type, it'll say that's impossible
return Some(Solution::Ambig(Guidance::Unknown));
}

View File

@ -92,7 +92,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
ty: &Ty,
binders: &CanonicalVarKinds<Interner>,
) -> Option<chalk_ir::TyVariableKind> {
if let TyKind::BoundVar(bv) = ty.interned(&Interner) {
if let TyKind::BoundVar(bv) = ty.kind(&Interner) {
let binders = binders.as_slice(&Interner);
if bv.debruijn == DebruijnIndex::INNERMOST {
if let chalk_ir::VariableKind::Ty(tk) = binders[bv.index].kind {