Change ty.kind to a method
This commit is contained in:
parent
ef55a0a92f
commit
3e14b684dd
189 changed files with 947 additions and 899 deletions
|
@ -1454,7 +1454,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
// Check if we have an enum variant.
|
||||
let mut variant_resolution = None;
|
||||
if let ty::Adt(adt_def, _) = qself_ty.kind {
|
||||
if let ty::Adt(adt_def, _) = qself_ty.kind() {
|
||||
if adt_def.is_enum() {
|
||||
let variant_def = adt_def
|
||||
.variants
|
||||
|
@ -1474,7 +1474,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
// Find the type of the associated item, and the trait where the associated
|
||||
// item is declared.
|
||||
let bound = match (&qself_ty.kind, qself_res) {
|
||||
let bound = match (&qself_ty.kind(), qself_res) {
|
||||
(_, Res::SelfTy(Some(_), Some(impl_def_id))) => {
|
||||
// `Self` in an impl of a trait -- we have a concrete self type and a
|
||||
// trait reference.
|
||||
|
|
|
@ -43,7 +43,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
self.try_overloaded_deref(autoderef.span(), source).and_then(
|
||||
|InferOk { value: method, obligations: o }| {
|
||||
obligations.extend(o);
|
||||
if let ty::Ref(region, _, mutbl) = method.sig.output().kind {
|
||||
if let ty::Ref(region, _, mutbl) = *method.sig.output().kind() {
|
||||
Some(OverloadedDeref { region, mutbl })
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -114,7 +114,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
);
|
||||
|
||||
// If the callee is a bare function or a closure, then we're all set.
|
||||
match adjusted_ty.kind {
|
||||
match *adjusted_ty.kind() {
|
||||
ty::FnDef(..) | ty::FnPtr(_) => {
|
||||
let adjustments = self.adjust_steps(autoderef);
|
||||
self.apply_adjustments(callee_expr, adjustments);
|
||||
|
@ -223,12 +223,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
if borrow {
|
||||
// Check for &self vs &mut self in the method signature. Since this is either
|
||||
// the Fn or FnMut trait, it should be one of those.
|
||||
let (region, mutbl) = if let ty::Ref(r, _, mutbl) = method.sig.inputs()[0].kind
|
||||
{
|
||||
(r, mutbl)
|
||||
} else {
|
||||
span_bug!(call_expr.span, "input to call/call_mut is not a ref?");
|
||||
};
|
||||
let (region, mutbl) =
|
||||
if let ty::Ref(r, _, mutbl) = method.sig.inputs()[0].kind() {
|
||||
(r, mutbl)
|
||||
} else {
|
||||
span_bug!(call_expr.span, "input to call/call_mut is not a ref?");
|
||||
};
|
||||
|
||||
let mutbl = match mutbl {
|
||||
hir::Mutability::Not => AutoBorrowMutability::Not,
|
||||
|
@ -285,7 +285,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
arg_exprs: &'tcx [hir::Expr<'tcx>],
|
||||
expected: Expectation<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
let (fn_sig, def_span) = match callee_ty.kind {
|
||||
let (fn_sig, def_span) = match *callee_ty.kind() {
|
||||
ty::FnDef(def_id, _) => {
|
||||
(callee_ty.fn_sig(self.tcx), self.tcx.hir().span_if_local(def_id))
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
return Ok(Some(PointerKind::Thin));
|
||||
}
|
||||
|
||||
Ok(match t.kind {
|
||||
Ok(match *t.kind() {
|
||||
ty::Slice(_) | ty::Str => Some(PointerKind::Length),
|
||||
ty::Dynamic(ref tty, ..) => Some(PointerKind::Vtable(tty.principal_def_id())),
|
||||
ty::Adt(def, substs) if def.is_struct() => match def.non_enum_variant().fields.last() {
|
||||
|
@ -203,7 +203,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
// For better error messages, check for some obviously unsized
|
||||
// cases now. We do a more thorough check at the end, once
|
||||
// inference is more completely known.
|
||||
match cast_ty.kind {
|
||||
match cast_ty.kind() {
|
||||
ty::Dynamic(..) | ty::Slice(..) => {
|
||||
check.report_cast_to_unsized_type(fcx);
|
||||
Err(ErrorReported)
|
||||
|
@ -348,7 +348,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
fcx.ty_to_string(self.cast_ty)
|
||||
);
|
||||
let mut sugg = None;
|
||||
if let ty::Ref(reg, _, mutbl) = self.cast_ty.kind {
|
||||
if let ty::Ref(reg, _, mutbl) = *self.cast_ty.kind() {
|
||||
if fcx
|
||||
.try_coerce(
|
||||
self.expr,
|
||||
|
@ -370,7 +370,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
Applicability::MachineApplicable,
|
||||
);
|
||||
} else if !matches!(
|
||||
self.cast_ty.kind,
|
||||
self.cast_ty.kind(),
|
||||
ty::FnDef(..) | ty::FnPtr(..) | ty::Closure(..)
|
||||
) {
|
||||
let mut label = true;
|
||||
|
@ -474,7 +474,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
fcx.resolve_vars_if_possible(&self.expr_ty),
|
||||
tstr
|
||||
);
|
||||
match self.expr_ty.kind {
|
||||
match self.expr_ty.kind() {
|
||||
ty::Ref(_, _, mt) => {
|
||||
let mtstr = mt.prefix_str();
|
||||
if self.cast_ty.is_trait() {
|
||||
|
@ -602,7 +602,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
(Some(t_from), Some(t_cast)) => (t_from, t_cast),
|
||||
// Function item types may need to be reified before casts.
|
||||
(None, Some(t_cast)) => {
|
||||
match self.expr_ty.kind {
|
||||
match *self.expr_ty.kind() {
|
||||
ty::FnDef(..) => {
|
||||
// Attempt a coercion to a fn pointer type.
|
||||
let f = fcx.normalize_associated_types_in(
|
||||
|
@ -629,7 +629,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
// a cast.
|
||||
ty::Ref(_, inner_ty, mutbl) => {
|
||||
return match t_cast {
|
||||
Int(_) | Float => match inner_ty.kind {
|
||||
Int(_) | Float => match *inner_ty.kind() {
|
||||
ty::Int(_)
|
||||
| ty::Uint(_)
|
||||
| ty::Float(_)
|
||||
|
@ -768,7 +768,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
// array-ptr-cast.
|
||||
|
||||
if m_expr.mutbl == hir::Mutability::Not && m_cast.mutbl == hir::Mutability::Not {
|
||||
if let ty::Array(ety, _) = m_expr.ty.kind {
|
||||
if let ty::Array(ety, _) = m_expr.ty.kind() {
|
||||
// Due to the limitations of LLVM global constants,
|
||||
// region pointers end up pointing at copies of
|
||||
// vector elements instead of the original values.
|
||||
|
@ -817,7 +817,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
}
|
||||
|
||||
fn cenum_impl_drop_lint(&self, fcx: &FnCtxt<'a, 'tcx>) {
|
||||
if let ty::Adt(d, _) = self.expr_ty.kind {
|
||||
if let ty::Adt(d, _) = self.expr_ty.kind() {
|
||||
if d.has_dtor(fcx.tcx) {
|
||||
fcx.tcx.struct_span_lint_hir(
|
||||
lint::builtin::CENUM_IMPL_DROP_CAST,
|
||||
|
|
|
@ -170,7 +170,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
) -> (Option<ExpectedSig<'tcx>>, Option<ty::ClosureKind>) {
|
||||
debug!("deduce_expectations_from_expected_type(expected_ty={:?})", expected_ty);
|
||||
|
||||
match expected_ty.kind {
|
||||
match *expected_ty.kind() {
|
||||
ty::Dynamic(ref object_type, ..) => {
|
||||
let sig = object_type.projection_bounds().find_map(|pb| {
|
||||
let pb = pb.with_self_ty(self.tcx, self.tcx.types.trait_object_dummy_self);
|
||||
|
@ -268,7 +268,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let arg_param_ty = self.resolve_vars_if_possible(&arg_param_ty);
|
||||
debug!("deduce_sig_from_projection: arg_param_ty={:?}", arg_param_ty);
|
||||
|
||||
match arg_param_ty.kind {
|
||||
match arg_param_ty.kind() {
|
||||
ty::Tuple(tys) => tys.into_iter().map(|k| k.expect_ty()).collect::<Vec<_>>(),
|
||||
_ => return None,
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// be inferring.
|
||||
let ret_ty = ret_coercion.borrow().expected_ty();
|
||||
let ret_ty = self.inh.infcx.shallow_resolve(ret_ty);
|
||||
let ret_vid = match ret_ty.kind {
|
||||
let ret_vid = match *ret_ty.kind() {
|
||||
ty::Infer(ty::TyVar(ret_vid)) => ret_vid,
|
||||
_ => span_bug!(
|
||||
self.tcx.def_span(expr_def_id),
|
||||
|
|
|
@ -197,7 +197,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
//
|
||||
// Note: does not attempt to resolve type variables we encounter.
|
||||
// See above for details.
|
||||
match b.kind {
|
||||
match *b.kind() {
|
||||
ty::RawPtr(mt_b) => {
|
||||
return self.coerce_unsafe_ptr(a, b, mt_b.mutbl);
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
_ => {}
|
||||
}
|
||||
|
||||
match a.kind {
|
||||
match *a.kind() {
|
||||
ty::FnDef(..) => {
|
||||
// Function items are coercible to any closure
|
||||
// type; function pointers are not (that would
|
||||
|
@ -252,7 +252,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
// to type check, we will construct the type that `&M*expr` would
|
||||
// yield.
|
||||
|
||||
let (r_a, mt_a) = match a.kind {
|
||||
let (r_a, mt_a) = match *a.kind() {
|
||||
ty::Ref(r_a, ty, mutbl) => {
|
||||
let mt_a = ty::TypeAndMut { ty, mutbl };
|
||||
coerce_mutbls(mt_a.mutbl, mutbl_b)?;
|
||||
|
@ -415,7 +415,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
|
||||
// Now apply the autoref. We have to extract the region out of
|
||||
// the final ref type we got.
|
||||
let r_borrow = match ty.kind {
|
||||
let r_borrow = match ty.kind() {
|
||||
ty::Ref(r_borrow, _, _) => r_borrow,
|
||||
_ => span_bug!(span, "expected a ref type, got {:?}", ty),
|
||||
};
|
||||
|
@ -490,7 +490,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
// that, at which point we will need extra checks on the target here.
|
||||
|
||||
// Handle reborrows before selecting `Source: CoerceUnsized<Target>`.
|
||||
let reborrow = match (&source.kind, &target.kind) {
|
||||
let reborrow = match (source.kind(), target.kind()) {
|
||||
(&ty::Ref(_, ty_a, mutbl_a), &ty::Ref(_, _, mutbl_b)) => {
|
||||
coerce_mutbls(mutbl_a, mutbl_b)?;
|
||||
|
||||
|
@ -588,7 +588,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
{
|
||||
if unsize_did == trait_pred.def_id() {
|
||||
let unsize_ty = trait_pred.trait_ref.substs[1].expect_ty();
|
||||
if let ty::Tuple(..) = unsize_ty.kind {
|
||||
if let ty::Tuple(..) = unsize_ty.kind() {
|
||||
debug!("coerce_unsized: found unsized tuple coercion");
|
||||
has_unsized_tuple_coercion = true;
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
let self_ty = trait_pred.skip_binder().self_ty();
|
||||
let unsize_ty = trait_pred.skip_binder().trait_ref.substs[1].expect_ty();
|
||||
debug!("coerce_unsized: ambiguous unsize case for {:?}", trait_pred);
|
||||
match (&self_ty.kind, &unsize_ty.kind) {
|
||||
match (&self_ty.kind(), &unsize_ty.kind()) {
|
||||
(ty::Infer(ty::TyVar(v)), ty::Dynamic(..))
|
||||
if self.type_var_is_sized(*v) =>
|
||||
{
|
||||
|
@ -672,7 +672,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
F: FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>>,
|
||||
G: FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>>,
|
||||
{
|
||||
if let ty::FnPtr(fn_ty_b) = b.kind {
|
||||
if let ty::FnPtr(fn_ty_b) = b.kind() {
|
||||
if let (hir::Unsafety::Normal, hir::Unsafety::Unsafe) =
|
||||
(fn_ty_a.unsafety(), fn_ty_b.unsafety())
|
||||
{
|
||||
|
@ -712,7 +712,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
let b = self.shallow_resolve(b);
|
||||
debug!("coerce_from_fn_item(a={:?}, b={:?})", a, b);
|
||||
|
||||
match b.kind {
|
||||
match b.kind() {
|
||||
ty::FnPtr(b_sig) => {
|
||||
let a_sig = a.fn_sig(self.tcx);
|
||||
// Intrinsics are not coercible to function pointers
|
||||
|
@ -721,7 +721,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
}
|
||||
|
||||
// Safe `#[target_feature]` functions are not assignable to safe fn pointers (RFC 2396).
|
||||
if let ty::FnDef(def_id, _) = a.kind {
|
||||
if let ty::FnDef(def_id, _) = *a.kind() {
|
||||
if b_sig.unsafety() == hir::Unsafety::Normal
|
||||
&& !self.tcx.codegen_fn_attrs(def_id).target_features.is_empty()
|
||||
{
|
||||
|
@ -771,7 +771,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
|
||||
let b = self.shallow_resolve(b);
|
||||
|
||||
match b.kind {
|
||||
match b.kind() {
|
||||
ty::FnPtr(fn_ty) if substs_a.as_closure().upvar_tys().next().is_none() => {
|
||||
// We coerce the closure, which has fn type
|
||||
// `extern "rust-call" fn((arg0,arg1,...)) -> _`
|
||||
|
@ -802,7 +802,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
) -> CoerceResult<'tcx> {
|
||||
debug!("coerce_unsafe_ptr(a={:?}, b={:?})", a, b);
|
||||
|
||||
let (is_ref, mt_a) = match a.kind {
|
||||
let (is_ref, mt_a) = match *a.kind() {
|
||||
ty::Ref(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }),
|
||||
ty::RawPtr(mt) => (false, mt),
|
||||
_ => return self.unify_and(a, b, identity),
|
||||
|
@ -912,10 +912,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
false
|
||||
}
|
||||
};
|
||||
if is_capturing_closure(&prev_ty.kind) || is_capturing_closure(&new_ty.kind) {
|
||||
if is_capturing_closure(&prev_ty.kind()) || is_capturing_closure(&new_ty.kind()) {
|
||||
(None, None)
|
||||
} else {
|
||||
match (&prev_ty.kind, &new_ty.kind) {
|
||||
match (&prev_ty.kind(), &new_ty.kind()) {
|
||||
(&ty::FnDef(..), &ty::FnDef(..)) => {
|
||||
// Don't reify if the function types have a LUB, i.e., they
|
||||
// are the same function and their parameters have a LUB.
|
||||
|
@ -969,12 +969,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
// Reify both sides and return the reified fn pointer type.
|
||||
let fn_ptr = self.tcx.mk_fn_ptr(sig);
|
||||
let prev_adjustment = match prev_ty.kind {
|
||||
let prev_adjustment = match prev_ty.kind() {
|
||||
ty::Closure(..) => Adjust::Pointer(PointerCast::ClosureFnPointer(a_sig.unsafety())),
|
||||
ty::FnDef(..) => Adjust::Pointer(PointerCast::ReifyFnPointer),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let next_adjustment = match new_ty.kind {
|
||||
let next_adjustment = match new_ty.kind() {
|
||||
ty::Closure(..) => Adjust::Pointer(PointerCast::ClosureFnPointer(b_sig.unsafety())),
|
||||
ty::FnDef(..) => Adjust::Pointer(PointerCast::ReifyFnPointer),
|
||||
_ => unreachable!(),
|
||||
|
@ -1024,7 +1024,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let noop = match self.typeck_results.borrow().expr_adjustments(expr) {
|
||||
&[Adjustment { kind: Adjust::Deref(_), .. }, Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl_adj)), .. }] =>
|
||||
{
|
||||
match self.node_ty(expr.hir_id).kind {
|
||||
match *self.node_ty(expr.hir_id).kind() {
|
||||
ty::Ref(_, _, mt_orig) => {
|
||||
let mutbl_adj: hir::Mutability = mutbl_adj.into();
|
||||
// Reborrow that we can safely ignore, because
|
||||
|
@ -1501,7 +1501,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
|||
if let hir::TyKind::OpaqueDef(..) = ty.kind {
|
||||
let ty = AstConv::ast_ty_to_ty(fcx, ty);
|
||||
// Get the `impl Trait`'s `DefId`.
|
||||
if let ty::Opaque(def_id, _) = ty.kind {
|
||||
if let ty::Opaque(def_id, _) = ty.kind() {
|
||||
let hir_id = fcx.tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
|
||||
// Get the `impl Trait`'s `Item` so that we can get its trait bounds and
|
||||
// get the `Trait`'s `DefId`.
|
||||
|
@ -1542,7 +1542,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
|||
if let Some((fn_decl, _)) = fcx.get_fn_decl(blk_id) {
|
||||
if let hir::FnRetTy::Return(ty) = fn_decl.output {
|
||||
let ty = AstConv::ast_ty_to_ty(fcx, ty);
|
||||
if let ty::Dynamic(..) = ty.kind {
|
||||
if let ty::Dynamic(..) = ty.kind() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,7 +186,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
expected: Ty<'tcx>,
|
||||
expr_ty: Ty<'tcx>,
|
||||
) {
|
||||
if let ty::Adt(expected_adt, substs) = expected.kind {
|
||||
if let ty::Adt(expected_adt, substs) = expected.kind() {
|
||||
if !expected_adt.is_enum() {
|
||||
return;
|
||||
}
|
||||
|
@ -413,8 +413,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// `ExprKind::DropTemps` is semantically irrelevant for these suggestions.
|
||||
let expr = expr.peel_drop_temps();
|
||||
|
||||
match (&expr.kind, &expected.kind, &checked_ty.kind) {
|
||||
(_, &ty::Ref(_, exp, _), &ty::Ref(_, check, _)) => match (&exp.kind, &check.kind) {
|
||||
match (&expr.kind, expected.kind(), checked_ty.kind()) {
|
||||
(_, &ty::Ref(_, exp, _), &ty::Ref(_, check, _)) => match (exp.kind(), check.kind()) {
|
||||
(&ty::Str, &ty::Array(arr, _) | &ty::Slice(arr)) if arr == self.tcx.types.u8 => {
|
||||
if let hir::ExprKind::Lit(_) = expr.kind {
|
||||
if let Ok(src) = sm.span_to_snippet(sp) {
|
||||
|
@ -774,7 +774,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let suffix_suggestion = with_opt_paren(&format_args!(
|
||||
"{}{}",
|
||||
if matches!(
|
||||
(&expected_ty.kind, &checked_ty.kind),
|
||||
(&expected_ty.kind(), &checked_ty.kind()),
|
||||
(ty::Int(_) | ty::Uint(_), ty::Float(_))
|
||||
) {
|
||||
// Remove fractional part from literal, for example `42.0f32` into `42`
|
||||
|
@ -790,7 +790,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
};
|
||||
let is_negative_int =
|
||||
|expr: &hir::Expr<'_>| matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::UnNeg, ..));
|
||||
let is_uint = |ty: Ty<'_>| matches!(ty.kind, ty::Uint(..));
|
||||
let is_uint = |ty: Ty<'_>| matches!(ty.kind(), ty::Uint(..));
|
||||
|
||||
let in_const_context = self.tcx.hir().is_inside_const_context(expr.hir_id);
|
||||
|
||||
|
@ -857,7 +857,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
err.span_suggestion(expr.span, msg, suggestion, Applicability::MachineApplicable);
|
||||
};
|
||||
|
||||
match (&expected_ty.kind, &checked_ty.kind) {
|
||||
match (&expected_ty.kind(), &checked_ty.kind()) {
|
||||
(&ty::Int(ref exp), &ty::Int(ref found)) => {
|
||||
let (f2e_is_fallible, e2f_is_fallible) = match (exp.bit_width(), found.bit_width())
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ use rustc_trait_selection::traits::{ObligationCause, TraitEngine, TraitEngineExt
|
|||
pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), ErrorReported> {
|
||||
let dtor_self_type = tcx.type_of(drop_impl_did);
|
||||
let dtor_predicates = tcx.predicates_of(drop_impl_did);
|
||||
match dtor_self_type.kind {
|
||||
match dtor_self_type.kind() {
|
||||
ty::Adt(adt_def, self_to_impl_substs) => {
|
||||
ensure_drop_params_and_item_params_correspond(
|
||||
tcx,
|
||||
|
|
|
@ -296,7 +296,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn check_expr_box(&self, expr: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>) -> Ty<'tcx> {
|
||||
let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| match ty.kind {
|
||||
let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| match ty.kind() {
|
||||
ty::Adt(def, _) if def.is_box() => Expectation::rvalue_hint(self, ty.boxed_ty()),
|
||||
_ => NoExpectation,
|
||||
});
|
||||
|
@ -346,7 +346,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
hir::UnOp::UnNot => {
|
||||
let result = self.check_user_unop(expr, oprnd_t, unop);
|
||||
// If it's builtin, we can reuse the type, this helps inference.
|
||||
if !(oprnd_t.is_integral() || oprnd_t.kind == ty::Bool) {
|
||||
if !(oprnd_t.is_integral() || *oprnd_t.kind() == ty::Bool) {
|
||||
oprnd_t = result;
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
expr: &'tcx hir::Expr<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
let hint = expected.only_has_type(self).map_or(NoExpectation, |ty| {
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => {
|
||||
if oprnd.is_syntactic_place_expr() {
|
||||
// Places may legitimately have unsized types.
|
||||
|
@ -473,7 +473,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
_ => self.instantiate_value_path(segs, opt_ty, res, expr.span, expr.hir_id).0,
|
||||
};
|
||||
|
||||
if let ty::FnDef(..) = ty.kind {
|
||||
if let ty::FnDef(..) = ty.kind() {
|
||||
let fn_sig = ty.fn_sig(tcx);
|
||||
if !tcx.features().unsized_locals {
|
||||
// We want to remove some Sized bounds from std functions,
|
||||
|
@ -951,7 +951,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
error,
|
||||
Some(args),
|
||||
) {
|
||||
if let ty::Adt(..) = rcvr_t.kind {
|
||||
if let ty::Adt(..) = rcvr_t.kind() {
|
||||
// Try alternative arbitrary self types that could fulfill this call.
|
||||
// FIXME: probe for all types that *could* be arbitrary self-types, not
|
||||
// just this list.
|
||||
|
@ -1002,7 +1002,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let element_ty = if !args.is_empty() {
|
||||
let coerce_to = expected
|
||||
.to_option(self)
|
||||
.and_then(|uty| match uty.kind {
|
||||
.and_then(|uty| match *uty.kind() {
|
||||
ty::Array(ty, _) | ty::Slice(ty) => Some(ty),
|
||||
_ => None,
|
||||
})
|
||||
|
@ -1040,7 +1040,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let count = self.to_const(count);
|
||||
|
||||
let uty = match expected {
|
||||
ExpectHasType(uty) => match uty.kind {
|
||||
ExpectHasType(uty) => match *uty.kind() {
|
||||
ty::Array(ty, _) | ty::Slice(ty) => Some(ty),
|
||||
_ => None,
|
||||
},
|
||||
|
@ -1077,7 +1077,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
) -> Ty<'tcx> {
|
||||
let flds = expected.only_has_type(self).and_then(|ty| {
|
||||
let ty = self.resolve_vars_with_obligations(ty);
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
ty::Tuple(ref flds) => Some(&flds[..]),
|
||||
_ => None,
|
||||
}
|
||||
|
@ -1145,7 +1145,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// when certain fields are assumed to exist that in fact do not.
|
||||
if !error_happened {
|
||||
self.check_expr_has_type_or_error(base_expr, adt_ty, |_| {});
|
||||
match adt_ty.kind {
|
||||
match adt_ty.kind() {
|
||||
ty::Adt(adt, substs) if adt.is_struct() => {
|
||||
let fru_field_types = adt
|
||||
.non_enum_variant()
|
||||
|
@ -1200,7 +1200,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// re-link the regions that EIfEO can erase.
|
||||
self.demand_eqtype(span, adt_ty_hint, adt_ty);
|
||||
|
||||
let (substs, adt_kind, kind_name) = match &adt_ty.kind {
|
||||
let (substs, adt_kind, kind_name) = match &adt_ty.kind() {
|
||||
&ty::Adt(adt, substs) => (substs, adt.adt_kind(), adt.variant_descr()),
|
||||
_ => span_bug!(span, "non-ADT passed to check_expr_struct_fields"),
|
||||
};
|
||||
|
@ -1331,7 +1331,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
let mut err = self.type_error_struct_with_diag(
|
||||
field.ident.span,
|
||||
|actual| match ty.kind {
|
||||
|actual| match ty.kind() {
|
||||
ty::Adt(adt, ..) if adt.is_enum() => struct_span_err!(
|
||||
self.tcx.sess,
|
||||
field.ident.span,
|
||||
|
@ -1381,7 +1381,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
} else {
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
ty::Adt(adt, ..) => {
|
||||
if adt.is_enum() {
|
||||
err.span_label(
|
||||
|
@ -1468,7 +1468,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let mut private_candidate = None;
|
||||
let mut autoderef = self.autoderef(expr.span, expr_t);
|
||||
while let Some((base_t, _)) = autoderef.next() {
|
||||
match base_t.kind {
|
||||
match base_t.kind() {
|
||||
ty::Adt(base_def, substs) if !base_def.is_enum() => {
|
||||
debug!("struct named {:?}", base_t);
|
||||
let (ident, def_scope) =
|
||||
|
@ -1571,9 +1571,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
debug!(
|
||||
"suggest_await_on_field_access: normalized_ty={:?}, ty_kind={:?}",
|
||||
self.resolve_vars_if_possible(&normalized_ty),
|
||||
normalized_ty.kind,
|
||||
normalized_ty.kind(),
|
||||
);
|
||||
if let ty::Adt(def, _) = normalized_ty.kind {
|
||||
if let ty::Adt(def, _) = normalized_ty.kind() {
|
||||
// no field access on enum type
|
||||
if !def.is_enum() {
|
||||
if def.non_enum_variant().fields.iter().any(|field| field.ident == field_ident)
|
||||
|
@ -1603,7 +1603,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
);
|
||||
let mut err = self.no_such_field_err(field.span, field, expr_t);
|
||||
|
||||
match expr_t.peel_refs().kind {
|
||||
match *expr_t.peel_refs().kind() {
|
||||
ty::Array(_, len) => {
|
||||
self.maybe_suggest_array_indexing(&mut err, expr, base, field, len);
|
||||
}
|
||||
|
@ -1823,7 +1823,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
base_t
|
||||
);
|
||||
// Try to give some advice about indexing tuples.
|
||||
if let ty::Tuple(..) = base_t.kind {
|
||||
if let ty::Tuple(..) = base_t.kind() {
|
||||
let mut needs_note = true;
|
||||
// If the index is an integer, we can show the actual
|
||||
// fixed expression:
|
||||
|
@ -1908,7 +1908,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// function.
|
||||
if is_input {
|
||||
let ty = self.structurally_resolved_type(expr.span, &ty);
|
||||
match ty.kind {
|
||||
match *ty.kind() {
|
||||
ty::FnDef(..) => {
|
||||
let fnptr_ty = self.tcx.mk_fn_ptr(ty.fn_sig(self.tcx));
|
||||
self.demand_coerce(expr, ty, fnptr_ty, None, AllowTwoPhase::No);
|
||||
|
@ -1956,7 +1956,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub(super) fn ty_kind_suggestion(ty: Ty<'_>) -> Option<&'static str> {
|
||||
Some(match ty.kind {
|
||||
Some(match ty.kind() {
|
||||
ty::Bool => "true",
|
||||
ty::Char => "'a'",
|
||||
ty::Int(_) | ty::Uint(_) => "42",
|
||||
|
|
|
@ -269,7 +269,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
|||
self.fcx
|
||||
.autoderef(self.span, self_ty)
|
||||
.include_raw_pointers()
|
||||
.find_map(|(ty, _)| match ty.kind {
|
||||
.find_map(|(ty, _)| match ty.kind() {
|
||||
ty::Dynamic(ref data, ..) => Some(closure(
|
||||
self,
|
||||
ty,
|
||||
|
@ -464,7 +464,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
|||
}
|
||||
_ => None,
|
||||
})
|
||||
.find_map(|(trait_pred, span)| match trait_pred.self_ty().kind {
|
||||
.find_map(|(trait_pred, span)| match trait_pred.self_ty().kind() {
|
||||
ty::Dynamic(..) => Some(span),
|
||||
_ => None,
|
||||
})
|
||||
|
|
|
@ -207,7 +207,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
if let Some(span) = result.illegal_sized_bound {
|
||||
let mut needs_mut = false;
|
||||
if let ty::Ref(region, t_type, mutability) = self_ty.kind {
|
||||
if let ty::Ref(region, t_type, mutability) = self_ty.kind() {
|
||||
let trait_type = self
|
||||
.tcx
|
||||
.mk_ref(region, ty::TypeAndMut { ty: t_type, mutbl: mutability.invert() });
|
||||
|
@ -424,7 +424,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let tcx = self.tcx;
|
||||
|
||||
// Check if we have an enum variant.
|
||||
if let ty::Adt(adt_def, _) = self_ty.kind {
|
||||
if let ty::Adt(adt_def, _) = self_ty.kind() {
|
||||
if adt_def.is_enum() {
|
||||
let variant_def = adt_def
|
||||
.variants
|
||||
|
|
|
@ -401,7 +401,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
.probe_instantiate_query_response(span, &orig_values, ty)
|
||||
.unwrap_or_else(|_| span_bug!(span, "instantiating {:?} failed?", ty));
|
||||
let ty = self.structurally_resolved_type(span, ty.value);
|
||||
assert!(matches!(ty.kind, ty::Error(_)));
|
||||
assert!(matches!(ty.kind(), ty::Error(_)));
|
||||
return Err(MethodError::NoMatch(NoMatchData::new(
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
|
@ -469,7 +469,7 @@ fn method_autoderef_steps<'tcx>(
|
|||
from_unsafe_deref: reached_raw_pointer,
|
||||
unsize: false,
|
||||
};
|
||||
if let ty::RawPtr(_) = ty.kind {
|
||||
if let ty::RawPtr(_) = ty.kind() {
|
||||
// all the subsequent steps will be from_unsafe_deref
|
||||
reached_raw_pointer = true;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ fn method_autoderef_steps<'tcx>(
|
|||
.collect();
|
||||
|
||||
let final_ty = autoderef.final_ty(true);
|
||||
let opt_bad_ty = match final_ty.kind {
|
||||
let opt_bad_ty = match final_ty.kind() {
|
||||
ty::Infer(ty::TyVar(_)) | ty::Error(_) => Some(MethodAutoderefBadTy {
|
||||
reached_raw_pointer,
|
||||
ty: infcx
|
||||
|
@ -587,7 +587,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
debug!("assemble_probe: self_ty={:?}", self_ty);
|
||||
let lang_items = self.tcx.lang_items();
|
||||
|
||||
match self_ty.value.value.kind {
|
||||
match *self_ty.value.value.kind() {
|
||||
ty::Dynamic(ref data, ..) => {
|
||||
if let Some(p) = data.principal() {
|
||||
// Subtle: we can't use `instantiate_query_response` here: using it will
|
||||
|
@ -759,7 +759,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
fn assemble_inherent_candidates_from_object(&mut self, self_ty: Ty<'tcx>) {
|
||||
debug!("assemble_inherent_candidates_from_object(self_ty={:?})", self_ty);
|
||||
|
||||
let principal = match self_ty.kind {
|
||||
let principal = match self_ty.kind() {
|
||||
ty::Dynamic(ref data, ..) => Some(data),
|
||||
_ => None,
|
||||
}
|
||||
|
@ -806,7 +806,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
self.param_env.caller_bounds().iter().map(ty::Predicate::skip_binders).filter_map(
|
||||
|predicate| match predicate {
|
||||
ty::PredicateAtom::Trait(trait_predicate, _) => {
|
||||
match trait_predicate.trait_ref.self_ty().kind {
|
||||
match trait_predicate.trait_ref.self_ty().kind() {
|
||||
ty::Param(ref p) if *p == param_ty => {
|
||||
Some(ty::Binder::bind(trait_predicate.trait_ref))
|
||||
}
|
||||
|
@ -1125,7 +1125,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
pick.autoderefs = step.autoderefs;
|
||||
|
||||
// Insert a `&*` or `&mut *` if this is a reference type:
|
||||
if let ty::Ref(_, _, mutbl) = step.self_ty.value.value.kind {
|
||||
if let ty::Ref(_, _, mutbl) = *step.self_ty.value.value.kind() {
|
||||
pick.autoderefs += 1;
|
||||
pick.autoref = Some(mutbl);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ use super::{CandidateSource, MethodError, NoMatchData};
|
|||
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
fn is_fn_ty(&self, ty: Ty<'tcx>, span: Span) -> bool {
|
||||
let tcx = self.tcx;
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
// Not all of these (e.g., unsafe fns) implement `FnOnce`,
|
||||
// so we look for these beforehand.
|
||||
ty::Closure(..) | ty::FnDef(..) | ty::FnPtr(_) => true,
|
||||
|
@ -413,7 +413,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
);
|
||||
}
|
||||
}
|
||||
if let ty::RawPtr(_) = &actual.kind {
|
||||
if let ty::RawPtr(_) = &actual.kind() {
|
||||
err.note(
|
||||
"try using `<*const T>::as_ref()` to get a reference to the \
|
||||
type behind the pointer: https://doc.rust-lang.org/std/\
|
||||
|
@ -450,7 +450,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// give a helping note that it has to be called as `(x.f)(...)`.
|
||||
if let SelfSource::MethodCall(expr) = source {
|
||||
let field_receiver =
|
||||
self.autoderef(span, rcvr_ty).find_map(|(ty, _)| match ty.kind {
|
||||
self.autoderef(span, rcvr_ty).find_map(|(ty, _)| match ty.kind() {
|
||||
ty::Adt(def, substs) if !def.is_enum() => {
|
||||
let variant = &def.non_enum_variant();
|
||||
self.tcx.find_field_index(item_name, variant).map(|index| {
|
||||
|
@ -545,7 +545,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// original type that has the associated function for accurate suggestions.
|
||||
// (#61411)
|
||||
let ty = tcx.at(span).type_of(*impl_did);
|
||||
match (&ty.peel_refs().kind, &actual.peel_refs().kind) {
|
||||
match (&ty.peel_refs().kind(), &actual.peel_refs().kind()) {
|
||||
(ty::Adt(def, _), ty::Adt(def_actual, _)) if def == def_actual => {
|
||||
// Use `actual` as it will have more `substs` filled in.
|
||||
self.ty_to_value_string(actual.peel_refs())
|
||||
|
@ -583,9 +583,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|self_ty: Ty<'tcx>, parent_pred: &ty::Predicate<'tcx>, obligation: &str| {
|
||||
// We don't care about regions here, so it's fine to skip the binder here.
|
||||
if let (ty::Param(_), ty::PredicateAtom::Trait(p, _)) =
|
||||
(&self_ty.kind, parent_pred.skip_binders())
|
||||
(self_ty.kind(), parent_pred.skip_binders())
|
||||
{
|
||||
if let ty::Adt(def, _) = p.trait_ref.self_ty().kind {
|
||||
if let ty::Adt(def, _) = p.trait_ref.self_ty().kind() {
|
||||
let node = def.did.as_local().map(|def_id| {
|
||||
self.tcx
|
||||
.hir()
|
||||
|
@ -615,7 +615,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
"doesn't satisfy `{}`",
|
||||
if obligation.len() > 50 { quiet } else { obligation }
|
||||
);
|
||||
match &self_ty.kind {
|
||||
match &self_ty.kind() {
|
||||
// Point at the type that couldn't satisfy the bound.
|
||||
ty::Adt(def, _) => bound_spans.push((def_span(def.did), msg)),
|
||||
// Point at the trait object that couldn't satisfy the bound.
|
||||
|
@ -837,7 +837,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
);
|
||||
self.suggest_use_candidates(&mut err, help, candidates);
|
||||
}
|
||||
if let ty::Ref(region, t_type, mutability) = rcvr_ty.kind {
|
||||
if let ty::Ref(region, t_type, mutability) = rcvr_ty.kind() {
|
||||
if needs_mut {
|
||||
let trait_type = self.tcx.mk_ref(
|
||||
region,
|
||||
|
@ -856,7 +856,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
/// Print out the type for use in value namespace.
|
||||
fn ty_to_value_string(&self, ty: Ty<'tcx>) -> String {
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
ty::Adt(def, substs) => format!("{}", ty::Instance::new(def.did, substs)),
|
||||
_ => self.ty_to_string(ty),
|
||||
}
|
||||
|
@ -870,7 +870,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
call: &hir::Expr<'_>,
|
||||
span: Span,
|
||||
) {
|
||||
if let ty::Opaque(def_id, _) = ty.kind {
|
||||
if let ty::Opaque(def_id, _) = *ty.kind() {
|
||||
let future_trait = self.tcx.require_lang_item(LangItem::Future, None);
|
||||
// Future::Output
|
||||
let item_def_id = self
|
||||
|
@ -897,7 +897,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
debug!(
|
||||
"suggest_await_before_method: normalized_ty={:?}, ty_kind={:?}",
|
||||
self.resolve_vars_if_possible(&normalized_ty),
|
||||
normalized_ty.kind,
|
||||
normalized_ty.kind(),
|
||||
);
|
||||
let method_exists = self.method_exists(item_name, normalized_ty, call.hir_id, true);
|
||||
debug!("suggest_await_before_method: is_method_exist={}", method_exists);
|
||||
|
@ -1089,9 +1089,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
candidates.sort_by(|a, b| a.cmp(b).reverse());
|
||||
candidates.dedup();
|
||||
|
||||
let param_type = match rcvr_ty.kind {
|
||||
let param_type = match rcvr_ty.kind() {
|
||||
ty::Param(param) => Some(param),
|
||||
ty::Ref(_, ty, _) => match ty.kind {
|
||||
ty::Ref(_, ty, _) => match ty.kind() {
|
||||
ty::Param(param) => Some(param),
|
||||
_ => None,
|
||||
},
|
||||
|
@ -1243,7 +1243,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
/// autoderefs of `rcvr_ty`.
|
||||
fn type_derefs_to_local(&self, span: Span, rcvr_ty: Ty<'tcx>, source: SelfSource<'_>) -> bool {
|
||||
fn is_local(ty: Ty<'_>) -> bool {
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
ty::Adt(def, _) => def.did.is_local(),
|
||||
ty::Foreign(did) => did.is_local(),
|
||||
|
||||
|
|
|
@ -329,7 +329,7 @@ impl<'a, 'tcx> Expectation<'tcx> {
|
|||
/// See the test case `test/ui/coerce-expect-unsized.rs` and #20169
|
||||
/// for examples of where this comes up,.
|
||||
fn rvalue_hint(fcx: &FnCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> {
|
||||
match fcx.tcx.struct_tail_without_normalization(ty).kind {
|
||||
match fcx.tcx.struct_tail_without_normalization(ty).kind() {
|
||||
ty::Slice(_) | ty::Str | ty::Dynamic(..) => ExpectRvalueLikeUnsized(ty),
|
||||
_ => ExpectHasType(ty),
|
||||
}
|
||||
|
@ -884,7 +884,7 @@ where
|
|||
}
|
||||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.kind {
|
||||
match *ty.kind() {
|
||||
ty::Opaque(def_id, substs) => {
|
||||
debug!("fixup_opaque_types: found type {:?}", ty);
|
||||
// Here, we replace any inference variables that occur within
|
||||
|
@ -900,7 +900,7 @@ where
|
|||
let old_param = substs[param.index as usize];
|
||||
match old_param.unpack() {
|
||||
GenericArgKind::Type(old_ty) => {
|
||||
if let ty::Infer(_) = old_ty.kind {
|
||||
if let ty::Infer(_) = old_ty.kind() {
|
||||
// Replace inference type with a generic parameter
|
||||
self.tcx.mk_param_from_def(param)
|
||||
} else {
|
||||
|
@ -1366,7 +1366,7 @@ fn check_fn<'a, 'tcx>(
|
|||
|
||||
inherited.typeck_results.borrow_mut().liberated_fn_sigs_mut().insert(fn_id, fn_sig);
|
||||
|
||||
if let ty::Dynamic(..) = declared_ret_ty.kind {
|
||||
if let ty::Dynamic(..) = declared_ret_ty.kind() {
|
||||
// FIXME: We need to verify that the return type is `Sized` after the return expression has
|
||||
// been evaluated so that we have types available for all the nodes being returned, but that
|
||||
// requires the coerced evaluated type to be stored. Moving `check_return_expr` before this
|
||||
|
@ -1465,15 +1465,15 @@ fn check_fn<'a, 'tcx>(
|
|||
if let Some(panic_impl_did) = tcx.lang_items().panic_impl() {
|
||||
if panic_impl_did == hir.local_def_id(fn_id).to_def_id() {
|
||||
if let Some(panic_info_did) = tcx.lang_items().panic_info() {
|
||||
if declared_ret_ty.kind != ty::Never {
|
||||
if *declared_ret_ty.kind() != ty::Never {
|
||||
sess.span_err(decl.output.span(), "return type should be `!`");
|
||||
}
|
||||
|
||||
let inputs = fn_sig.inputs();
|
||||
let span = hir.span(fn_id);
|
||||
if inputs.len() == 1 {
|
||||
let arg_is_panic_info = match inputs[0].kind {
|
||||
ty::Ref(region, ty, mutbl) => match ty.kind {
|
||||
let arg_is_panic_info = match *inputs[0].kind() {
|
||||
ty::Ref(region, ty, mutbl) => match *ty.kind() {
|
||||
ty::Adt(ref adt, _) => {
|
||||
adt.did == panic_info_did
|
||||
&& mutbl == hir::Mutability::Not
|
||||
|
@ -1509,14 +1509,14 @@ fn check_fn<'a, 'tcx>(
|
|||
if let Some(alloc_error_handler_did) = tcx.lang_items().oom() {
|
||||
if alloc_error_handler_did == hir.local_def_id(fn_id).to_def_id() {
|
||||
if let Some(alloc_layout_did) = tcx.lang_items().alloc_layout() {
|
||||
if declared_ret_ty.kind != ty::Never {
|
||||
if *declared_ret_ty.kind() != ty::Never {
|
||||
sess.span_err(decl.output.span(), "return type should be `!`");
|
||||
}
|
||||
|
||||
let inputs = fn_sig.inputs();
|
||||
let span = hir.span(fn_id);
|
||||
if inputs.len() == 1 {
|
||||
let arg_is_alloc_layout = match inputs[0].kind {
|
||||
let arg_is_alloc_layout = match inputs[0].kind() {
|
||||
ty::Adt(ref adt, _) => adt.did == alloc_layout_did,
|
||||
_ => false,
|
||||
};
|
||||
|
@ -1577,7 +1577,7 @@ fn check_union(tcx: TyCtxt<'_>, id: hir::HirId, span: Span) {
|
|||
/// check that the fields of the `union` does not contain fields that need dropping.
|
||||
fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> bool {
|
||||
let item_type = tcx.type_of(item_def_id);
|
||||
if let ty::Adt(def, substs) = item_type.kind {
|
||||
if let ty::Adt(def, substs) = item_type.kind() {
|
||||
assert!(def.is_union());
|
||||
let fields = &def.non_enum_variant().fields;
|
||||
let param_env = tcx.param_env(item_def_id);
|
||||
|
@ -1598,7 +1598,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
|||
}
|
||||
}
|
||||
} else {
|
||||
span_bug!(span, "unions must be ty::Adt, but got {:?}", item_type.kind);
|
||||
span_bug!(span, "unions must be ty::Adt, but got {:?}", item_type.kind());
|
||||
}
|
||||
true
|
||||
}
|
||||
|
@ -1758,7 +1758,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) {
|
|||
.returns
|
||||
.iter()
|
||||
.filter_map(|expr| typeck_results.node_type_opt(expr.hir_id))
|
||||
.all(|ty| matches!(ty.kind, ty::Never))
|
||||
.all(|ty| matches!(ty.kind(), ty::Never))
|
||||
{
|
||||
let spans = visitor
|
||||
.returns
|
||||
|
@ -1787,12 +1787,12 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) {
|
|||
.returns
|
||||
.iter()
|
||||
.filter_map(|e| typeck_results.node_type_opt(e.hir_id).map(|t| (e.span, t)))
|
||||
.filter(|(_, ty)| !matches!(ty.kind, ty::Never))
|
||||
.filter(|(_, ty)| !matches!(ty.kind(), ty::Never))
|
||||
{
|
||||
struct VisitTypes(Vec<DefId>);
|
||||
impl<'tcx> ty::fold::TypeVisitor<'tcx> for VisitTypes {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
|
||||
match t.kind {
|
||||
match *t.kind() {
|
||||
ty::Opaque(def, _) => {
|
||||
self.0.push(def);
|
||||
false
|
||||
|
@ -2426,7 +2426,7 @@ fn bounds_from_generic_predicates<'tcx>(
|
|||
"<{}>",
|
||||
types
|
||||
.keys()
|
||||
.filter_map(|t| match t.kind {
|
||||
.filter_map(|t| match t.kind() {
|
||||
ty::Param(_) => Some(t.to_string()),
|
||||
// Avoid suggesting the following:
|
||||
// fn foo<T, <T as Trait>::Bar>(_: T) where T: Trait, <T as Trait>::Bar: Other {}
|
||||
|
@ -2471,7 +2471,7 @@ fn fn_sig_suggestion<'tcx>(
|
|||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, ty)| {
|
||||
Some(match ty.kind {
|
||||
Some(match ty.kind() {
|
||||
ty::Param(_) if assoc.fn_has_self_parameter && i == 0 => "self".to_string(),
|
||||
ty::Ref(reg, ref_ty, mutability) if i == 0 => {
|
||||
let reg = match &format!("{}", reg)[..] {
|
||||
|
@ -2479,7 +2479,7 @@ fn fn_sig_suggestion<'tcx>(
|
|||
reg => format!("{} ", reg),
|
||||
};
|
||||
if assoc.fn_has_self_parameter {
|
||||
match ref_ty.kind {
|
||||
match ref_ty.kind() {
|
||||
ty::Param(param) if param.name == kw::SelfUpper => {
|
||||
format!("&{}{}self", reg, mutability.prefix_str())
|
||||
}
|
||||
|
@ -2570,7 +2570,7 @@ fn check_representable(tcx: TyCtxt<'_>, sp: Span, item_def_id: LocalDefId) -> bo
|
|||
|
||||
pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
||||
let t = tcx.type_of(def_id);
|
||||
if let ty::Adt(def, substs) = t.kind {
|
||||
if let ty::Adt(def, substs) = t.kind() {
|
||||
if def.is_struct() {
|
||||
let fields = &def.non_enum_variant().fields;
|
||||
if fields.is_empty() {
|
||||
|
@ -2584,7 +2584,7 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
|||
.emit();
|
||||
return;
|
||||
}
|
||||
match e.kind {
|
||||
match e.kind() {
|
||||
ty::Param(_) => { /* struct<T>(T, T, T, T) is ok */ }
|
||||
_ if e.is_machine() => { /* struct(u8, u8, u8, u8) is ok */ }
|
||||
_ => {
|
||||
|
@ -2678,7 +2678,7 @@ fn check_packed_inner(
|
|||
def_id: DefId,
|
||||
stack: &mut Vec<DefId>,
|
||||
) -> Option<Vec<(DefId, Span)>> {
|
||||
if let ty::Adt(def, substs) = tcx.type_of(def_id).kind {
|
||||
if let ty::Adt(def, substs) = tcx.type_of(def_id).kind() {
|
||||
if def.is_struct() || def.is_union() {
|
||||
if def.repr.align.is_some() {
|
||||
return Some(vec![(def.did, DUMMY_SP)]);
|
||||
|
@ -2686,7 +2686,7 @@ fn check_packed_inner(
|
|||
|
||||
stack.push(def_id);
|
||||
for field in &def.non_enum_variant().fields {
|
||||
if let ty::Adt(def, _) = field.ty(tcx, substs).kind {
|
||||
if let ty::Adt(def, _) = field.ty(tcx, substs).kind() {
|
||||
if !stack.contains(&def.did) {
|
||||
if let Some(mut defs) = check_packed_inner(tcx, def.did, stack) {
|
||||
defs.push((def.did, field.ident.span));
|
||||
|
@ -3862,7 +3862,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
"self_type_matches_expected_vid(trait_ref={:?}, self_ty={:?}, expected_vid={:?})",
|
||||
trait_ref, self_ty, expected_vid
|
||||
);
|
||||
match self_ty.kind {
|
||||
match *self_ty.kind() {
|
||||
ty::Infer(ty::TyVar(found_vid)) => {
|
||||
// FIXME: consider using `sub_root_var` here so we
|
||||
// can see through subtyping.
|
||||
|
@ -4042,7 +4042,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
let formal_tys = if tuple_arguments == TupleArguments {
|
||||
let tuple_type = self.structurally_resolved_type(sp, fn_inputs[0]);
|
||||
match tuple_type.kind {
|
||||
match tuple_type.kind() {
|
||||
ty::Tuple(arg_types) if arg_types.len() != args.len() => {
|
||||
param_count_error(arg_types.len(), args.len(), "E0057", false, false);
|
||||
expected_arg_tys = vec![];
|
||||
|
@ -4050,7 +4050,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
ty::Tuple(arg_types) => {
|
||||
expected_arg_tys = match expected_arg_tys.get(0) {
|
||||
Some(&ty) => match ty.kind {
|
||||
Some(&ty) => match ty.kind() {
|
||||
ty::Tuple(ref tys) => tys.iter().map(|k| k.expect_ty()).collect(),
|
||||
_ => vec![],
|
||||
},
|
||||
|
@ -4195,7 +4195,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// There are a few types which get autopromoted when passed via varargs
|
||||
// in C but we just error out instead and require explicit casts.
|
||||
let arg_ty = self.structurally_resolved_type(arg.span, arg_ty);
|
||||
match arg_ty.kind {
|
||||
match arg_ty.kind() {
|
||||
ty::Float(ast::FloatTy::F32) => {
|
||||
variadic_error(tcx.sess, arg.span, arg_ty, "c_double");
|
||||
}
|
||||
|
@ -4345,7 +4345,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
ast::LitKind::Int(_, ast::LitIntType::Signed(t)) => tcx.mk_mach_int(t),
|
||||
ast::LitKind::Int(_, ast::LitIntType::Unsigned(t)) => tcx.mk_mach_uint(t),
|
||||
ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => {
|
||||
let opt_ty = expected.to_option(self).and_then(|ty| match ty.kind {
|
||||
let opt_ty = expected.to_option(self).and_then(|ty| match ty.kind() {
|
||||
ty::Int(_) | ty::Uint(_) => Some(ty),
|
||||
ty::Char => Some(tcx.types.u8),
|
||||
ty::RawPtr(..) => Some(tcx.types.usize),
|
||||
|
@ -4356,7 +4356,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
ast::LitKind::Float(_, ast::LitFloatType::Suffixed(t)) => tcx.mk_mach_float(t),
|
||||
ast::LitKind::Float(_, ast::LitFloatType::Unsuffixed) => {
|
||||
let opt_ty = expected.to_option(self).and_then(|ty| match ty.kind {
|
||||
let opt_ty = expected.to_option(self).and_then(|ty| match ty.kind() {
|
||||
ty::Float(_) => Some(ty),
|
||||
_ => None,
|
||||
});
|
||||
|
@ -4434,12 +4434,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
self.set_tainted_by_errors();
|
||||
return None;
|
||||
}
|
||||
Res::Def(DefKind::Variant, _) => match ty.kind {
|
||||
Res::Def(DefKind::Variant, _) => match ty.kind() {
|
||||
ty::Adt(adt, substs) => Some((adt.variant_of_res(def), adt.did, substs)),
|
||||
_ => bug!("unexpected type: {:?}", ty),
|
||||
},
|
||||
Res::Def(DefKind::Struct | DefKind::Union | DefKind::TyAlias | DefKind::AssocTy, _)
|
||||
| Res::SelfTy(..) => match ty.kind {
|
||||
| Res::SelfTy(..) => match ty.kind() {
|
||||
ty::Adt(adt, substs) if !adt.is_enum() => {
|
||||
Some((adt.non_enum_variant(), adt.did, substs))
|
||||
}
|
||||
|
@ -4976,7 +4976,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
found: Ty<'tcx>,
|
||||
) -> bool {
|
||||
let hir = self.tcx.hir();
|
||||
let (def_id, sig) = match found.kind {
|
||||
let (def_id, sig) = match *found.kind() {
|
||||
ty::FnDef(def_id, _) => (def_id, found.fn_sig(self.tcx)),
|
||||
ty::Closure(def_id, substs) => (def_id, substs.as_closure().sig()),
|
||||
_ => return false,
|
||||
|
@ -5109,7 +5109,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
if let Some((sp, msg, suggestion, applicability)) = self.check_ref(expr, found, expected) {
|
||||
err.span_suggestion(sp, msg, suggestion, applicability);
|
||||
} else if let (ty::FnDef(def_id, ..), true) =
|
||||
(&found.kind, self.suggest_fn_call(err, expr, expected, found))
|
||||
(&found.kind(), self.suggest_fn_call(err, expr, expected, found))
|
||||
{
|
||||
if let Some(sp) = self.tcx.hir().span_if_local(*def_id) {
|
||||
let sp = self.sess().source_map().guess_head_span(sp);
|
||||
|
@ -5256,7 +5256,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
return false;
|
||||
}
|
||||
let pin_did = self.tcx.lang_items().pin_type();
|
||||
match expected.kind {
|
||||
match expected.kind() {
|
||||
ty::Adt(def, _) if Some(def.did) != pin_did => return false,
|
||||
// This guards the `unwrap` and `mk_box` below.
|
||||
_ if pin_did.is_none() || self.tcx.lang_items().owned_box().is_none() => return false,
|
||||
|
@ -5268,7 +5268,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
self.can_coerce(new_found, expected),
|
||||
self.sess().source_map().span_to_snippet(expr.span),
|
||||
) {
|
||||
match found.kind {
|
||||
match found.kind() {
|
||||
ty::Adt(def, _) if def.is_box() => {
|
||||
err.help("use `Box::pin`");
|
||||
}
|
||||
|
@ -5376,7 +5376,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let ty = AstConv::ast_ty_to_ty(self, ty);
|
||||
debug!("suggest_missing_return_type: return type {:?}", ty);
|
||||
debug!("suggest_missing_return_type: expected type {:?}", ty);
|
||||
if ty.kind == expected.kind {
|
||||
if ty.kind() == expected.kind() {
|
||||
err.span_label(sp, format!("expected `{}` because of return type", expected));
|
||||
return true;
|
||||
}
|
||||
|
@ -5480,7 +5480,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
expected: Ty<'tcx>,
|
||||
found: Ty<'tcx>,
|
||||
) {
|
||||
let (sig, did, substs) = match (&expected.kind, &found.kind) {
|
||||
let (sig, did, substs) = match (&expected.kind(), &found.kind()) {
|
||||
(ty::FnDef(did1, substs1), ty::FnDef(did2, substs2)) => {
|
||||
let sig1 = self.tcx.fn_sig(*did1).subst(self.tcx, substs1);
|
||||
let sig2 = self.tcx.fn_sig(*did2).subst(self.tcx, substs2);
|
||||
|
@ -5551,7 +5551,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
_ => return None,
|
||||
};
|
||||
let last_expr_ty = self.node_ty(last_expr.hir_id);
|
||||
if matches!(last_expr_ty.kind, ty::Error(_))
|
||||
if matches!(last_expr_ty.kind(), ty::Error(_))
|
||||
|| self.can_sub(self.param_env, last_expr_ty, expected_ty).is_err()
|
||||
{
|
||||
return None;
|
||||
|
@ -5680,7 +5680,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
let (res, self_ctor_substs) = if let Res::SelfCtor(impl_def_id) = res {
|
||||
let ty = self.normalize_ty(span, tcx.at(span).type_of(impl_def_id));
|
||||
match ty.kind {
|
||||
match *ty.kind() {
|
||||
ty::Adt(adt_def, substs) if adt_def.has_ctor() => {
|
||||
let variant = adt_def.non_enum_variant();
|
||||
let ctor_def_id = variant.ctor_def_id.unwrap();
|
||||
|
@ -5992,7 +5992,7 @@ fn check_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, generics: &ty::Generics,
|
|||
|
||||
for leaf in ty.walk() {
|
||||
if let GenericArgKind::Type(leaf_ty) = leaf.unpack() {
|
||||
if let ty::Param(param) = leaf_ty.kind {
|
||||
if let ty::Param(param) = leaf_ty.kind() {
|
||||
debug!("found use of ty param {:?}", param);
|
||||
params_used.insert(param.index);
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
Ok(method) => {
|
||||
let by_ref_binop = !op.node.is_by_value();
|
||||
if is_assign == IsAssign::Yes || by_ref_binop {
|
||||
if let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].kind {
|
||||
if let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].kind() {
|
||||
let mutbl = match mutbl {
|
||||
hir::Mutability::Not => AutoBorrowMutability::Not,
|
||||
hir::Mutability::Mut => AutoBorrowMutability::Mut {
|
||||
|
@ -223,7 +223,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
if by_ref_binop {
|
||||
if let ty::Ref(region, _, mutbl) = method.sig.inputs()[1].kind {
|
||||
if let ty::Ref(region, _, mutbl) = method.sig.inputs()[1].kind() {
|
||||
let mutbl = match mutbl {
|
||||
hir::Mutability::Not => AutoBorrowMutability::Not,
|
||||
hir::Mutability::Mut => AutoBorrowMutability::Mut {
|
||||
|
@ -395,7 +395,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
};
|
||||
let mut suggested_deref = false;
|
||||
if let Ref(_, rty, _) = lhs_ty.kind {
|
||||
if let Ref(_, rty, _) = lhs_ty.kind() {
|
||||
if {
|
||||
self.infcx.type_is_copy_modulo_regions(self.param_env, rty, lhs_expr.span)
|
||||
&& self
|
||||
|
@ -436,7 +436,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// concatenation (e.g., "Hello " + "World!"). This means
|
||||
// we don't want the note in the else clause to be emitted
|
||||
} else if let [ty] = &visitor.0[..] {
|
||||
if let ty::Param(p) = ty.kind {
|
||||
if let ty::Param(p) = *ty.kind() {
|
||||
// Check if the method would be found if the type param wasn't
|
||||
// involved. If so, it means that adding a trait bound to the param is
|
||||
// enough. Otherwise we do not give the suggestion.
|
||||
|
@ -468,7 +468,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
));
|
||||
}
|
||||
} else {
|
||||
bug!("type param visitor stored a non type param: {:?}", ty.kind);
|
||||
bug!("type param visitor stored a non type param: {:?}", ty.kind());
|
||||
}
|
||||
} else if !suggested_deref && !involves_fn {
|
||||
suggest_impl_missing(&mut err, lhs_ty, &missing_trait);
|
||||
|
@ -494,7 +494,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
is_assign: IsAssign,
|
||||
) -> bool /* did we suggest to call a function because of missing parenthesis? */ {
|
||||
err.span_label(span, ty.to_string());
|
||||
if let FnDef(def_id, _) = ty.kind {
|
||||
if let FnDef(def_id, _) = *ty.kind() {
|
||||
let source_map = self.tcx.sess.source_map();
|
||||
if !self.tcx.has_typeck_results(def_id) {
|
||||
return false;
|
||||
|
@ -502,7 +502,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// We're emitting a suggestion, so we can just ignore regions
|
||||
let fn_sig = self.tcx.fn_sig(def_id).skip_binder();
|
||||
|
||||
let other_ty = if let FnDef(def_id, _) = other_ty.kind {
|
||||
let other_ty = if let FnDef(def_id, _) = *other_ty.kind() {
|
||||
if !self.tcx.has_typeck_results(def_id) {
|
||||
return false;
|
||||
}
|
||||
|
@ -568,10 +568,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
None => false,
|
||||
};
|
||||
|
||||
match (&lhs_ty.kind, &rhs_ty.kind) {
|
||||
match (lhs_ty.kind(), rhs_ty.kind()) {
|
||||
(&Ref(_, l_ty, _), &Ref(_, r_ty, _)) // &str or &String + &str, &String or &&str
|
||||
if (l_ty.kind == Str || is_std_string(l_ty)) && (
|
||||
r_ty.kind == Str || is_std_string(r_ty) ||
|
||||
if (*l_ty.kind() == Str || is_std_string(l_ty)) && (
|
||||
*r_ty.kind() == Str || is_std_string(r_ty) ||
|
||||
&format!("{:?}", rhs_ty) == "&&str"
|
||||
) =>
|
||||
{
|
||||
|
@ -605,7 +605,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
true
|
||||
}
|
||||
(&Ref(_, l_ty, _), &Adt(..)) // Handle `&str` & `&String` + `String`
|
||||
if (l_ty.kind == Str || is_std_string(l_ty)) && is_std_string(rhs_ty) =>
|
||||
if (*l_ty.kind() == Str || is_std_string(l_ty)) && is_std_string(rhs_ty) =>
|
||||
{
|
||||
err.span_label(
|
||||
op.span,
|
||||
|
@ -670,12 +670,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
ex.span,
|
||||
format!("cannot apply unary operator `{}`", op.as_str()),
|
||||
);
|
||||
match actual.kind {
|
||||
match actual.kind() {
|
||||
Uint(_) if op == hir::UnOp::UnNeg => {
|
||||
err.note("unsigned values cannot be negated");
|
||||
}
|
||||
Str | Never | Char | Tuple(_) | Array(_, _) => {}
|
||||
Ref(_, ref lty, _) if lty.kind == Str => {}
|
||||
Ref(_, ref lty, _) if *lty.kind() == Str => {}
|
||||
_ => {
|
||||
let missing_trait = match op {
|
||||
hir::UnOp::UnNeg => "std::ops::Neg",
|
||||
|
@ -844,7 +844,7 @@ enum Op {
|
|||
|
||||
/// Dereferences a single level of immutable referencing.
|
||||
fn deref_ty_if_possible(ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
ty::Ref(_, ty, hir::Mutability::Not) => ty,
|
||||
_ => ty,
|
||||
}
|
||||
|
@ -903,7 +903,7 @@ fn is_builtin_binop<'tcx>(lhs: Ty<'tcx>, rhs: Ty<'tcx>, op: hir::BinOp) -> bool
|
|||
|
||||
/// If applicable, note that an implementation of `trait` for `ty` may fix the error.
|
||||
fn suggest_impl_missing(err: &mut DiagnosticBuilder<'_>, ty: Ty<'_>, missing_trait: &str) {
|
||||
if let Adt(def, _) = ty.peel_refs().kind {
|
||||
if let Adt(def, _) = ty.peel_refs().kind() {
|
||||
if def.did.is_local() {
|
||||
err.note(&format!(
|
||||
"an implementation of `{}` might be missing for `{}`",
|
||||
|
@ -957,7 +957,7 @@ struct TypeParamVisitor<'tcx>(Vec<Ty<'tcx>>);
|
|||
|
||||
impl<'tcx> TypeVisitor<'tcx> for TypeParamVisitor<'tcx> {
|
||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
|
||||
if let ty::Param(_) = ty.kind {
|
||||
if let ty::Param(_) = ty.kind() {
|
||||
self.0.push(ty);
|
||||
}
|
||||
ty.super_visit_with(self)
|
||||
|
@ -972,7 +972,7 @@ impl TypeFolder<'tcx> for TypeParamEraser<'_, 'tcx> {
|
|||
}
|
||||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
ty::Param(_) => self.0.next_ty_var(TypeVariableOrigin {
|
||||
kind: TypeVariableOriginKind::MiscVariable,
|
||||
span: self.1,
|
||||
|
|
|
@ -281,7 +281,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// String and byte-string literals result in types `&str` and `&[u8]` respectively.
|
||||
// All other literals result in non-reference types.
|
||||
// As a result, we allow `if let 0 = &&0 {}` but not `if let "foo" = &&"foo {}`.
|
||||
PatKind::Lit(lt) => match self.check_expr(lt).kind {
|
||||
PatKind::Lit(lt) => match self.check_expr(lt).kind() {
|
||||
ty::Ref(..) => AdjustMode::Pass,
|
||||
_ => AdjustMode::Peel,
|
||||
},
|
||||
|
@ -341,7 +341,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
//
|
||||
// See the examples in `ui/match-defbm*.rs`.
|
||||
let mut pat_adjustments = vec![];
|
||||
while let ty::Ref(_, inner_ty, inner_mutability) = expected.kind {
|
||||
while let ty::Ref(_, inner_ty, inner_mutability) = *expected.kind() {
|
||||
debug!("inspecting {:?}", expected);
|
||||
|
||||
debug!("current discriminant is Ref, inserting implicit deref");
|
||||
|
@ -389,9 +389,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let mut pat_ty = ty;
|
||||
if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(_), .. }) = lt.kind {
|
||||
let expected = self.structurally_resolved_type(span, expected);
|
||||
if let ty::Ref(_, ty::TyS { kind: ty::Slice(_), .. }, _) = expected.kind {
|
||||
let tcx = self.tcx;
|
||||
pat_ty = tcx.mk_imm_ref(tcx.lifetimes.re_static, tcx.mk_slice(tcx.types.u8));
|
||||
if let ty::Ref(_, inner_ty, _) = expected.kind() {
|
||||
if matches!(inner_ty.kind(), ty::Slice(_)) {
|
||||
let tcx = self.tcx;
|
||||
pat_ty = tcx.mk_imm_ref(tcx.lifetimes.re_static, tcx.mk_slice(tcx.types.u8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -639,7 +641,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
pub fn check_dereferenceable(&self, span: Span, expected: Ty<'tcx>, inner: &Pat<'_>) -> bool {
|
||||
if let PatKind::Binding(..) = inner.kind {
|
||||
if let Some(mt) = self.shallow_resolve(expected).builtin_deref(true) {
|
||||
if let ty::Dynamic(..) = mt.ty.kind {
|
||||
if let ty::Dynamic(..) = mt.ty.kind() {
|
||||
// This is "x = SomeTrait" being reduced from
|
||||
// "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
|
||||
let type_str = self.ty_to_string(expected);
|
||||
|
@ -871,7 +873,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
if subpats.len() == variant.fields.len()
|
||||
|| subpats.len() < variant.fields.len() && ddpos.is_some()
|
||||
{
|
||||
let substs = match pat_ty.kind {
|
||||
let substs = match pat_ty.kind() {
|
||||
ty::Adt(_, substs) => substs,
|
||||
_ => bug!("unexpected pattern type {:?}", pat_ty),
|
||||
};
|
||||
|
@ -924,13 +926,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// More generally, the expected type wants a tuple variant with one field of an
|
||||
// N-arity-tuple, e.g., `V_i((p_0, .., p_N))`. Meanwhile, the user supplied a pattern
|
||||
// with the subpatterns directly in the tuple variant pattern, e.g., `V_i(p_0, .., p_N)`.
|
||||
let missing_parenthesis = match (&expected.kind, fields, had_err) {
|
||||
let missing_parenthesis = match (&expected.kind(), fields, had_err) {
|
||||
// #67037: only do this if we could successfully type-check the expected type against
|
||||
// the tuple struct pattern. Otherwise the substs could get out of range on e.g.,
|
||||
// `let P() = U;` where `P != U` with `struct P<T>(T);`.
|
||||
(ty::Adt(_, substs), [field], false) => {
|
||||
let field_ty = self.field_ty(pat_span, field, substs);
|
||||
match field_ty.kind {
|
||||
match field_ty.kind() {
|
||||
ty::Tuple(_) => field_ty.tuple_fields().count() == subpats.len(),
|
||||
_ => false,
|
||||
}
|
||||
|
@ -981,7 +983,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let mut expected_len = elements.len();
|
||||
if ddpos.is_some() {
|
||||
// Require known type only when `..` is present.
|
||||
if let ty::Tuple(ref tys) = self.structurally_resolved_type(span, expected).kind {
|
||||
if let ty::Tuple(ref tys) = self.structurally_resolved_type(span, expected).kind() {
|
||||
expected_len = tys.len();
|
||||
}
|
||||
}
|
||||
|
@ -1025,7 +1027,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
) -> bool {
|
||||
let tcx = self.tcx;
|
||||
|
||||
let (substs, adt) = match adt_ty.kind {
|
||||
let (substs, adt) = match adt_ty.kind() {
|
||||
ty::Adt(adt, substs) => (substs, adt),
|
||||
_ => span_bug!(pat.span, "struct pattern is not an ADT"),
|
||||
};
|
||||
|
@ -1378,7 +1380,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// to avoid creating needless variables. This also helps with
|
||||
// the bad interactions of the given hack detailed in (note_1).
|
||||
debug!("check_pat_ref: expected={:?}", expected);
|
||||
match expected.kind {
|
||||
match *expected.kind() {
|
||||
ty::Ref(_, r_ty, r_mutbl) if r_mutbl == mutbl => (expected, r_ty),
|
||||
_ => {
|
||||
let inner_ty = self.next_ty_var(TypeVariableOrigin {
|
||||
|
@ -1434,7 +1436,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
ti: TopInfo<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
let expected = self.structurally_resolved_type(span, expected);
|
||||
let (element_ty, opt_slice_ty, inferred) = match expected.kind {
|
||||
let (element_ty, opt_slice_ty, inferred) = match *expected.kind() {
|
||||
// An array, so we might have something like `let [a, b, c] = [0, 1, 2];`.
|
||||
ty::Array(element_ty, len) => {
|
||||
let min = before.len() as u64 + after.len() as u64;
|
||||
|
@ -1570,8 +1572,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
"expected an array or slice, found `{}`",
|
||||
expected_ty
|
||||
);
|
||||
if let ty::Ref(_, ty, _) = expected_ty.kind {
|
||||
if let ty::Array(..) | ty::Slice(..) = ty.kind {
|
||||
if let ty::Ref(_, ty, _) = expected_ty.kind() {
|
||||
if let ty::Array(..) | ty::Slice(..) = ty.kind() {
|
||||
err.help("the semantics of slice patterns changed recently; see issue #62254");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
let ok = self.try_overloaded_deref(expr.span, oprnd_ty)?;
|
||||
let method = self.register_infer_ok_obligations(ok);
|
||||
if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].kind {
|
||||
if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].kind() {
|
||||
self.apply_adjustments(
|
||||
oprnd_expr,
|
||||
vec![Adjustment {
|
||||
|
@ -86,7 +86,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let mut self_ty = adjusted_ty;
|
||||
if unsize {
|
||||
// We only unsize arrays here.
|
||||
if let ty::Array(element_ty, _) = adjusted_ty.kind {
|
||||
if let ty::Array(element_ty, _) = adjusted_ty.kind() {
|
||||
self_ty = self.tcx.mk_slice(element_ty);
|
||||
} else {
|
||||
continue;
|
||||
|
@ -108,7 +108,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let method = self.register_infer_ok_obligations(ok);
|
||||
|
||||
let mut adjustments = self.adjust_steps(autoderef);
|
||||
if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].kind {
|
||||
if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].kind() {
|
||||
adjustments.push(Adjustment {
|
||||
kind: Adjust::Borrow(AutoBorrow::Ref(region, AutoBorrowMutability::Not)),
|
||||
target: self.tcx.mk_ref(
|
||||
|
@ -233,7 +233,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
PlaceOp::Deref,
|
||||
) {
|
||||
let method = self.register_infer_ok_obligations(ok);
|
||||
if let ty::Ref(region, _, mutbl) = method.sig.output().kind {
|
||||
if let ty::Ref(region, _, mutbl) = *method.sig.output().kind() {
|
||||
*deref = OverloadedDeref { region, mutbl };
|
||||
}
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
debug!("convert_place_op_to_mutable: method={:?}", method);
|
||||
self.write_method_call(expr.hir_id, method);
|
||||
|
||||
let region = if let ty::Ref(r, _, hir::Mutability::Mut) = method.sig.inputs()[0].kind {
|
||||
let region = if let ty::Ref(r, _, hir::Mutability::Mut) = method.sig.inputs()[0].kind() {
|
||||
r
|
||||
} else {
|
||||
span_bug!(expr.span, "input to mutable place op is not a mut ref?");
|
||||
|
|
|
@ -624,7 +624,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
|
|||
);
|
||||
|
||||
let rptr_ty = self.resolve_node_type(id);
|
||||
if let ty::Ref(r, _, _) = rptr_ty.kind {
|
||||
if let ty::Ref(r, _, _) = rptr_ty.kind() {
|
||||
debug!("rptr_ty={}", rptr_ty);
|
||||
self.link_region(span, r, ty::BorrowKind::from_mutbl(mutbl), cmt_borrowed);
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
|
|||
"link_region(borrow_region={:?}, borrow_kind={:?}, pointer_ty={:?})",
|
||||
borrow_region, borrow_kind, borrow_place
|
||||
);
|
||||
match pointer_ty.kind {
|
||||
match *pointer_ty.kind() {
|
||||
ty::RawPtr(_) => return,
|
||||
ty::Ref(ref_region, _, ref_mutability) => {
|
||||
if self.link_reborrowed_region(span, borrow_region, ref_region, ref_mutability)
|
||||
|
@ -794,7 +794,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
|
|||
|
||||
// A closure capture can't be borrowed for longer than the
|
||||
// reference to the closure.
|
||||
if let ty::Closure(_, substs) = ty.kind {
|
||||
if let ty::Closure(_, substs) = ty.kind() {
|
||||
match self.infcx.closure_kind(substs) {
|
||||
Some(ty::ClosureKind::Fn | ty::ClosureKind::FnMut) => {
|
||||
// Region of environment pointer
|
||||
|
|
|
@ -88,7 +88,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
// Extract the type of the closure.
|
||||
let ty = self.node_ty(closure_hir_id);
|
||||
let (closure_def_id, substs) = match ty.kind {
|
||||
let (closure_def_id, substs) = match *ty.kind() {
|
||||
ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)),
|
||||
ty::Generator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)),
|
||||
ty::Error(_) => {
|
||||
|
@ -349,7 +349,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
|
|||
if let PlaceBase::Upvar(upvar_id) = place_with_id.place.base {
|
||||
let mut borrow_kind = ty::MutBorrow;
|
||||
for pointer_ty in place_with_id.place.deref_tys() {
|
||||
match pointer_ty.kind {
|
||||
match pointer_ty.kind() {
|
||||
// Raw pointers don't inherit mutability.
|
||||
ty::RawPtr(_) => return,
|
||||
// assignment to deref of an `&mut`
|
||||
|
|
|
@ -291,7 +291,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
|
|||
let err_ty_str;
|
||||
let mut is_ptr = true;
|
||||
let err = if tcx.features().min_const_generics {
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Error(_) => None,
|
||||
ty::FnPtr(_) => Some("function pointers"),
|
||||
ty::RawPtr(_) => Some("raw pointers"),
|
||||
|
@ -302,7 +302,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
match ty.peel_refs().kind {
|
||||
match ty.peel_refs().kind() {
|
||||
ty::FnPtr(_) => Some("function pointers"),
|
||||
ty::RawPtr(_) => Some("raw pointers"),
|
||||
_ => None,
|
||||
|
@ -338,7 +338,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
|
|||
// We use the same error code in both branches, because this is really the same
|
||||
// issue: we just special-case the message for type parameters to make it
|
||||
// clearer.
|
||||
if let ty::Param(_) = ty.peel_refs().kind {
|
||||
if let ty::Param(_) = ty.peel_refs().kind() {
|
||||
// Const parameters may not have type parameters as their types,
|
||||
// because we cannot be sure that the type parameter derives `PartialEq`
|
||||
// and `Eq` (just implementing them is not enough for `structural_match`).
|
||||
|
@ -638,7 +638,7 @@ fn check_associated_type_defaults(fcx: &FnCtxt<'_, '_>, trait_def_id: DefId) {
|
|||
}
|
||||
|
||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match t.kind {
|
||||
match t.kind() {
|
||||
ty::Projection(proj_ty) => {
|
||||
if let Some(default) = self.map.get(&proj_ty) {
|
||||
default
|
||||
|
@ -709,7 +709,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: hir::HirId, ty_span: Span, allow_fo
|
|||
let mut forbid_unsized = true;
|
||||
if allow_foreign_ty {
|
||||
let tail = fcx.tcx.struct_tail_erasing_lifetimes(item_ty, fcx.param_env);
|
||||
if let ty::Foreign(_) = tail.kind {
|
||||
if let ty::Foreign(_) = tail.kind() {
|
||||
forbid_unsized = false;
|
||||
}
|
||||
}
|
||||
|
@ -867,7 +867,7 @@ fn check_where_clauses<'tcx, 'fcx>(
|
|||
}
|
||||
impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
|
||||
if let ty::Param(param) = t.kind {
|
||||
if let ty::Param(param) = t.kind() {
|
||||
self.params.insert(param.index);
|
||||
}
|
||||
t.super_visit_with(self)
|
||||
|
@ -1001,7 +1001,7 @@ fn check_opaque_types<'fcx, 'tcx>(
|
|||
ty.fold_with(&mut ty::fold::BottomUpFolder {
|
||||
tcx: fcx.tcx,
|
||||
ty_op: |ty| {
|
||||
if let ty::Opaque(def_id, substs) = ty.kind {
|
||||
if let ty::Opaque(def_id, substs) = *ty.kind() {
|
||||
trace!("check_opaque_types: opaque_ty, {:?}, {:?}", def_id, substs);
|
||||
let generics = tcx.generics_of(def_id);
|
||||
|
||||
|
@ -1044,7 +1044,7 @@ fn check_opaque_types<'fcx, 'tcx>(
|
|||
let mut seen_params: FxHashMap<_, Vec<_>> = FxHashMap::default();
|
||||
for (i, arg) in substs.iter().enumerate() {
|
||||
let arg_is_param = match arg.unpack() {
|
||||
GenericArgKind::Type(ty) => matches!(ty.kind, ty::Param(_)),
|
||||
GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)),
|
||||
|
||||
GenericArgKind::Lifetime(region) => {
|
||||
if let ty::ReStatic = region {
|
||||
|
|
|
@ -193,7 +193,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
let mut typeck_results = self.fcx.typeck_results.borrow_mut();
|
||||
|
||||
// All valid indexing looks like this; might encounter non-valid indexes at this point.
|
||||
let base_ty = typeck_results.expr_ty_adjusted_opt(&base).map(|t| &t.kind);
|
||||
let base_ty = typeck_results.expr_ty_adjusted_opt(&base).map(|t| t.kind());
|
||||
if base_ty.is_none() {
|
||||
// When encountering `return [0][0]` outside of a `fn` body we can encounter a base
|
||||
// that isn't in the type table. We assume more relevant errors have already been
|
||||
|
@ -459,7 +459,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
|
||||
let mut skip_add = false;
|
||||
|
||||
if let ty::Opaque(defin_ty_def_id, _substs) = definition_ty.kind {
|
||||
if let ty::Opaque(defin_ty_def_id, _substs) = *definition_ty.kind() {
|
||||
if let hir::OpaqueTyOrigin::Misc = opaque_defn.origin {
|
||||
if def_id == defin_ty_def_id {
|
||||
debug!(
|
||||
|
|
|
@ -48,7 +48,7 @@ impl<'tcx> Checker<'tcx> {
|
|||
|
||||
fn visit_implementation_of_drop(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
||||
// Destructors only work on nominal types.
|
||||
if let ty::Adt(..) | ty::Error(_) = tcx.type_of(impl_did).kind {
|
||||
if let ty::Adt(..) | ty::Error(_) = tcx.type_of(impl_did).kind() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||
let cause = ObligationCause::misc(span, impl_hir_id);
|
||||
|
||||
use ty::TyKind::*;
|
||||
match (&source.kind, &target.kind) {
|
||||
match (source.kind(), target.kind()) {
|
||||
(&Ref(r_a, _, mutbl_a), Ref(r_b, _, mutbl_b))
|
||||
if infcx.at(&cause, param_env).eq(r_a, r_b).is_ok() && mutbl_a == *mutbl_b => {}
|
||||
(&RawPtr(tm_a), &RawPtr(tm_b)) if tm_a.mutbl == tm_b.mutbl => (),
|
||||
|
@ -352,7 +352,7 @@ pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedI
|
|||
}
|
||||
(mt_a.ty, mt_b.ty, unsize_trait, None)
|
||||
};
|
||||
let (source, target, trait_def_id, kind) = match (&source.kind, &target.kind) {
|
||||
let (source, target, trait_def_id, kind) = match (source.kind(), target.kind()) {
|
||||
(&ty::Ref(r_a, ty_a, mutbl_a), &ty::Ref(r_b, ty_b, mutbl_b)) => {
|
||||
infcx.sub_regions(infer::RelateObjectBound(span), r_b, r_a);
|
||||
let mt_a = ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a };
|
||||
|
|
|
@ -52,7 +52,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
|||
let def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
let self_ty = self.tcx.type_of(def_id);
|
||||
let lang_items = self.tcx.lang_items();
|
||||
match self_ty.kind {
|
||||
match *self_ty.kind() {
|
||||
ty::Adt(def, _) => {
|
||||
self.check_def_id(item, def.did);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
|||
);
|
||||
}
|
||||
ty::RawPtr(ty::TypeAndMut { ty: inner, mutbl: hir::Mutability::Not })
|
||||
if matches!(inner.kind, ty::Slice(_)) =>
|
||||
if matches!(inner.kind(), ty::Slice(_)) =>
|
||||
{
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
|
@ -135,7 +135,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
|||
);
|
||||
}
|
||||
ty::RawPtr(ty::TypeAndMut { ty: inner, mutbl: hir::Mutability::Mut })
|
||||
if matches!(inner.kind, ty::Slice(_)) =>
|
||||
if matches!(inner.kind(), ty::Slice(_)) =>
|
||||
{
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
|
|
|
@ -209,7 +209,7 @@ fn check_object_overlap<'tcx>(
|
|||
}
|
||||
|
||||
// check for overlap with the automatic `impl Trait for dyn Trait`
|
||||
if let ty::Dynamic(ref data, ..) = trait_ref.self_ty().kind {
|
||||
if let ty::Dynamic(ref data, ..) = trait_ref.self_ty().kind() {
|
||||
// This is something like impl Trait1 for Trait2. Illegal
|
||||
// if Trait1 is a supertrait of Trait2 or Trait2 is not object safe.
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> {
|
|||
// Remove the lifetimes unnecessary for this error.
|
||||
ty = infcx.freshen(ty);
|
||||
});
|
||||
ty = match ty.kind {
|
||||
ty = match ty.kind() {
|
||||
// Remove the type arguments from the output, as they are not relevant.
|
||||
// You can think of this as the reverse of `resolve_vars_if_possible`.
|
||||
// That way if we had `Vec<MyType>`, we will properly attribute the
|
||||
|
@ -62,7 +62,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> {
|
|||
_ => ty,
|
||||
};
|
||||
let this = "this".to_string();
|
||||
let (ty, postfix) = match &ty.kind {
|
||||
let (ty, postfix) = match &ty.kind() {
|
||||
ty::Slice(_) => (this, " because slices are always foreign"),
|
||||
ty::Array(..) => (this, " because arrays are always foreign"),
|
||||
ty::Tuple(..) => (this, " because tuples are always foreign"),
|
||||
|
@ -185,7 +185,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> {
|
|||
);
|
||||
if self.tcx.trait_is_auto(trait_def_id) && !trait_def_id.is_local() {
|
||||
let self_ty = trait_ref.self_ty();
|
||||
let opt_self_def_id = match self_ty.kind {
|
||||
let opt_self_def_id = match *self_ty.kind() {
|
||||
ty::Adt(self_def, _) => Some(self_def.did),
|
||||
ty::Foreign(did) => Some(did),
|
||||
_ => None,
|
||||
|
|
|
@ -1922,7 +1922,7 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
|
|||
// That way, `where Ty:` is not a complete noop (see #53696) and `Ty`
|
||||
// is still checked for WF.
|
||||
if bound_pred.bounds.is_empty() {
|
||||
if let ty::Param(_) = ty.kind {
|
||||
if let ty::Param(_) = ty.kind() {
|
||||
// This is a `where T:`, which can be in the HIR from the
|
||||
// transformation that moves `?Sized` to `T`'s declaration.
|
||||
// We can skip the predicate because type parameters are
|
||||
|
|
|
@ -382,7 +382,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
|
|||
let mut used_params: FxHashSet<_> = FxHashSet::default();
|
||||
for (i, arg) in substs.iter().enumerate() {
|
||||
let arg_is_param = match arg.unpack() {
|
||||
GenericArgKind::Type(ty) => matches!(ty.kind, ty::Param(_)),
|
||||
GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)),
|
||||
GenericArgKind::Lifetime(lt) => {
|
||||
matches!(lt, ty::ReEarlyBound(_) | ty::ReFree(_))
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ fn infer_placeholder_type(
|
|||
}
|
||||
None => {
|
||||
let mut diag = bad_placeholder_type(tcx, vec![span]);
|
||||
if !matches!(ty.kind, ty::Error(_)) {
|
||||
if !matches!(ty.kind(), ty::Error(_)) {
|
||||
diag.span_suggestion(
|
||||
span,
|
||||
"replace `_` with the correct type",
|
||||
|
|
|
@ -57,7 +57,7 @@ struct ParameterCollector {
|
|||
|
||||
impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
|
||||
match t.kind {
|
||||
match *t.kind() {
|
||||
ty::Projection(..) | ty::Opaque(..) if !self.include_nonconstraining => {
|
||||
// projections are not injective
|
||||
return false;
|
||||
|
|
|
@ -387,7 +387,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
|
||||
// Select just those fields of the `with`
|
||||
// expression that will actually be used
|
||||
match with_place.place.ty().kind {
|
||||
match with_place.place.ty().kind() {
|
||||
ty::Adt(adt, substs) if adt.is_struct() => {
|
||||
// Consume those fields of the with expression that are needed.
|
||||
for (f_index, with_field) in adt.non_enum_variant().fields.iter().enumerate() {
|
||||
|
|
|
@ -158,7 +158,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: LocalDefId) {
|
|||
let main_id = tcx.hir().local_def_id_to_hir_id(main_def_id);
|
||||
let main_span = tcx.def_span(main_def_id);
|
||||
let main_t = tcx.type_of(main_def_id);
|
||||
match main_t.kind {
|
||||
match main_t.kind() {
|
||||
ty::FnDef(..) => {
|
||||
if let Some(Node::Item(it)) = tcx.hir().find(main_id) {
|
||||
if let hir::ItemKind::Fn(ref sig, ref generics, _) = it.kind {
|
||||
|
@ -254,7 +254,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: LocalDefId) {
|
|||
let start_id = tcx.hir().local_def_id_to_hir_id(start_def_id);
|
||||
let start_span = tcx.def_span(start_def_id);
|
||||
let start_t = tcx.type_of(start_def_id);
|
||||
match start_t.kind {
|
||||
match start_t.kind() {
|
||||
ty::FnDef(..) => {
|
||||
if let Some(Node::Item(it)) = tcx.hir().find(start_id) {
|
||||
if let hir::ItemKind::Fn(ref sig, ref generics, _) = it.kind {
|
||||
|
|
|
@ -482,7 +482,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
let place_ty = self.expr_ty(expr)?;
|
||||
let base_ty = self.expr_ty_adjusted(base)?;
|
||||
|
||||
let (region, mutbl) = match base_ty.kind {
|
||||
let (region, mutbl) = match *base_ty.kind() {
|
||||
ty::Ref(region, _, mutbl) => (region, mutbl),
|
||||
_ => span_bug!(expr.span, "cat_overloaded_place: base is not a reference"),
|
||||
};
|
||||
|
@ -542,7 +542,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
) -> McResult<VariantIdx> {
|
||||
let res = self.typeck_results.qpath_res(qpath, pat_hir_id);
|
||||
let ty = self.typeck_results.node_type(pat_hir_id);
|
||||
let adt_def = match ty.kind {
|
||||
let adt_def = match ty.kind() {
|
||||
ty::Adt(adt_def, _) => adt_def,
|
||||
_ => {
|
||||
self.tcx()
|
||||
|
@ -577,7 +577,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
span: Span,
|
||||
) -> McResult<usize> {
|
||||
let ty = self.typeck_results.node_type(pat_hir_id);
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
ty::Adt(adt_def, _) => Ok(adt_def.variants[variant_index].fields.len()),
|
||||
_ => {
|
||||
self.tcx()
|
||||
|
@ -592,7 +592,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
/// Here `pat_hir_id` is the HirId of the pattern itself.
|
||||
fn total_fields_in_tuple(&self, pat_hir_id: hir::HirId, span: Span) -> McResult<usize> {
|
||||
let ty = self.typeck_results.node_type(pat_hir_id);
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
ty::Tuple(substs) => Ok(substs.len()),
|
||||
_ => {
|
||||
self.tcx().sess.delay_span_bug(span, "tuple pattern not applied to a tuple");
|
||||
|
|
|
@ -128,7 +128,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
|
|||
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => continue,
|
||||
};
|
||||
|
||||
match ty.kind {
|
||||
match *ty.kind() {
|
||||
// The field is of type &'a T which means that we will have
|
||||
// a predicate requirement of T: 'a (T outlives 'a).
|
||||
//
|
||||
|
|
|
@ -140,7 +140,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
let id = tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
let inferred_start = self.terms_cx.inferred_starts[&id];
|
||||
let current_item = &CurrentItem { inferred_start };
|
||||
match tcx.type_of(def_id).kind {
|
||||
match tcx.type_of(def_id).kind() {
|
||||
ty::Adt(def, _) => {
|
||||
// Not entirely obvious: constraints on structs/enums do not
|
||||
// affect the variance of their type parameters. See discussion
|
||||
|
@ -257,7 +257,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
) {
|
||||
debug!("add_constraints_from_ty(ty={:?}, variance={:?})", ty, variance);
|
||||
|
||||
match ty.kind {
|
||||
match *ty.kind() {
|
||||
ty::Bool
|
||||
| ty::Char
|
||||
| ty::Int(_)
|
||||
|
|
|
@ -107,7 +107,7 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> {
|
|||
self.enforce_const_invariance(generics, variances);
|
||||
|
||||
// Functions are permitted to have unused generic parameters: make those invariant.
|
||||
if let ty::FnDef(..) = tcx.type_of(def_id).kind {
|
||||
if let ty::FnDef(..) = tcx.type_of(def_id).kind() {
|
||||
for variance in variances.iter_mut() {
|
||||
if *variance == ty::Bivariant {
|
||||
*variance = ty::Invariant;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue