From c551604b5a0b74a43f5efe567bcbd979daa2f3cc Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 3 Apr 2021 13:08:29 +0200 Subject: Rename Ty::interned to Ty::kind ... since that's the actual method on Chalk side that matches the signature. --- crates/hir_ty/src/autoderef.rs | 2 +- crates/hir_ty/src/diagnostics/expr.rs | 2 +- crates/hir_ty/src/diagnostics/match_check.rs | 2 +- crates/hir_ty/src/diagnostics/unsafe_check.rs | 2 +- crates/hir_ty/src/display.rs | 8 +++--- crates/hir_ty/src/infer.rs | 4 +-- crates/hir_ty/src/infer/coerce.rs | 8 +++--- crates/hir_ty/src/infer/expr.rs | 12 ++++---- crates/hir_ty/src/infer/pat.rs | 2 +- crates/hir_ty/src/infer/path.rs | 4 +-- crates/hir_ty/src/infer/unify.rs | 12 ++++---- crates/hir_ty/src/lib.rs | 40 +++++++++++++-------------- crates/hir_ty/src/method_resolution.rs | 12 ++++---- crates/hir_ty/src/op.rs | 8 +++--- crates/hir_ty/src/traits.rs | 2 +- crates/hir_ty/src/traits/chalk.rs | 2 +- 16 files changed, 60 insertions(+), 62 deletions(-) (limited to 'crates/hir_ty/src') diff --git a/crates/hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs index 5e3c018a8..c859f9491 100644 --- a/crates/hir_ty/src/autoderef.rs +++ b/crates/hir_ty/src/autoderef.rs @@ -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); diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 373d1cb74..ad1259b34 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs @@ -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 => { diff --git a/crates/hir_ty/src/diagnostics/match_check.rs b/crates/hir_ty/src/diagnostics/match_check.rs index 85ba58c44..34291578a 100644 --- a/crates/hir_ty/src/diagnostics/match_check.rs +++ b/crates/hir_ty/src/diagnostics/match_check.rs @@ -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); diff --git a/crates/hir_ty/src/diagnostics/unsafe_check.rs b/crates/hir_ty/src/diagnostics/unsafe_check.rs index 1f49a4909..a71eebc6f 100644 --- a/crates/hir_ty/src/diagnostics/unsafe_check.rs +++ b/crates/hir_ty/src/diagnostics/unsafe_check.rs @@ -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 }); } } diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 59fd18c2a..97f1092c6 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs @@ -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) => { diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index 674e9e6f9..b871594bd 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs @@ -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()) } diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index 8f7322b36..d887e21a2 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs @@ -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), diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index b99b6cd21..dd3914ec3 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -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() { diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index f1316415f..10df8d8cb 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs @@ -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()), diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs index b96391776..1ba15f737 100644 --- a/crates/hir_ty/src/infer/path.rs +++ b/crates/hir_ty/src/infer/path.rs @@ -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)> { - if let TyKind::Unknown = ty.interned(&Interner) { + if let TyKind::Unknown = ty.kind(&Interner) { return None; } diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 0efc62e53..d2496db3b 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs @@ -49,7 +49,7 @@ impl<'a, 'b> Canonicalizer<'a, 'b> { fn do_canonicalize(&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, 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, 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) { diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index c927ed973..4c3d904bf 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs @@ -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 { - 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 { - 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 { - 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 { - 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`, 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> { - 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 { - 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); diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 054896475..338851fa8 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -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 { - 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> { 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 }) diff --git a/crates/hir_ty/src/op.rs b/crates/hir_ty/src/op.rs index 527c5cbbd..8533e1ed8 100644 --- a/crates/hir_ty/src/op.rs +++ b/crates/hir_ty/src/op.rs @@ -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, diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index a15b6486e..e5e8cff33 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs @@ -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)); } diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index cf7ed1e11..fbac51b05 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs @@ -92,7 +92,7 @@ impl<'a> chalk_solve::RustIrDatabase for ChalkContext<'a> { ty: &Ty, binders: &CanonicalVarKinds, ) -> Option { - 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 { -- cgit v1.2.3