Auto merge of #64513 - varkor:sty-begone, r=eddyb
Rename `TyS.sty` to `TyS.kind` Fixes https://github.com/rust-lang/rust/issues/64353. r? @eddyb
This commit is contained in:
commit
dc45735f29
179 changed files with 735 additions and 736 deletions
|
|
@ -343,7 +343,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Infer(ty::TyVar(vid)) => {
|
||||
debug!("canonical: type var found with vid {:?}", vid);
|
||||
match self.infcx.unwrap().probe_ty_var(vid) {
|
||||
|
|
|
|||
|
|
@ -471,7 +471,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
|||
match result_value.unpack() {
|
||||
UnpackedKind::Type(result_value) => {
|
||||
// e.g., here `result_value` might be `?0` in the example above...
|
||||
if let ty::Bound(debruijn, b) = result_value.sty {
|
||||
if let ty::Bound(debruijn, b) = result_value.kind {
|
||||
// ...in which case we would set `canonical_vars[0]` to `Some(?U)`.
|
||||
|
||||
// We only allow a `ty::INNERMOST` index in substitutions.
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
|
|||
{
|
||||
let a_is_expected = relation.a_is_expected();
|
||||
|
||||
match (&a.sty, &b.sty) {
|
||||
match (&a.kind, &b.kind) {
|
||||
// Relate integral variables to other types
|
||||
(&ty::Infer(ty::IntVar(a_id)), &ty::Infer(ty::IntVar(b_id))) => {
|
||||
self.int_unification_table
|
||||
|
|
@ -486,7 +486,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
|
|||
// any other type variable related to `vid` via
|
||||
// subtyping. This is basically our "occurs check", preventing
|
||||
// us from creating infinitely sized types.
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Infer(ty::TyVar(vid)) => {
|
||||
let mut variables = self.infcx.type_variables.borrow_mut();
|
||||
let vid = variables.root_var(vid);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> {
|
|||
|
||||
debug!("{}.tys: replacements ({:?}, {:?})", self.tag(), a, b);
|
||||
|
||||
match (&a.sty, &b.sty) {
|
||||
match (&a.kind, &b.kind) {
|
||||
(&ty::Infer(TyVar(a_id)), &ty::Infer(TyVar(b_id))) => {
|
||||
infcx.type_variables.borrow_mut().equate(a_id, b_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -589,7 +589,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
// if they are both "path types", there's a chance of ambiguity
|
||||
// due to different versions of the same crate
|
||||
if let (&ty::Adt(exp_adt, _), &ty::Adt(found_adt, _))
|
||||
= (&exp_found.expected.sty, &exp_found.found.sty)
|
||||
= (&exp_found.expected.kind, &exp_found.found.kind)
|
||||
{
|
||||
report_path_match(err, exp_adt.did, found_adt.did);
|
||||
}
|
||||
|
|
@ -803,7 +803,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
|
||||
return Some(());
|
||||
}
|
||||
if let &ty::Adt(def, _) = &ta.sty {
|
||||
if let &ty::Adt(def, _) = &ta.kind {
|
||||
let path_ = self.tcx.def_path_str(def.did.clone());
|
||||
if path_ == other_path {
|
||||
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
|
||||
|
|
@ -868,7 +868,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
/// relevant differences, and return two representation of those types for highlighted printing.
|
||||
fn cmp(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) -> (DiagnosticStyledString, DiagnosticStyledString) {
|
||||
fn equals<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
|
||||
match (&a.sty, &b.sty) {
|
||||
match (&a.kind, &b.kind) {
|
||||
(a, b) if *a == *b => true,
|
||||
(&ty::Int(_), &ty::Infer(ty::InferTy::IntVar(_)))
|
||||
| (&ty::Infer(ty::InferTy::IntVar(_)), &ty::Int(_))
|
||||
|
|
@ -902,7 +902,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
s.push_normal(ty.to_string());
|
||||
}
|
||||
|
||||
match (&t1.sty, &t2.sty) {
|
||||
match (&t1.kind, &t2.kind) {
|
||||
(&ty::Adt(def1, sub1), &ty::Adt(def2, sub2)) => {
|
||||
let sub_no_defaults_1 = self.strip_generic_default_params(def1.did, sub1);
|
||||
let sub_no_defaults_2 = self.strip_generic_default_params(def2.did, sub2);
|
||||
|
|
@ -1138,7 +1138,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
match (terr, is_simple_error, expected == found) {
|
||||
(&TypeError::Sorts(ref values), false, true) => {
|
||||
let sort_string = | a_type: Ty<'tcx> |
|
||||
if let ty::Opaque(def_id, _) = a_type.sty {
|
||||
if let ty::Opaque(def_id, _) = a_type.kind {
|
||||
format!(" (opaque type at {})", self.tcx.sess.source_map()
|
||||
.mk_substr_filename(self.tcx.def_span(def_id)))
|
||||
} else {
|
||||
|
|
@ -1179,9 +1179,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>,
|
||||
diag: &mut DiagnosticBuilder<'tcx>,
|
||||
) {
|
||||
match (&exp_found.expected.sty, &exp_found.found.sty) {
|
||||
match (&exp_found.expected.kind, &exp_found.found.kind) {
|
||||
(ty::Adt(exp_def, exp_substs), ty::Ref(_, found_ty, _)) => {
|
||||
if let ty::Adt(found_def, found_substs) = found_ty.sty {
|
||||
if let ty::Adt(found_def, found_substs) = found_ty.kind {
|
||||
let path_str = format!("{:?}", exp_def);
|
||||
if exp_def == &found_def {
|
||||
let opt_msg = "you can convert from `&Option<T>` to `Option<&T>` using \
|
||||
|
|
@ -1203,9 +1203,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
{
|
||||
let mut show_suggestion = true;
|
||||
for (exp_ty, found_ty) in exp_substs.types().zip(found_substs.types()) {
|
||||
match exp_ty.sty {
|
||||
match exp_ty.kind {
|
||||
ty::Ref(_, exp_ty, _) => {
|
||||
match (&exp_ty.sty, &found_ty.sty) {
|
||||
match (&exp_ty.kind, &found_ty.kind) {
|
||||
(_, ty::Param(_)) |
|
||||
(_, ty::Infer(_)) |
|
||||
(ty::Param(_), _) |
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ impl<'a, 'tcx> FindLocalByTypeVisitor<'a, 'tcx> {
|
|||
Some(ty) => {
|
||||
let ty = self.infcx.resolve_vars_if_possible(&ty);
|
||||
if ty.walk().any(|inner_ty| {
|
||||
inner_ty == self.target_ty || match (&inner_ty.sty, &self.target_ty.sty) {
|
||||
inner_ty == self.target_ty || match (&inner_ty.kind, &self.target_ty.kind) {
|
||||
(&Infer(TyVar(a_vid)), &Infer(TyVar(b_vid))) => {
|
||||
self.infcx
|
||||
.type_variables
|
||||
|
|
@ -151,7 +151,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
ty: Ty<'tcx>,
|
||||
highlight: Option<ty::print::RegionHighlightMode>,
|
||||
) -> (String, Option<Span>) {
|
||||
if let ty::Infer(ty::TyVar(ty_vid)) = ty.sty {
|
||||
if let ty::Infer(ty::TyVar(ty_vid)) = ty.kind {
|
||||
let ty_vars = self.type_variables.borrow();
|
||||
let var_origin = ty_vars.var_origin(ty_vid);
|
||||
if let TypeVariableOriginKind::TypeParameterDefinition(name) = var_origin.kind {
|
||||
|
|
@ -219,7 +219,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
};
|
||||
|
||||
let ty_msg = match local_visitor.found_ty {
|
||||
Some(ty::TyS { sty: ty::Closure(def_id, substs), .. }) => {
|
||||
Some(ty::TyS { kind: ty::Closure(def_id, substs), .. }) => {
|
||||
let fn_sig = substs.closure_sig(*def_id, self.tcx);
|
||||
let args = closure_args(&fn_sig);
|
||||
let ret = fn_sig.output().skip_binder().to_string();
|
||||
|
|
@ -254,7 +254,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
);
|
||||
|
||||
let suffix = match local_visitor.found_ty {
|
||||
Some(ty::TyS { sty: ty::Closure(def_id, substs), .. }) => {
|
||||
Some(ty::TyS { kind: ty::Closure(def_id, substs), .. }) => {
|
||||
let fn_sig = substs.closure_sig(*def_id, self.tcx);
|
||||
let ret = fn_sig.output().skip_binder().to_string();
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
decl: &hir::FnDecl,
|
||||
) -> Option<Span> {
|
||||
let ret_ty = self.tcx().type_of(scope_def_id);
|
||||
if let ty::FnDef(_, _) = ret_ty.sty {
|
||||
if let ty::FnDef(_, _) = ret_ty.kind {
|
||||
let sig = ret_ty.fn_sig(self.tcx());
|
||||
let late_bound_regions = self.tcx()
|
||||
.collect_referenced_late_bound_regions(&sig.output());
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
|
|||
|
||||
let tcx = self.infcx.tcx;
|
||||
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Infer(ty::TyVar(v)) => {
|
||||
let opt_ty = self.infcx.type_variables.borrow_mut().probe(v).known();
|
||||
self.freshen_ty(
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for InferenceFudger<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Infer(ty::InferTy::TyVar(vid)) => {
|
||||
if self.type_vars.0.contains(&vid) {
|
||||
// This variable was created during the fudging.
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ where
|
|||
let infcx = this.infcx();
|
||||
let a = infcx.type_variables.borrow_mut().replace_if_possible(a);
|
||||
let b = infcx.type_variables.borrow_mut().replace_if_possible(b);
|
||||
match (&a.sty, &b.sty) {
|
||||
match (&a.kind, &b.kind) {
|
||||
// If one side is known to be a variable and one is not,
|
||||
// create a variable (`v`) to represent the LUB. Make sure to
|
||||
// relate `v` to the non-type-variable first (by passing it
|
||||
|
|
|
|||
|
|
@ -614,7 +614,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn type_var_diverges(&'a self, ty: Ty<'_>) -> bool {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Infer(ty::TyVar(vid)) => self.type_variables.borrow().var_diverges(vid),
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -627,7 +627,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
pub fn type_is_unconstrained_numeric(&'a self, ty: Ty<'_>) -> UnconstrainedNumeric {
|
||||
use crate::ty::error::UnconstrainedNumeric::Neither;
|
||||
use crate::ty::error::UnconstrainedNumeric::{UnconstrainedFloat, UnconstrainedInt};
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Infer(ty::IntVar(vid)) => {
|
||||
if self.int_unification_table
|
||||
.borrow_mut()
|
||||
|
|
@ -1563,7 +1563,7 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn shallow_resolve(&mut self, typ: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match typ.sty {
|
||||
match typ.kind {
|
||||
ty::Infer(ty::TyVar(v)) => {
|
||||
// Not entirely obvious: if `typ` is a type variable,
|
||||
// it can be resolved to an int/float variable, which
|
||||
|
|
@ -1604,7 +1604,7 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> {
|
|||
// are extremely hot.
|
||||
#[inline(always)]
|
||||
pub fn shallow_resolve_changed(&mut self, typ: Ty<'tcx>) -> bool {
|
||||
match typ.sty {
|
||||
match typ.kind {
|
||||
ty::Infer(ty::TyVar(v)) => {
|
||||
use self::type_variable::TypeVariableValue;
|
||||
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ where
|
|||
use crate::traits::WhereClause;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
|
||||
match value_ty.sty {
|
||||
match value_ty.kind {
|
||||
ty::Projection(other_projection_ty) => {
|
||||
let var = self.infcx.next_ty_var(TypeVariableOrigin {
|
||||
kind: TypeVariableOriginKind::MiscVariable,
|
||||
|
|
@ -328,7 +328,7 @@ where
|
|||
// This only presently applies to chalk integration, as NLL
|
||||
// doesn't permit type variables to appear on both sides (and
|
||||
// doesn't use lazy norm).
|
||||
match value_ty.sty {
|
||||
match value_ty.kind {
|
||||
ty::Infer(ty::TyVar(value_vid)) => {
|
||||
// Two type variables: just equate them.
|
||||
self.infcx
|
||||
|
|
@ -548,7 +548,7 @@ where
|
|||
b = self.infcx.shallow_resolve(b);
|
||||
}
|
||||
|
||||
match (&a.sty, &b.sty) {
|
||||
match (&a.kind, &b.kind) {
|
||||
(_, &ty::Infer(ty::TyVar(vid))) => {
|
||||
if D::forbid_inference_vars() {
|
||||
// Forbid inference variables in the RHS.
|
||||
|
|
@ -878,7 +878,7 @@ where
|
|||
|
||||
debug!("TypeGeneralizer::tys(a={:?})", a);
|
||||
|
||||
match a.sty {
|
||||
match a.kind {
|
||||
ty::Infer(ty::TyVar(_)) | ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_))
|
||||
if D::forbid_inference_vars() =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -720,7 +720,7 @@ where
|
|||
return false; // keep visiting
|
||||
}
|
||||
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Closure(def_id, ref substs) => {
|
||||
// Skip lifetime parameters of the enclosing item(s)
|
||||
|
||||
|
|
@ -857,7 +857,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
|
|||
}
|
||||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Closure(def_id, substs) => {
|
||||
// I am a horrible monster and I pray for death. When
|
||||
// we encounter a closure here, it is always a closure
|
||||
|
|
@ -990,7 +990,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
|
|||
ty_op: |ty| {
|
||||
if ty.references_error() {
|
||||
return tcx.types.err;
|
||||
} else if let ty::Opaque(def_id, substs) = ty.sty {
|
||||
} else if let ty::Opaque(def_id, substs) = ty.kind {
|
||||
// Check that this is `impl Trait` type is
|
||||
// declared by `parent_def_id` -- i.e., one whose
|
||||
// value we are inferring. At present, this is
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ where
|
|||
// 'a` in the environment but `trait Foo<'b> { type Item: 'b
|
||||
// }` in the trait definition.
|
||||
approx_env_bounds.retain(|bound| {
|
||||
match bound.0.sty {
|
||||
match bound.0.kind {
|
||||
ty::Projection(projection_ty) => {
|
||||
self.verify_bound.projection_declared_bounds_from_trait(projection_ty)
|
||||
.all(|r| r != bound.1)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
fn type_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Param(p) => self.param_bound(p),
|
||||
ty::Projection(data) => self.projection_bound(data),
|
||||
_ => self.recursive_type_bound(ty),
|
||||
|
|
@ -87,7 +87,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
|
|||
let projection_ty = GenericKind::Projection(projection_ty).to_ty(self.tcx);
|
||||
let erased_projection_ty = self.tcx.erase_regions(&projection_ty);
|
||||
self.declared_generic_bounds_from_env_with_compare_fn(|ty| {
|
||||
if let ty::Projection(..) = ty.sty {
|
||||
if let ty::Projection(..) = ty.kind {
|
||||
let erased_ty = self.tcx.erase_regions(&ty);
|
||||
erased_ty == erased_projection_ty
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
|
|||
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
|
||||
let t = self.infcx.shallow_resolve(t);
|
||||
if t.has_infer_types() {
|
||||
if let ty::Infer(infer_ty) = t.sty {
|
||||
if let ty::Infer(infer_ty) = t.kind {
|
||||
// Since we called `shallow_resolve` above, this must
|
||||
// be an (as yet...) unresolved inference variable.
|
||||
let ty_var_span =
|
||||
|
|
@ -188,7 +188,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
|
|||
// defaulted tuples.
|
||||
} else {
|
||||
let t = self.infcx.shallow_resolve(t);
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Infer(ty::TyVar(vid)) => {
|
||||
self.err = Some(FixupError::UnresolvedTy(vid));
|
||||
self.tcx().types.err
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
|
|||
let infcx = self.fields.infcx;
|
||||
let a = infcx.type_variables.borrow_mut().replace_if_possible(a);
|
||||
let b = infcx.type_variables.borrow_mut().replace_if_possible(b);
|
||||
match (&a.sty, &b.sty) {
|
||||
match (&a.kind, &b.kind) {
|
||||
(&ty::Infer(TyVar(a_vid)), &ty::Infer(TyVar(b_vid))) => {
|
||||
// Shouldn't have any LBR here, so we can safely put
|
||||
// this under a binder below without fear of accidental
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
|
|||
/// instantiated, then return the with which it was
|
||||
/// instantiated. Otherwise, returns `t`.
|
||||
pub fn replace_if_possible(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Infer(ty::TyVar(v)) => {
|
||||
match self.probe(v) {
|
||||
TypeVariableValue::Unknown { .. } => t,
|
||||
|
|
|
|||
|
|
@ -829,7 +829,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
|
|||
trait_ref: Option<ty::TraitRef<'tcx>>,
|
||||
) -> Result<Self::Path, Self::Error> {
|
||||
if trait_ref.is_none() {
|
||||
if let ty::Adt(def, substs) = self_ty.sty {
|
||||
if let ty::Adt(def, substs) = self_ty.kind {
|
||||
return self.print_def_path(def.did, substs);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn handle_field_access(&mut self, lhs: &hir::Expr, hir_id: hir::HirId) {
|
||||
match self.tables.expr_ty_adjusted(lhs).sty {
|
||||
match self.tables.expr_ty_adjusted(lhs).kind {
|
||||
ty::Adt(def, _) => {
|
||||
let index = self.tcx.field_index(hir_id, self.tables);
|
||||
self.insert_def_id(def.non_enum_variant().fields[index].did);
|
||||
|
|
@ -128,7 +128,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn handle_field_pattern_match(&mut self, lhs: &hir::Pat, res: Res, pats: &[hir::FieldPat]) {
|
||||
let variant = match self.tables.node_type(lhs.hir_id).sty {
|
||||
let variant = match self.tables.node_type(lhs.hir_id).kind {
|
||||
ty::Adt(adt, _) => adt.variant_of_res(res),
|
||||
_ => span_bug!(lhs.span, "non-ADT in struct pattern")
|
||||
};
|
||||
|
|
@ -248,7 +248,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
|
|||
self.handle_field_access(&lhs, expr.hir_id);
|
||||
}
|
||||
hir::ExprKind::Struct(_, ref fields, _) => {
|
||||
if let ty::Adt(ref adt, _) = self.tables.expr_ty(expr).sty {
|
||||
if let ty::Adt(ref adt, _) = self.tables.expr_ty(expr).kind {
|
||||
self.mark_as_used_if_union(adt, fields);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
// make sure that the thing we are pointing out stays valid
|
||||
// for the lifetime `scope_r` of the resulting ptr:
|
||||
let expr_ty = return_if_err!(self.mc.expr_ty(expr));
|
||||
if let ty::Ref(r, _, _) = expr_ty.sty {
|
||||
if let ty::Ref(r, _, _) = expr_ty.kind {
|
||||
let bk = ty::BorrowKind::from_mutbl(m);
|
||||
self.borrow_expr(&base, r, bk, AddrOf);
|
||||
}
|
||||
|
|
@ -553,7 +553,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
let callee_ty = return_if_err!(self.mc.expr_ty_adjusted(callee));
|
||||
debug!("walk_callee: callee={:?} callee_ty={:?}",
|
||||
callee, callee_ty);
|
||||
match callee_ty.sty {
|
||||
match callee_ty.kind {
|
||||
ty::FnDef(..) | ty::FnPtr(_) => {
|
||||
self.consume_expr(callee);
|
||||
}
|
||||
|
|
@ -658,7 +658,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
|
||||
// Select just those fields of the `with`
|
||||
// expression that will actually be used
|
||||
match with_cmt.ty.sty {
|
||||
match with_cmt.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() {
|
||||
|
|
@ -863,7 +863,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
// It is also a borrow or copy/move of the value being matched.
|
||||
match bm {
|
||||
ty::BindByReference(m) => {
|
||||
if let ty::Ref(r, _, _) = pat_ty.sty {
|
||||
if let ty::Ref(r, _, _) = pat_ty.kind {
|
||||
let bk = ty::BorrowKind::from_mutbl(m);
|
||||
delegate.borrow(pat.hir_id, pat.span, &cmt_pat, r, bk, RefBinding);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ struct ExprVisitor<'tcx> {
|
|||
/// If the type is `Option<T>`, it will return `T`, otherwise
|
||||
/// the type itself. Works on most `Option`-like types.
|
||||
fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
let (def, substs) = match ty.sty {
|
||||
let (def, substs) = match ty.kind {
|
||||
ty::Adt(def, substs) => (def, substs),
|
||||
_ => return ty
|
||||
};
|
||||
|
|
@ -83,7 +83,7 @@ impl ExprVisitor<'tcx> {
|
|||
// Special-case transmutting from `typeof(function)` and
|
||||
// `Option<typeof(function)>` to present a clearer error.
|
||||
let from = unpack_option_like(self.tcx.global_tcx(), from);
|
||||
if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (&from.sty, sk_to) {
|
||||
if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (&from.kind, sk_to) {
|
||||
if size_to == Pointer.size(&self.tcx) {
|
||||
struct_span_err!(self.tcx.sess, span, E0591,
|
||||
"can't transmute zero-sized type")
|
||||
|
|
|
|||
|
|
@ -738,7 +738,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
LocalDefId::from_def_id(closure_expr_def_id),
|
||||
);
|
||||
let ty = self.node_ty(fn_hir_id)?;
|
||||
let kind = match ty.sty {
|
||||
let kind = match ty.kind {
|
||||
ty::Generator(..) => ty::ClosureKind::FnOnce,
|
||||
ty::Closure(closure_def_id, closure_substs) => {
|
||||
match self.infcx {
|
||||
|
|
@ -900,7 +900,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
debug!("cat_rvalue_node: promotable = {:?}", promotable);
|
||||
|
||||
// Always promote `[T; 0]` (even when e.g., borrowed mutably).
|
||||
let promotable = match expr_ty.sty {
|
||||
let promotable = match expr_ty.kind {
|
||||
ty::Array(_, len) if len.try_eval_usize(self.tcx, self.param_env) == Some(0) => true,
|
||||
_ => promotable,
|
||||
};
|
||||
|
|
@ -974,7 +974,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.sty {
|
||||
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")
|
||||
};
|
||||
|
|
@ -1004,7 +1004,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
}
|
||||
};
|
||||
|
||||
let ptr = match base_cmt.ty.sty {
|
||||
let ptr = match base_cmt.ty.kind {
|
||||
ty::Adt(def, ..) if def.is_box() => Unique,
|
||||
ty::RawPtr(ref mt) => UnsafePtr(mt.mutbl),
|
||||
ty::Ref(r, _, mutbl) => {
|
||||
|
|
@ -1230,7 +1230,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
Res::Def(DefKind::Ctor(CtorOf::Struct, CtorKind::Fn), _)
|
||||
| Res::SelfCtor(..) => {
|
||||
let ty = self.pat_ty_unadjusted(&pat)?;
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Adt(adt_def, _) => {
|
||||
(cmt, adt_def.non_enum_variant().fields.len())
|
||||
}
|
||||
|
|
@ -1303,7 +1303,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
PatKind::Tuple(ref subpats, ddpos) => {
|
||||
// (p1, ..., pN)
|
||||
let ty = self.pat_ty_unadjusted(&pat)?;
|
||||
let expected_len = match ty.sty {
|
||||
let expected_len = match ty.kind {
|
||||
ty::Tuple(ref tys) => tys.len(),
|
||||
_ => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ impl<'tcx> PlaceTy<'tcx> {
|
|||
///
|
||||
/// Note that the resulting type has not been normalized.
|
||||
pub fn field_ty(self, tcx: TyCtxt<'tcx>, f: &Field) -> Ty<'tcx> {
|
||||
let answer = match self.ty.sty {
|
||||
let answer = match self.ty.kind {
|
||||
ty::Adt(adt_def, substs) => {
|
||||
let variant_def = match self.variant_index {
|
||||
None => adt_def.non_enum_variant(),
|
||||
|
|
@ -89,7 +89,7 @@ impl<'tcx> PlaceTy<'tcx> {
|
|||
ProjectionElem::Index(_) | ProjectionElem::ConstantIndex { .. } =>
|
||||
PlaceTy::from_ty(self.ty.builtin_index().unwrap()),
|
||||
ProjectionElem::Subslice { from, to } => {
|
||||
PlaceTy::from_ty(match self.ty.sty {
|
||||
PlaceTy::from_ty(match self.ty.kind {
|
||||
ty::Array(inner, size) => {
|
||||
let size = size.eval_usize(tcx, param_env);
|
||||
let len = size - (from as u64) - (to as u64);
|
||||
|
|
@ -195,7 +195,7 @@ impl<'tcx> Rvalue<'tcx> {
|
|||
}
|
||||
Rvalue::Discriminant(ref place) => {
|
||||
let ty = place.ty(local_decls, tcx).ty;
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Adt(adt_def, _) => adt_def.repr.discr_type().to_ty(tcx),
|
||||
ty::Generator(_, substs, _) => substs.discr_ty(tcx),
|
||||
_ => {
|
||||
|
|
|
|||
|
|
@ -601,7 +601,7 @@ impl AutoTraitFinder<'tcx> {
|
|||
}
|
||||
|
||||
pub fn is_of_param(&self, ty: Ty<'_>) -> bool {
|
||||
return match ty.sty {
|
||||
return match ty.kind {
|
||||
ty::Param(_) => true,
|
||||
ty::Projection(p) => self.is_of_param(p.self_ty()),
|
||||
_ => false,
|
||||
|
|
@ -609,7 +609,7 @@ impl AutoTraitFinder<'tcx> {
|
|||
}
|
||||
|
||||
fn is_self_referential_projection(&self, p: ty::PolyProjectionPredicate<'_>) -> bool {
|
||||
match p.ty().skip_binder().sty {
|
||||
match p.ty().skip_binder().kind {
|
||||
ty::Projection(proj) if proj == p.skip_binder().projection_ty => {
|
||||
true
|
||||
},
|
||||
|
|
|
|||
|
|
@ -383,7 +383,7 @@ fn orphan_check_trait_ref<'tcx>(
|
|||
if ty_is_local(tcx, input_ty, in_crate) {
|
||||
debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty);
|
||||
return Ok(());
|
||||
} else if let ty::Param(_) = input_ty.sty {
|
||||
} else if let ty::Param(_) = input_ty.kind {
|
||||
debug!("orphan_check_trait_ref: uncovered ty: `{:?}`", input_ty);
|
||||
return Err(OrphanCheckErr::UncoveredTy(input_ty))
|
||||
}
|
||||
|
|
@ -444,7 +444,7 @@ fn uncovered_tys<'tcx>(tcx: TyCtxt<'_>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec<
|
|||
}
|
||||
|
||||
fn is_possibly_remote_type(ty: Ty<'_>, _in_crate: InCrate) -> bool {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Projection(..) | ty::Param(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -456,7 +456,7 @@ fn ty_is_local(tcx: TyCtxt<'_>, ty: Ty<'_>, in_crate: InCrate) -> bool {
|
|||
}
|
||||
|
||||
fn fundamental_ty(ty: Ty<'_>) -> bool {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Ref(..) => true,
|
||||
ty::Adt(def, _) => def.is_fundamental(),
|
||||
_ => false
|
||||
|
|
@ -475,7 +475,7 @@ fn def_id_is_local(def_id: DefId, in_crate: InCrate) -> bool {
|
|||
fn ty_is_local_constructor(tcx: TyCtxt<'_>, ty: Ty<'_>, in_crate: InCrate) -> bool {
|
||||
debug!("ty_is_local_constructor({:?})", ty);
|
||||
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Bool |
|
||||
ty::Char |
|
||||
ty::Int(..) |
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
/// returns the fuzzy category of a given type, or None
|
||||
/// if the type can be equated to any type.
|
||||
fn type_category(t: Ty<'_>) -> Option<u32> {
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Bool => Some(0),
|
||||
ty::Char => Some(1),
|
||||
ty::Str => Some(2),
|
||||
|
|
@ -288,7 +288,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
match (type_category(a), type_category(b)) {
|
||||
(Some(cat_a), Some(cat_b)) => match (&a.sty, &b.sty) {
|
||||
(Some(cat_a), Some(cat_b)) => match (&a.kind, &b.kind) {
|
||||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => def_a == def_b,
|
||||
_ => cat_a == cat_b
|
||||
},
|
||||
|
|
@ -419,7 +419,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
flags.push((sym::_Self, Some("{integral}".to_owned())));
|
||||
}
|
||||
|
||||
if let ty::Array(aty, len) = self_ty.sty {
|
||||
if let ty::Array(aty, len) = self_ty.kind {
|
||||
flags.push((sym::_Self, Some("[]".to_owned())));
|
||||
flags.push((sym::_Self, Some(format!("[{}]", aty))));
|
||||
if let Some(def) = aty.ty_adt_def() {
|
||||
|
|
@ -876,7 +876,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
|
||||
let found_trait_ty = found_trait_ref.self_ty();
|
||||
|
||||
let found_did = match found_trait_ty.sty {
|
||||
let found_did = match found_trait_ty.kind {
|
||||
ty::Closure(did, _) | ty::Foreign(did) | ty::FnDef(did, _) => Some(did),
|
||||
ty::Adt(def, _) => Some(def.did),
|
||||
_ => None,
|
||||
|
|
@ -886,13 +886,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
self.tcx.hir().span_if_local(did)
|
||||
).map(|sp| self.tcx.sess.source_map().def_span(sp)); // the sp could be an fn def
|
||||
|
||||
let found = match found_trait_ref.skip_binder().substs.type_at(1).sty {
|
||||
let found = match found_trait_ref.skip_binder().substs.type_at(1).kind {
|
||||
ty::Tuple(ref tys) => vec![ArgKind::empty(); tys.len()],
|
||||
_ => vec![ArgKind::empty()],
|
||||
};
|
||||
|
||||
let expected_ty = expected_trait_ref.skip_binder().substs.type_at(1);
|
||||
let expected = match expected_ty.sty {
|
||||
let expected = match expected_ty.kind {
|
||||
ty::Tuple(ref tys) => tys.iter()
|
||||
.map(|t| ArgKind::from_expected_ty(t.expect_ty(), Some(span))).collect(),
|
||||
_ => vec![ArgKind::Arg("_".to_owned(), expected_ty.to_string())],
|
||||
|
|
@ -979,7 +979,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
points_at_arg: bool,
|
||||
) {
|
||||
let self_ty = trait_ref.self_ty();
|
||||
match self_ty.sty {
|
||||
match self_ty.kind {
|
||||
ty::FnDef(def_id, _) => {
|
||||
// We tried to apply the bound to an `fn`. Check whether calling it would evaluate
|
||||
// to a type that *would* satisfy the trait binding. If it would, suggest calling
|
||||
|
|
@ -1066,7 +1066,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
let mut trait_type = trait_ref.self_ty();
|
||||
|
||||
for refs_remaining in 0..refs_number {
|
||||
if let ty::Ref(_, t_type, _) = trait_type.sty {
|
||||
if let ty::Ref(_, t_type, _) = trait_type.kind {
|
||||
trait_type = t_type;
|
||||
|
||||
let substs = self.tcx.mk_substs_trait(trait_type, &[]);
|
||||
|
|
@ -1340,7 +1340,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
) -> DiagnosticBuilder<'tcx> {
|
||||
fn build_fn_sig_string<'tcx>(tcx: TyCtxt<'tcx>, trait_ref: &ty::TraitRef<'tcx>) -> String {
|
||||
let inputs = trait_ref.substs.type_at(1);
|
||||
let sig = if let ty::Tuple(inputs) = inputs.sty {
|
||||
let sig = if let ty::Tuple(inputs) = inputs.kind {
|
||||
tcx.mk_fn_sig(
|
||||
inputs.iter().map(|k| k.expect_ty()),
|
||||
tcx.mk_ty_infer(ty::TyVar(ty::TyVid { index: 0 })),
|
||||
|
|
@ -1463,7 +1463,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
ty::Predicate::Trait(ref data) => {
|
||||
let trait_ref = data.to_poly_trait_ref();
|
||||
let self_ty = trait_ref.self_ty();
|
||||
debug!("self_ty {:?} {:?} trait_ref {:?}", self_ty, self_ty.sty, trait_ref);
|
||||
debug!("self_ty {:?} {:?} trait_ref {:?}", self_ty, self_ty.kind, trait_ref);
|
||||
|
||||
if predicate.references_error() {
|
||||
return;
|
||||
|
|
@ -1564,7 +1564,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx }
|
||||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
if let ty::Param(ty::ParamTy {name, .. }) = ty.sty {
|
||||
if let ty::Param(ty::ParamTy {name, .. }) = ty.kind {
|
||||
let infcx = self.infcx;
|
||||
self.var_map.entry(ty).or_insert_with(||
|
||||
infcx.next_ty_var(
|
||||
|
|
@ -1834,7 +1834,7 @@ impl ArgKind {
|
|||
/// Creates an `ArgKind` from the expected type of an
|
||||
/// argument. It has no name (`_`) and an optional source span.
|
||||
pub fn from_expected_ty(t: Ty<'_>, span: Option<Span>) -> ArgKind {
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Tuple(ref tys) => ArgKind::Tuple(
|
||||
span,
|
||||
tys.iter()
|
||||
|
|
|
|||
|
|
@ -548,7 +548,7 @@ fn trait_ref_type_vars<'a, 'tcx>(
|
|||
.map(|t| selcx.infcx().resolve_vars_if_possible(&t))
|
||||
.filter(|t| t.has_infer_types())
|
||||
.flat_map(|t| t.walk())
|
||||
.filter(|t| match t.sty { ty::Infer(_) => true, _ => false })
|
||||
.filter(|t| match t.kind { ty::Infer(_) => true, _ => false })
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -677,7 +677,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let mut error = false;
|
||||
let self_ty = self.types.self_param;
|
||||
ty.maybe_walk(|ty| {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Param(_) => {
|
||||
if ty == self_ty {
|
||||
error = true;
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
|
|||
// should occur eventually).
|
||||
|
||||
let ty = ty.super_fold_with(self);
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Opaque(def_id, substs) if !substs.has_escaping_bound_vars() => { // (*)
|
||||
// Only normalize `impl Trait` after type-checking, usually in codegen.
|
||||
match self.param_env.reveal {
|
||||
|
|
@ -921,7 +921,7 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
|
|||
|
||||
let tcx = selcx.tcx();
|
||||
// Check whether the self-type is itself a projection.
|
||||
let (def_id, substs) = match obligation_trait_ref.self_ty().sty {
|
||||
let (def_id, substs) = match obligation_trait_ref.self_ty().kind {
|
||||
ty::Projection(ref data) => {
|
||||
(data.trait_ref(tcx).def_id, data.substs)
|
||||
}
|
||||
|
|
@ -1199,7 +1199,7 @@ fn confirm_object_candidate<'cx, 'tcx>(
|
|||
let object_ty = selcx.infcx().shallow_resolve(self_ty);
|
||||
debug!("confirm_object_candidate(object_ty={:?})",
|
||||
object_ty);
|
||||
let data = match object_ty.sty {
|
||||
let data = match object_ty.kind {
|
||||
ty::Dynamic(ref data, ..) => data,
|
||||
_ => {
|
||||
span_bug!(
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ impl_stable_hash_for!(struct DtorckConstraint<'tcx> {
|
|||
/// Note also that `needs_drop` requires a "global" type (i.e., one
|
||||
/// with erased regions), but this function does not.
|
||||
pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
// None of these types have a destructor and hence they do not
|
||||
// require anything in particular to outlive the dtor's
|
||||
// execution.
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
|
|||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
let ty = ty.super_fold_with(self);
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Opaque(def_id, substs) if !substs.has_escaping_bound_vars() => {
|
||||
// (*)
|
||||
// Only normalize `impl Trait` after type-checking, usually in codegen.
|
||||
|
|
|
|||
|
|
@ -1785,7 +1785,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
// before we go into the whole placeholder thing, just
|
||||
// quickly check if the self-type is a projection at all.
|
||||
match obligation.predicate.skip_binder().trait_ref.self_ty().sty {
|
||||
match obligation.predicate.skip_binder().trait_ref.self_ty().kind {
|
||||
ty::Projection(_) | ty::Opaque(..) => {}
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
span_bug!(
|
||||
|
|
@ -1823,7 +1823,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
placeholder_trait_predicate,
|
||||
);
|
||||
|
||||
let (def_id, substs) = match placeholder_trait_predicate.trait_ref.self_ty().sty {
|
||||
let (def_id, substs) = match placeholder_trait_predicate.trait_ref.self_ty().kind {
|
||||
ty::Projection(ref data) => (data.trait_ref(self.tcx()).def_id, data.substs),
|
||||
ty::Opaque(def_id, substs) => (def_id, substs),
|
||||
_ => {
|
||||
|
|
@ -1971,7 +1971,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// touch bound regions, they just capture the in-scope
|
||||
// type/region parameters.
|
||||
let self_ty = *obligation.self_ty().skip_binder();
|
||||
match self_ty.sty {
|
||||
match self_ty.kind {
|
||||
ty::Generator(..) => {
|
||||
debug!(
|
||||
"assemble_generator_candidates: self_ty={:?} obligation={:?}",
|
||||
|
|
@ -2014,7 +2014,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// Okay to skip binder because the substs on closure types never
|
||||
// touch bound regions, they just capture the in-scope
|
||||
// type/region parameters
|
||||
match obligation.self_ty().skip_binder().sty {
|
||||
match obligation.self_ty().skip_binder().kind {
|
||||
ty::Closure(closure_def_id, closure_substs) => {
|
||||
debug!(
|
||||
"assemble_unboxed_candidates: kind={:?} obligation={:?}",
|
||||
|
|
@ -2063,7 +2063,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
// Okay to skip binder because what we are inspecting doesn't involve bound regions
|
||||
let self_ty = *obligation.self_ty().skip_binder();
|
||||
match self_ty.sty {
|
||||
match self_ty.kind {
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
debug!("assemble_fn_pointer_candidates: ambiguous self-type");
|
||||
candidates.ambiguous = true; // could wind up being a fn() type
|
||||
|
|
@ -2125,7 +2125,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let def_id = obligation.predicate.def_id();
|
||||
|
||||
if self.tcx().trait_is_auto(def_id) {
|
||||
match self_ty.sty {
|
||||
match self_ty.kind {
|
||||
ty::Dynamic(..) => {
|
||||
// For object types, we don't know what the closed
|
||||
// over types are. This means we conservatively
|
||||
|
|
@ -2198,7 +2198,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// self-ty here doesn't escape this probe, so just erase
|
||||
// any LBR.
|
||||
let self_ty = self.tcx().erase_late_bound_regions(&obligation.self_ty());
|
||||
let poly_trait_ref = match self_ty.sty {
|
||||
let poly_trait_ref = match self_ty.kind {
|
||||
ty::Dynamic(ref data, ..) => {
|
||||
if data.auto_traits()
|
||||
.any(|did| did == obligation.predicate.def_id())
|
||||
|
|
@ -2294,7 +2294,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
source, target
|
||||
);
|
||||
|
||||
let may_apply = match (&source.sty, &target.sty) {
|
||||
let may_apply = match (&source.kind, &target.kind) {
|
||||
// Trait+Kx+'a -> Trait+Ky+'b (upcasts).
|
||||
(&ty::Dynamic(ref data_a, ..), &ty::Dynamic(ref data_b, ..)) => {
|
||||
// Upcasts permit two things:
|
||||
|
|
@ -2532,7 +2532,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let self_ty = self.infcx
|
||||
.shallow_resolve(obligation.predicate.skip_binder().self_ty());
|
||||
|
||||
match self_ty.sty {
|
||||
match self_ty.kind {
|
||||
ty::Infer(ty::IntVar(_))
|
||||
| ty::Infer(ty::FloatVar(_))
|
||||
| ty::Uint(_)
|
||||
|
|
@ -2598,7 +2598,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
use self::BuiltinImplConditions::{Ambiguous, None, Where};
|
||||
|
||||
match self_ty.sty {
|
||||
match self_ty.kind {
|
||||
ty::Infer(ty::IntVar(_))
|
||||
| ty::Infer(ty::FloatVar(_))
|
||||
| ty::FnDef(..)
|
||||
|
|
@ -2680,7 +2680,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
/// Zed<i32> where enum Zed { A(T), B(u32) } -> [i32, u32]
|
||||
/// ```
|
||||
fn constituent_types_for_ty(&self, t: Ty<'tcx>) -> Vec<Ty<'tcx>> {
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Uint(_)
|
||||
| ty::Int(_)
|
||||
| ty::Bool
|
||||
|
|
@ -3118,7 +3118,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// results.
|
||||
let self_ty = self.infcx
|
||||
.shallow_resolve(*obligation.self_ty().skip_binder());
|
||||
let poly_trait_ref = match self_ty.sty {
|
||||
let poly_trait_ref = match self_ty.kind {
|
||||
ty::Dynamic(ref data, ..) =>
|
||||
data.principal().unwrap_or_else(|| {
|
||||
span_bug!(obligation.cause.span, "object candidate with no principal")
|
||||
|
|
@ -3252,7 +3252,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// touch bound regions, they just capture the in-scope
|
||||
// type/region parameters.
|
||||
let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder());
|
||||
let (generator_def_id, substs) = match self_ty.sty {
|
||||
let (generator_def_id, substs) = match self_ty.kind {
|
||||
ty::Generator(id, substs, _) => (id, substs),
|
||||
_ => bug!("closure candidate for non-closure {:?}", obligation),
|
||||
};
|
||||
|
|
@ -3309,7 +3309,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// touch bound regions, they just capture the in-scope
|
||||
// type/region parameters.
|
||||
let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder());
|
||||
let (closure_def_id, substs) = match self_ty.sty {
|
||||
let (closure_def_id, substs) = match self_ty.kind {
|
||||
ty::Closure(id, substs) => (id, substs),
|
||||
_ => bug!("closure candidate for non-closure {:?}", obligation),
|
||||
};
|
||||
|
|
@ -3418,7 +3418,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
);
|
||||
|
||||
let mut nested = vec![];
|
||||
match (&source.sty, &target.sty) {
|
||||
match (&source.kind, &target.kind) {
|
||||
// Trait+Kx+'a -> Trait+Ky+'b (upcasts).
|
||||
(&ty::Dynamic(ref data_a, r_a), &ty::Dynamic(ref data_b, r_b)) => {
|
||||
// See assemble_candidates_for_unsizing for more info.
|
||||
|
|
@ -3550,7 +3550,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let mut ty_params = GrowableBitSet::new_empty();
|
||||
let mut found = false;
|
||||
for ty in field.walk() {
|
||||
if let ty::Param(p) = ty.sty {
|
||||
if let ty::Param(p) = ty.kind {
|
||||
ty_params.insert(p.index as usize);
|
||||
found = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,11 +85,11 @@ impl<'tcx> Children {
|
|||
/// Insert an impl into this set of children without comparing to any existing impls.
|
||||
fn insert_blindly(&mut self, tcx: TyCtxt<'tcx>, impl_def_id: DefId) {
|
||||
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
|
||||
if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
|
||||
debug!("insert_blindly: impl_def_id={:?} sty={:?}", impl_def_id, sty);
|
||||
self.nonblanket_impls.entry(sty).or_default().push(impl_def_id)
|
||||
if let Some(st) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
|
||||
debug!("insert_blindly: impl_def_id={:?} st={:?}", impl_def_id, st);
|
||||
self.nonblanket_impls.entry(st).or_default().push(impl_def_id)
|
||||
} else {
|
||||
debug!("insert_blindly: impl_def_id={:?} sty=None", impl_def_id);
|
||||
debug!("insert_blindly: impl_def_id={:?} st=None", impl_def_id);
|
||||
self.blanket_impls.push(impl_def_id)
|
||||
}
|
||||
}
|
||||
|
|
@ -100,11 +100,11 @@ impl<'tcx> Children {
|
|||
fn remove_existing(&mut self, tcx: TyCtxt<'tcx>, impl_def_id: DefId) {
|
||||
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
|
||||
let vec: &mut Vec<DefId>;
|
||||
if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
|
||||
debug!("remove_existing: impl_def_id={:?} sty={:?}", impl_def_id, sty);
|
||||
vec = self.nonblanket_impls.get_mut(&sty).unwrap();
|
||||
if let Some(st) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
|
||||
debug!("remove_existing: impl_def_id={:?} st={:?}", impl_def_id, st);
|
||||
vec = self.nonblanket_impls.get_mut(&st).unwrap();
|
||||
} else {
|
||||
debug!("remove_existing: impl_def_id={:?} sty=None", impl_def_id);
|
||||
debug!("remove_existing: impl_def_id={:?} st=None", impl_def_id);
|
||||
vec = &mut self.blanket_impls;
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ impl<'tcx> Children {
|
|||
);
|
||||
|
||||
let possible_siblings = match simplified_self {
|
||||
Some(sty) => PotentialSiblings::Filtered(self.filtered(sty)),
|
||||
Some(st) => PotentialSiblings::Filtered(self.filtered(st)),
|
||||
None => PotentialSiblings::Unfiltered(self.iter()),
|
||||
};
|
||||
|
||||
|
|
@ -249,8 +249,8 @@ impl<'tcx> Children {
|
|||
self.blanket_impls.iter().chain(nonblanket).cloned()
|
||||
}
|
||||
|
||||
fn filtered(&mut self, sty: SimplifiedType) -> impl Iterator<Item = DefId> + '_ {
|
||||
let nonblanket = self.nonblanket_impls.entry(sty).or_default().iter();
|
||||
fn filtered(&mut self, st: SimplifiedType) -> impl Iterator<Item = DefId> + '_ {
|
||||
let nonblanket = self.nonblanket_impls.entry(st).or_default().iter();
|
||||
self.blanket_impls.iter().chain(nonblanket).cloned()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundNamesCollector {
|
|||
}
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Bound(debruijn, bound_ty) if debruijn == self.binder_index => {
|
||||
self.types.insert(
|
||||
bound_ty.var.as_u32(),
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ impl TypeRelation<'tcx> for Match<'tcx> {
|
|||
a, b);
|
||||
if a == b { return Ok(a); }
|
||||
|
||||
match (&a.sty, &b.sty) {
|
||||
match (&a.kind, &b.kind) {
|
||||
(_, &ty::Infer(ty::FreshTy(_))) |
|
||||
(_, &ty::Infer(ty::FreshIntTy(_))) |
|
||||
(_, &ty::Infer(ty::FreshFloatTy(_))) => {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ impl<'tcx> CastTy<'tcx> {
|
|||
/// Returns `Some` for integral/pointer casts.
|
||||
/// casts like unsizing casts will return `None`
|
||||
pub fn from_ty(t: Ty<'tcx>) -> Option<CastTy<'tcx>> {
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Bool => Some(CastTy::Int(IntTy::Bool)),
|
||||
ty::Char => Some(CastTy::Int(IntTy::Char)),
|
||||
ty::Int(_) => Some(CastTy::Int(IntTy::I)),
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ pub trait EncodableWithShorthand: Clone + Eq + Hash {
|
|||
impl<'tcx> EncodableWithShorthand for Ty<'tcx> {
|
||||
type Variant = ty::TyKind<'tcx>;
|
||||
fn variant(&self) -> &Self::Variant {
|
||||
&self.sty
|
||||
&self.kind
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ impl<'tcx> CtxtInterners<'tcx> {
|
|||
let flags = super::flags::FlagComputation::for_sty(&st);
|
||||
|
||||
let ty_struct = TyS {
|
||||
sty: st,
|
||||
kind: st,
|
||||
flags: flags.flags,
|
||||
outer_exclusive_binder: flags.outer_exclusive_binder,
|
||||
};
|
||||
|
|
@ -828,7 +828,7 @@ impl CanonicalUserType<'tcx> {
|
|||
|
||||
user_substs.substs.iter().zip(BoundVar::new(0)..).all(|(kind, cvar)| {
|
||||
match kind.unpack() {
|
||||
UnpackedKind::Type(ty) => match ty.sty {
|
||||
UnpackedKind::Type(ty) => match ty.kind {
|
||||
ty::Bound(debruijn, b) => {
|
||||
// We only allow a `ty::INNERMOST` index in substitutions.
|
||||
assert_eq!(debruijn, ty::INNERMOST);
|
||||
|
|
@ -890,7 +890,7 @@ EnumLiftImpl! {
|
|||
|
||||
impl<'tcx> CommonTypes<'tcx> {
|
||||
fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
|
||||
let mk = |sty| interners.intern_ty(sty);
|
||||
let mk = |ty| interners.intern_ty(ty);
|
||||
|
||||
CommonTypes {
|
||||
unit: mk(Tuple(List::empty())),
|
||||
|
|
@ -1565,7 +1565,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
let ret_ty = self.type_of(scope_def_id);
|
||||
match ret_ty.sty {
|
||||
match ret_ty.kind {
|
||||
ty::FnDef(_, _) => {
|
||||
let sig = ret_ty.fn_sig(*self);
|
||||
let output = self.erase_late_bound_regions(&sig.output());
|
||||
|
|
@ -2011,7 +2011,7 @@ macro_rules! sty_debug_print {
|
|||
let shards = tcx.interners.type_.lock_shards();
|
||||
let types = shards.iter().flat_map(|shard| shard.keys());
|
||||
for &Interned(t) in types {
|
||||
let variant = match t.sty {
|
||||
let variant = match t.kind {
|
||||
ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) |
|
||||
ty::Float(..) | ty::Str | ty::Never => continue,
|
||||
ty::Error => /* unimportant */ continue,
|
||||
|
|
@ -2080,10 +2080,10 @@ impl<'tcx, T: 'tcx+?Sized> Clone for Interned<'tcx, T> {
|
|||
}
|
||||
impl<'tcx, T: 'tcx+?Sized> Copy for Interned<'tcx, T> {}
|
||||
|
||||
// N.B., an `Interned<Ty>` compares and hashes as a sty.
|
||||
// N.B., an `Interned<Ty>` compares and hashes as a `TyKind`.
|
||||
impl<'tcx> PartialEq for Interned<'tcx, TyS<'tcx>> {
|
||||
fn eq(&self, other: &Interned<'tcx, TyS<'tcx>>) -> bool {
|
||||
self.0.sty == other.0.sty
|
||||
self.0.kind == other.0.kind
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2091,14 +2091,14 @@ impl<'tcx> Eq for Interned<'tcx, TyS<'tcx>> {}
|
|||
|
||||
impl<'tcx> Hash for Interned<'tcx, TyS<'tcx>> {
|
||||
fn hash<H: Hasher>(&self, s: &mut H) {
|
||||
self.0.sty.hash(s)
|
||||
self.0.kind.hash(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(rustc::usage_of_ty_tykind)]
|
||||
impl<'tcx> Borrow<TyKind<'tcx>> for Interned<'tcx, TyS<'tcx>> {
|
||||
fn borrow<'a>(&'a self) -> &'a TyKind<'tcx> {
|
||||
&self.0.sty
|
||||
&self.0.kind
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2292,7 +2292,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
/// It cannot convert a closure that requires unsafe.
|
||||
pub fn coerce_closure_fn_ty(self, sig: PolyFnSig<'tcx>, unsafety: hir::Unsafety) -> Ty<'tcx> {
|
||||
let converted_sig = sig.map_bound(|s| {
|
||||
let params_iter = match s.inputs()[0].sty {
|
||||
let params_iter = match s.inputs()[0].kind {
|
||||
ty::Tuple(params) => {
|
||||
params.into_iter().map(|k| k.expect_ty())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
|
|||
|
||||
impl<'tcx> ty::TyS<'tcx> {
|
||||
pub fn sort_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
ty::Bool | ty::Char | ty::Int(_) |
|
||||
ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => self.to_string().into(),
|
||||
ty::Tuple(ref tys) if tys.is_empty() => self.to_string().into(),
|
||||
|
|
@ -275,7 +275,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
`.await`ing on both of them");
|
||||
}
|
||||
}
|
||||
match (&values.expected.sty, &values.found.sty) {
|
||||
match (&values.expected.kind, &values.found.kind) {
|
||||
(ty::Float(_), ty::Infer(ty::IntVar(_))) => if let Ok( // Issue #53280
|
||||
snippet,
|
||||
) = self.sess.source_map().span_to_snippet(sp) {
|
||||
|
|
@ -373,9 +373,9 @@ impl Trait for X {
|
|||
debug!(
|
||||
"note_and_explain_type_err expected={:?} ({:?}) found={:?} ({:?})",
|
||||
values.expected,
|
||||
values.expected.sty,
|
||||
values.expected.kind,
|
||||
values.found,
|
||||
values.found.sty,
|
||||
values.found.kind,
|
||||
);
|
||||
},
|
||||
CyclicTy(ty) => {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ pub fn simplify_type(
|
|||
ty: Ty<'_>,
|
||||
can_simplify_params: bool,
|
||||
) -> Option<SimplifiedType> {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Bool => Some(BoolSimplifiedType),
|
||||
ty::Char => Some(CharSimplifiedType),
|
||||
ty::Int(int_type) => Some(IntSimplifiedType(int_type)),
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for BoundVarReplacer<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Bound(debruijn, bound_ty) => {
|
||||
if debruijn == self.current_index {
|
||||
let fld_t = &mut self.fld_t;
|
||||
|
|
@ -776,7 +776,7 @@ impl TypeFolder<'tcx> for Shifter<'tcx> {
|
|||
}
|
||||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Bound(debruijn, bound_ty) => {
|
||||
if self.amount == 0 || debruijn < self.current_index {
|
||||
ty
|
||||
|
|
@ -985,7 +985,7 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
|
|||
// ignore the inputs to a projection, as they may not appear
|
||||
// in the normalized form
|
||||
if self.just_constrained {
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Projection(..) | ty::Opaque(..) => { return false; }
|
||||
_ => { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ impl<'tcx> FieldDef {
|
|||
impl<'tcx> TyS<'tcx> {
|
||||
/// Calculates the forest of `DefId`s from which this type is visibly uninhabited.
|
||||
fn uninhabited_from(&self, tcx: TyCtxt<'tcx>) -> DefIdForest {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Adt(def, substs) => def.uninhabited_from(tcx, substs),
|
||||
|
||||
Never => DefIdForest::full(tcx),
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ impl<'tcx> Instance<'tcx> {
|
|||
|
||||
fn fn_sig_noadjust(&self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> {
|
||||
let ty = self.ty(tcx);
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::FnDef(..) |
|
||||
// Shims currently have type FnPtr. Not sure this should remain.
|
||||
ty::FnPtr(_) => ty.fn_sig(tcx),
|
||||
|
|
@ -255,7 +255,7 @@ impl<'tcx> Instance<'tcx> {
|
|||
&ty,
|
||||
);
|
||||
|
||||
let def = match item_type.sty {
|
||||
let def = match item_type.kind {
|
||||
ty::FnDef(..) if {
|
||||
let f = item_type.fn_sig(tcx);
|
||||
f.abi() == Abi::RustIntrinsic ||
|
||||
|
|
|
|||
|
|
@ -520,7 +520,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
|||
};
|
||||
debug_assert!(!ty.has_infer_types());
|
||||
|
||||
Ok(match ty.sty {
|
||||
Ok(match ty.kind {
|
||||
// Basic scalars.
|
||||
ty::Bool => {
|
||||
tcx.intern_layout(LayoutDetails::scalar(self, Scalar {
|
||||
|
|
@ -573,7 +573,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
|||
}
|
||||
|
||||
let unsized_part = tcx.struct_tail_erasing_lifetimes(pointee, param_env);
|
||||
let metadata = match unsized_part.sty {
|
||||
let metadata = match unsized_part.kind {
|
||||
ty::Foreign(..) => {
|
||||
return Ok(tcx.intern_layout(LayoutDetails::scalar(self, data_ptr)));
|
||||
}
|
||||
|
|
@ -1618,7 +1618,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
|||
variants);
|
||||
};
|
||||
|
||||
let adt_def = match layout.ty.sty {
|
||||
let adt_def = match layout.ty.kind {
|
||||
ty::Adt(ref adt_def, _) => {
|
||||
debug!("print-type-size t: `{:?}` process adt", layout.ty);
|
||||
adt_def
|
||||
|
|
@ -1759,12 +1759,12 @@ impl<'tcx> SizeSkeleton<'tcx> {
|
|||
Err(err) => err
|
||||
};
|
||||
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Ref(_, pointee, _) |
|
||||
ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
|
||||
let non_zero = !ty.is_unsafe_ptr();
|
||||
let tail = tcx.struct_tail_erasing_lifetimes(pointee, param_env);
|
||||
match tail.sty {
|
||||
match tail.kind {
|
||||
ty::Param(_) | ty::Projection(_) => {
|
||||
debug_assert!(tail.has_param_types());
|
||||
Ok(SizeSkeleton::Pointer {
|
||||
|
|
@ -2040,7 +2040,7 @@ where
|
|||
assert_eq!(layout.variants, Variants::Single { index });
|
||||
}
|
||||
|
||||
let fields = match this.ty.sty {
|
||||
let fields = match this.ty.kind {
|
||||
ty::Adt(def, _) => def.variants[variant_index].fields.len(),
|
||||
_ => bug!()
|
||||
};
|
||||
|
|
@ -2078,7 +2078,7 @@ where
|
|||
}))
|
||||
};
|
||||
|
||||
cx.layout_of(match this.ty.sty {
|
||||
cx.layout_of(match this.ty.kind {
|
||||
ty::Bool |
|
||||
ty::Char |
|
||||
ty::Int(_) |
|
||||
|
|
@ -2115,7 +2115,7 @@ where
|
|||
}));
|
||||
}
|
||||
|
||||
match tcx.struct_tail_erasing_lifetimes(pointee, cx.param_env()).sty {
|
||||
match tcx.struct_tail_erasing_lifetimes(pointee, cx.param_env()).kind {
|
||||
ty::Slice(_) |
|
||||
ty::Str => tcx.types.usize,
|
||||
ty::Dynamic(_, _) => {
|
||||
|
|
@ -2202,7 +2202,7 @@ where
|
|||
cx: &C,
|
||||
offset: Size,
|
||||
) -> Option<PointeeInfo> {
|
||||
match this.ty.sty {
|
||||
match this.ty.kind {
|
||||
ty::RawPtr(mt) if offset.bytes() == 0 => {
|
||||
cx.layout_of(mt.ty).to_result().ok()
|
||||
.map(|layout| PointeeInfo {
|
||||
|
|
@ -2309,7 +2309,7 @@ where
|
|||
|
||||
// FIXME(eddyb) This should be for `ptr::Unique<T>`, not `Box<T>`.
|
||||
if let Some(ref mut pointee) = result {
|
||||
if let ty::Adt(def, _) = this.ty.sty {
|
||||
if let ty::Adt(def, _) = this.ty.kind {
|
||||
if def.is_box() && offset.bytes() == 0 {
|
||||
pointee.safe = Some(PointerKind::UniqueOwned);
|
||||
}
|
||||
|
|
@ -2641,7 +2641,7 @@ where
|
|||
let extra_args = if sig.abi == RustCall {
|
||||
assert!(!sig.c_variadic && extra_args.is_empty());
|
||||
|
||||
match sig.inputs().last().unwrap().sty {
|
||||
match sig.inputs().last().unwrap().kind {
|
||||
ty::Tuple(tupled_arguments) => {
|
||||
inputs = &sig.inputs()[0..sig.inputs().len() - 1];
|
||||
tupled_arguments.iter().map(|k| k.expect_ty()).collect()
|
||||
|
|
@ -2753,7 +2753,7 @@ where
|
|||
Some(did) => did,
|
||||
None => bug!("`va_list` lang item required for C-variadic functions"),
|
||||
};
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Adt(def, _) if def.did == va_list_did => {
|
||||
// This is the "spoofed" `VaListImpl`. Set the arguments mode
|
||||
// so that it will be ignored.
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ bitflags! {
|
|||
|
||||
#[allow(rustc::usage_of_ty_tykind)]
|
||||
pub struct TyS<'tcx> {
|
||||
pub sty: TyKind<'tcx>,
|
||||
pub kind: TyKind<'tcx>,
|
||||
pub flags: TypeFlags,
|
||||
|
||||
/// This is a kind of confusing thing: it stores the smallest
|
||||
|
|
@ -508,13 +508,13 @@ static_assert_size!(TyS<'_>, 32);
|
|||
|
||||
impl<'tcx> Ord for TyS<'tcx> {
|
||||
fn cmp(&self, other: &TyS<'tcx>) -> Ordering {
|
||||
self.sty.cmp(&other.sty)
|
||||
self.kind.cmp(&other.kind)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> PartialOrd for TyS<'tcx> {
|
||||
fn partial_cmp(&self, other: &TyS<'tcx>) -> Option<Ordering> {
|
||||
Some(self.sty.cmp(&other.sty))
|
||||
Some(self.kind.cmp(&other.kind))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -534,7 +534,7 @@ impl<'tcx> Hash for TyS<'tcx> {
|
|||
|
||||
impl<'tcx> TyS<'tcx> {
|
||||
pub fn is_primitive_ty(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Bool |
|
||||
Char |
|
||||
Int(_) |
|
||||
|
|
@ -550,7 +550,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
}
|
||||
|
||||
pub fn is_suggestable(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Opaque(..) |
|
||||
FnDef(..) |
|
||||
FnPtr(..) |
|
||||
|
|
@ -568,16 +568,16 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::TyS<'tcx> {
|
|||
hcx: &mut StableHashingContext<'a>,
|
||||
hasher: &mut StableHasher<W>) {
|
||||
let ty::TyS {
|
||||
ref sty,
|
||||
ref kind,
|
||||
|
||||
// The other fields just provide fast access to information that is
|
||||
// also contained in `sty`, so no need to hash them.
|
||||
// also contained in `kind`, so no need to hash them.
|
||||
flags: _,
|
||||
|
||||
outer_exclusive_binder: _,
|
||||
} = *self;
|
||||
|
||||
sty.hash_stable(hcx, hasher);
|
||||
kind.hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2494,7 +2494,7 @@ impl<'tcx> AdtDef {
|
|||
}
|
||||
|
||||
fn sized_constraint_for_ty(&self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Vec<Ty<'tcx>> {
|
||||
let result = match ty.sty {
|
||||
let result = match ty.kind {
|
||||
Bool | Char | Int(..) | Uint(..) | Float(..) |
|
||||
RawPtr(..) | Ref(..) | FnDef(..) | FnPtr(_) |
|
||||
Array(..) | Closure(..) | Generator(..) | Never => {
|
||||
|
|
@ -3339,7 +3339,7 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Ty<'_>> {
|
|||
}
|
||||
|
||||
let self_ty = trait_ref.self_ty();
|
||||
let self_ty_matches = match self_ty.sty {
|
||||
let self_ty_matches = match self_ty.kind {
|
||||
ty::Dynamic(ref data, ty::ReStatic) => data.principal().is_none(),
|
||||
_ => false
|
||||
};
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
// with `collect()` because of the need to sometimes skip subtrees
|
||||
// in the `subtys` iterator (e.g., when encountering a
|
||||
// projection).
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Closure(def_id, ref substs) => {
|
||||
for upvar_ty in substs.upvar_tys(def_id, *self) {
|
||||
self.compute_components(upvar_ty, out);
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ pub trait Printer<'tcx>: Sized {
|
|||
/// type. It's just a heuristic so it makes some questionable
|
||||
/// decisions and we may want to adjust it later.
|
||||
pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option<DefId> {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Adt(adt_def, _) => Some(adt_def.did),
|
||||
|
||||
ty::Dynamic(data, ..) => data.principal_def_id(),
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ impl DefPathBasedNames<'tcx> {
|
|||
// When being used for codegen purposes, `debug` should be set to `false`
|
||||
// in order to catch unexpected types that should never end up in a type name.
|
||||
pub fn push_type_name(&self, t: Ty<'tcx>, output: &mut String, debug: bool) {
|
||||
match t.sty {
|
||||
match t.kind {
|
||||
ty::Bool => output.push_str("bool"),
|
||||
ty::Char => output.push_str("char"),
|
||||
ty::Str => output.push_str("str"),
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||
// Inherent impls. Try to print `Foo::bar` for an inherent
|
||||
// impl on `Foo`, but fallback to `<Foo>::bar` if self-type is
|
||||
// anything other than a simple path.
|
||||
match self_ty.sty {
|
||||
match self_ty.kind {
|
||||
ty::Adt(..) | ty::Foreign(_) |
|
||||
ty::Bool | ty::Char | ty::Str |
|
||||
ty::Int(_) | ty::Uint(_) | ty::Float(_) => {
|
||||
|
|
@ -463,7 +463,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||
) -> Result<Self::Type, Self::Error> {
|
||||
define_scoped_cx!(self);
|
||||
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Bool => p!(write("bool")),
|
||||
ty::Char => p!(write("char")),
|
||||
ty::Int(t) => p!(write("{}", t.ty_to_string())),
|
||||
|
|
@ -739,7 +739,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||
// Special-case `Fn(...) -> ...` and resugar it.
|
||||
let fn_trait_kind = self.tcx().lang_items().fn_trait_kind(principal.def_id);
|
||||
if !self.tcx().sess.verbose() && fn_trait_kind.is_some() {
|
||||
if let ty::Tuple(ref args) = principal.substs.type_at(0).sty {
|
||||
if let ty::Tuple(ref args) = principal.substs.type_at(0).kind {
|
||||
let mut projections = predicates.projection_bounds();
|
||||
if let (Some(proj), None) = (projections.next(), projections.next()) {
|
||||
let tys: Vec<_> = args.iter().map(|k| k.expect_ty()).collect();
|
||||
|
|
@ -856,7 +856,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||
define_scoped_cx!(self);
|
||||
|
||||
let u8 = self.tcx().types.u8;
|
||||
if let ty::FnDef(did, substs) = ct.ty.sty {
|
||||
if let ty::FnDef(did, substs) = ct.ty.kind {
|
||||
p!(print_value_path(did, substs));
|
||||
return Ok(self);
|
||||
}
|
||||
|
|
@ -887,7 +887,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||
return Ok(self);
|
||||
}
|
||||
if let ConstValue::Scalar(Scalar::Raw { data, .. }) = ct.val {
|
||||
match ct.ty.sty {
|
||||
match ct.ty.kind {
|
||||
ty::Bool => {
|
||||
p!(write("{}", if data == 0 { "false" } else { "true" }));
|
||||
return Ok(self);
|
||||
|
|
@ -935,8 +935,8 @@ pub trait PrettyPrinter<'tcx>:
|
|||
_ => {},
|
||||
}
|
||||
}
|
||||
if let ty::Ref(_, ref_ty, _) = ct.ty.sty {
|
||||
let byte_str = match (ct.val, &ref_ty.sty) {
|
||||
if let ty::Ref(_, ref_ty, _) = ct.ty.kind {
|
||||
let byte_str = match (ct.val, &ref_ty.kind) {
|
||||
(ConstValue::Scalar(Scalar::Ptr(ptr)), ty::Array(t, n)) if *t == u8 => {
|
||||
let n = n.eval_usize(self.tcx(), ty::ParamEnv::empty());
|
||||
Some(self.tcx()
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
|
|||
) -> RelateResult<'tcx, Ty<'tcx>> {
|
||||
let tcx = relation.tcx();
|
||||
debug!("super_relate_tys: a={:?} b={:?}", a, b);
|
||||
match (&a.sty, &b.sty) {
|
||||
match (&a.kind, &b.kind) {
|
||||
(&ty::Infer(_), _) |
|
||||
(_, &ty::Infer(_)) =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1023,7 +1023,7 @@ impl<'tcx> TypeFoldable<'tcx> for interpret::GlobalId<'tcx> {
|
|||
|
||||
impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
||||
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
||||
let sty = match self.sty {
|
||||
let kind = match self.kind {
|
||||
ty::RawPtr(tm) => ty::RawPtr(tm.fold_with(folder)),
|
||||
ty::Array(typ, sz) => ty::Array(typ.fold_with(folder), sz.fold_with(folder)),
|
||||
ty::Slice(typ) => ty::Slice(typ.fold_with(folder)),
|
||||
|
|
@ -1064,13 +1064,13 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
|||
ty::Bound(..) |
|
||||
ty::Placeholder(..) |
|
||||
ty::Never |
|
||||
ty::Foreign(..) => return self
|
||||
ty::Foreign(..) => return self,
|
||||
};
|
||||
|
||||
if self.sty == sty {
|
||||
if self.kind == kind {
|
||||
self
|
||||
} else {
|
||||
folder.tcx().mk_ty(sty)
|
||||
folder.tcx().mk_ty(kind)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1079,7 +1079,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
|||
}
|
||||
|
||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
ty::RawPtr(ref tm) => tm.visit_with(visitor),
|
||||
ty::Array(typ, sz) => typ.visit_with(visitor) || sz.visit_with(visitor),
|
||||
ty::Slice(typ) => typ.visit_with(visitor),
|
||||
|
|
|
|||
|
|
@ -384,9 +384,9 @@ impl<'tcx> ClosureSubsts<'tcx> {
|
|||
/// If you have an inference context, use `infcx.closure_sig()`.
|
||||
pub fn closure_sig(self, def_id: DefId, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> {
|
||||
let ty = self.closure_sig_ty(def_id, tcx);
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::FnPtr(sig) => sig,
|
||||
_ => bug!("closure_sig_ty is not a fn-ptr: {:?}", ty.sty),
|
||||
_ => bug!("closure_sig_ty is not a fn-ptr: {:?}", ty.kind),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1678,7 +1678,7 @@ impl RegionKind {
|
|||
impl<'tcx> TyS<'tcx> {
|
||||
#[inline]
|
||||
pub fn is_unit(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Tuple(ref tys) => tys.is_empty(),
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1686,7 +1686,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_never(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Never => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1701,7 +1701,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
pub fn conservative_is_privately_uninhabited(&self, tcx: TyCtxt<'tcx>) -> bool {
|
||||
// FIXME(varkor): we can make this less conversative by substituting concrete
|
||||
// type arguments.
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
ty::Never => true,
|
||||
ty::Adt(def, _) if def.is_union() => {
|
||||
// For now, `union`s are never considered uninhabited.
|
||||
|
|
@ -1741,7 +1741,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_primitive(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Bool | Char | Int(_) | Uint(_) | Float(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1749,7 +1749,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_ty_var(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Infer(TyVar(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1757,7 +1757,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_ty_infer(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Infer(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1765,7 +1765,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_phantom_data(&self) -> bool {
|
||||
if let Adt(def, _) = self.sty {
|
||||
if let Adt(def, _) = self.kind {
|
||||
def.is_phantom_data()
|
||||
} else {
|
||||
false
|
||||
|
|
@ -1773,11 +1773,11 @@ impl<'tcx> TyS<'tcx> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_bool(&self) -> bool { self.sty == Bool }
|
||||
pub fn is_bool(&self) -> bool { self.kind == Bool }
|
||||
|
||||
#[inline]
|
||||
pub fn is_param(&self, index: u32) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
ty::Param(ref data) => data.index == index,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1785,8 +1785,8 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_slice(&self) -> bool {
|
||||
match self.sty {
|
||||
RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => match ty.sty {
|
||||
match self.kind {
|
||||
RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => match ty.kind {
|
||||
Slice(_) | Str => true,
|
||||
_ => false,
|
||||
},
|
||||
|
|
@ -1796,14 +1796,14 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_simd(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Adt(def, _) => def.repr.simd(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sequence_element_type(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Array(ty, _) | Slice(ty) => ty,
|
||||
Str => tcx.mk_mach_uint(ast::UintTy::U8),
|
||||
_ => bug!("sequence_element_type called on non-sequence value: {}", self),
|
||||
|
|
@ -1811,7 +1811,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
}
|
||||
|
||||
pub fn simd_type(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Adt(def, substs) => {
|
||||
def.non_enum_variant().fields[0].ty(tcx, substs)
|
||||
}
|
||||
|
|
@ -1820,7 +1820,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
}
|
||||
|
||||
pub fn simd_size(&self, _cx: TyCtxt<'_>) -> usize {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Adt(def, _) => def.non_enum_variant().fields.len(),
|
||||
_ => bug!("simd_size called on invalid type")
|
||||
}
|
||||
|
|
@ -1828,7 +1828,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_region_ptr(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Ref(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1836,7 +1836,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_mutable_ptr(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
RawPtr(TypeAndMut { mutbl: hir::Mutability::MutMutable, .. }) |
|
||||
Ref(_, _, hir::Mutability::MutMutable) => true,
|
||||
_ => false
|
||||
|
|
@ -1845,7 +1845,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_unsafe_ptr(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
RawPtr(_) => return true,
|
||||
_ => return false,
|
||||
}
|
||||
|
|
@ -1860,7 +1860,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
/// Returns `true` if this type is an `Arc<T>`.
|
||||
#[inline]
|
||||
pub fn is_arc(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Adt(def, _) => def.is_arc(),
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1869,7 +1869,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
/// Returns `true` if this type is an `Rc<T>`.
|
||||
#[inline]
|
||||
pub fn is_rc(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Adt(def, _) => def.is_rc(),
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1877,7 +1877,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_box(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Adt(def, _) => def.is_box(),
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1885,7 +1885,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
/// panics if called on any type other than `Box<T>`
|
||||
pub fn boxed_ty(&self) -> Ty<'tcx> {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Adt(def, substs) if def.is_box() => substs.type_at(0),
|
||||
_ => bug!("`boxed_ty` is called on non-box type {:?}", self),
|
||||
}
|
||||
|
|
@ -1896,7 +1896,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
/// contents are abstract to rustc.)
|
||||
#[inline]
|
||||
pub fn is_scalar(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Bool | Char | Int(_) | Float(_) | Uint(_) |
|
||||
Infer(IntVar(_)) | Infer(FloatVar(_)) |
|
||||
FnDef(..) | FnPtr(_) | RawPtr(_) => true,
|
||||
|
|
@ -1907,7 +1907,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
/// Returns `true` if this type is a floating point type.
|
||||
#[inline]
|
||||
pub fn is_floating_point(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Float(_) |
|
||||
Infer(FloatVar(_)) => true,
|
||||
_ => false,
|
||||
|
|
@ -1916,7 +1916,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_trait(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Dynamic(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1924,7 +1924,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_enum(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Adt(adt_def, _) => {
|
||||
adt_def.is_enum()
|
||||
}
|
||||
|
|
@ -1934,7 +1934,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_closure(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Closure(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1942,7 +1942,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_generator(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Generator(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1950,7 +1950,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_integral(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Infer(IntVar(_)) | Int(_) | Uint(_) => true,
|
||||
_ => false
|
||||
}
|
||||
|
|
@ -1958,7 +1958,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_fresh_ty(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Infer(FreshTy(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1966,7 +1966,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_fresh(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Infer(FreshTy(_)) => true,
|
||||
Infer(FreshIntTy(_)) => true,
|
||||
Infer(FreshFloatTy(_)) => true,
|
||||
|
|
@ -1976,7 +1976,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_char(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Char => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1989,7 +1989,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_signed(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Int(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1997,7 +1997,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_ptr_sized_integral(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Int(ast::IntTy::Isize) | Uint(ast::UintTy::Usize) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -2005,7 +2005,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_machine(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Int(..) | Uint(..) | Float(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -2013,7 +2013,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn has_concrete_skeleton(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Param(_) | Infer(_) | Error => false,
|
||||
_ => true,
|
||||
}
|
||||
|
|
@ -2024,7 +2024,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
/// The parameter `explicit` indicates if this is an *explicit* dereference.
|
||||
/// Some types -- notably unsafe ptrs -- can only be dereferenced explicitly.
|
||||
pub fn builtin_deref(&self, explicit: bool) -> Option<TypeAndMut<'tcx>> {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Adt(def, _) if def.is_box() => {
|
||||
Some(TypeAndMut {
|
||||
ty: self.boxed_ty(),
|
||||
|
|
@ -2039,14 +2039,14 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
/// Returns the type of `ty[i]`.
|
||||
pub fn builtin_index(&self) -> Option<Ty<'tcx>> {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Array(ty, _) | Slice(ty) => Some(ty),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fn_sig(&self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
FnDef(def_id, substs) => {
|
||||
tcx.fn_sig(def_id).subst(tcx, substs)
|
||||
}
|
||||
|
|
@ -2063,7 +2063,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_fn(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
FnDef(..) | FnPtr(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -2071,7 +2071,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_fn_ptr(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
FnPtr(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -2079,7 +2079,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_impl_trait(&self) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Opaque(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -2087,7 +2087,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Adt(adt, _) => Some(adt),
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -2096,7 +2096,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
/// Iterates over tuple fields.
|
||||
/// Panics when called on anything but a tuple.
|
||||
pub fn tuple_fields(&self) -> impl DoubleEndedIterator<Item=Ty<'tcx>> {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Tuple(substs) => substs.iter().map(|field| field.expect_ty()),
|
||||
_ => bug!("tuple_fields called on non-tuple"),
|
||||
}
|
||||
|
|
@ -2106,7 +2106,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
/// FIXME This requires the optimized MIR in the case of generators.
|
||||
#[inline]
|
||||
pub fn variant_range(&self, tcx: TyCtxt<'tcx>) -> Option<Range<VariantIdx>> {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
TyKind::Adt(adt, _) => Some(adt.variant_range()),
|
||||
TyKind::Generator(def_id, substs, _) => Some(substs.variant_range(def_id, tcx)),
|
||||
_ => None,
|
||||
|
|
@ -2122,7 +2122,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
tcx: TyCtxt<'tcx>,
|
||||
variant_index: VariantIdx,
|
||||
) -> Option<Discr<'tcx>> {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
TyKind::Adt(adt, _) => Some(adt.discriminant_for_variant(tcx, variant_index)),
|
||||
TyKind::Generator(def_id, substs, _) =>
|
||||
Some(substs.discriminant_for_variant(def_id, tcx, variant_index)),
|
||||
|
|
@ -2134,7 +2134,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
/// types reachable from this type via `walk_tys`). This ignores late-bound
|
||||
/// regions binders.
|
||||
pub fn push_regions(&self, out: &mut SmallVec<[ty::Region<'tcx>; 4]>) {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Ref(region, _, _) => {
|
||||
out.push(region);
|
||||
}
|
||||
|
|
@ -2190,7 +2190,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
/// inferred. Once upvar inference (in `src/librustc_typeck/check/upvar.rs`)
|
||||
/// is complete, that type variable will be unified.
|
||||
pub fn to_opt_closure_kind(&self) -> Option<ty::ClosureKind> {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
Int(int_ty) => match int_ty {
|
||||
ast::IntTy::I8 => Some(ty::ClosureKind::Fn),
|
||||
ast::IntTy::I16 => Some(ty::ClosureKind::FnMut),
|
||||
|
|
@ -2211,7 +2211,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
/// Returning true means the type is known to be sized. Returning
|
||||
/// `false` means nothing -- could be sized, might not be.
|
||||
pub fn is_trivially_sized(&self, tcx: TyCtxt<'tcx>) -> bool {
|
||||
match self.sty {
|
||||
match self.kind {
|
||||
ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) |
|
||||
ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) |
|
||||
ty::FnDef(..) | ty::FnPtr(_) | ty::RawPtr(..) |
|
||||
|
|
|
|||
|
|
@ -501,7 +501,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
|
|||
}
|
||||
self.ty_stack_depth += 1;
|
||||
|
||||
let t1 = match t.sty {
|
||||
let t1 = match t.kind {
|
||||
ty::Param(p) => {
|
||||
self.ty_for_param(p, t)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ pub struct Discr<'tcx> {
|
|||
|
||||
impl<'tcx> fmt::Display for Discr<'tcx> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.ty.sty {
|
||||
match self.ty.kind {
|
||||
ty::Int(ity) => {
|
||||
let size = ty::tls::with(|tcx| {
|
||||
Integer::from_attr(&tcx, SignedInt(ity)).size()
|
||||
|
|
@ -54,7 +54,7 @@ impl<'tcx> Discr<'tcx> {
|
|||
self.checked_add(tcx, 1).0
|
||||
}
|
||||
pub fn checked_add(self, tcx: TyCtxt<'tcx>, n: u128) -> (Self, bool) {
|
||||
let (int, signed) = match self.ty.sty {
|
||||
let (int, signed) = match self.ty.kind {
|
||||
Int(ity) => (Integer::from_attr(&tcx, SignedInt(ity)), true),
|
||||
Uint(uty) => (Integer::from_attr(&tcx, UnsignedInt(uty)), false),
|
||||
_ => bug!("non integer discriminant"),
|
||||
|
|
@ -179,7 +179,7 @@ impl<'tcx> ty::ParamEnv<'tcx> {
|
|||
) -> Result<(), CopyImplementationError<'tcx>> {
|
||||
// FIXME: (@jroesch) float this code up
|
||||
tcx.infer_ctxt().enter(|infcx| {
|
||||
let (adt, substs) = match self_type.sty {
|
||||
let (adt, substs) = match self_type.kind {
|
||||
// These types used to have a builtin impl.
|
||||
// Now libcore provides that impl.
|
||||
ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) |
|
||||
|
|
@ -246,10 +246,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
pub fn has_error_field(self, ty: Ty<'tcx>) -> bool {
|
||||
if let ty::Adt(def, substs) = ty.sty {
|
||||
if let ty::Adt(def, substs) = ty.kind {
|
||||
for field in def.all_fields() {
|
||||
let field_ty = field.ty(self, substs);
|
||||
if let Error = field_ty.sty {
|
||||
if let Error = field_ty.kind {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -298,7 +298,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
-> Ty<'tcx>
|
||||
{
|
||||
loop {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Adt(def, substs) => {
|
||||
if !def.is_struct() {
|
||||
break;
|
||||
|
|
@ -370,7 +370,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
{
|
||||
let (mut a, mut b) = (source, target);
|
||||
loop {
|
||||
match (&a.sty, &b.sty) {
|
||||
match (&a.kind, &b.kind) {
|
||||
(&Adt(a_def, a_substs), &Adt(b_def, b_substs))
|
||||
if a_def == b_def && a_def.is_struct() => {
|
||||
if let Some(f) = a_def.non_enum_variant().fields.last() {
|
||||
|
|
@ -544,12 +544,12 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
// <P1, P2, P0>, and then look up which of the impl substs refer to
|
||||
// parameters marked as pure.
|
||||
|
||||
let impl_substs = match self.type_of(impl_def_id).sty {
|
||||
let impl_substs = match self.type_of(impl_def_id).kind {
|
||||
ty::Adt(def_, substs) if def_ == def => substs,
|
||||
_ => bug!()
|
||||
};
|
||||
|
||||
let item_substs = match self.type_of(def.did).sty {
|
||||
let item_substs = match self.type_of(def.did).kind {
|
||||
ty::Adt(def_, substs) if def_ == def => substs,
|
||||
_ => bug!()
|
||||
};
|
||||
|
|
@ -561,7 +561,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
!impl_generics.region_param(ebr, self).pure_wrt_drop
|
||||
}
|
||||
UnpackedKind::Type(&ty::TyS {
|
||||
sty: ty::Param(ref pt), ..
|
||||
kind: ty::Param(ref pt), ..
|
||||
}) => {
|
||||
!impl_generics.type_param(pt, self).pure_wrt_drop
|
||||
}
|
||||
|
|
@ -733,7 +733,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||
if let ty::Opaque(def_id, substs) = t.sty {
|
||||
if let ty::Opaque(def_id, substs) = t.kind {
|
||||
self.expand_opaque_ty(def_id, substs).unwrap_or(t)
|
||||
} else {
|
||||
t.super_fold_with(self)
|
||||
|
|
@ -811,7 +811,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
}
|
||||
|
||||
pub fn same_type(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
|
||||
match (&a.sty, &b.sty) {
|
||||
match (&a.kind, &b.kind) {
|
||||
(&Adt(did_a, substs_a), &Adt(did_b, substs_b)) => {
|
||||
if did_a != did_b {
|
||||
return false;
|
||||
|
|
@ -846,7 +846,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Representability {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
Tuple(..) => {
|
||||
// Find non representable
|
||||
fold_repr(ty.tuple_fields().map(|ty| {
|
||||
|
|
@ -889,7 +889,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
}
|
||||
|
||||
fn same_struct_or_enum<'tcx>(ty: Ty<'tcx>, def: &'tcx ty::AdtDef) -> bool {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
Adt(ty_def, _) => {
|
||||
ty_def == def
|
||||
}
|
||||
|
|
@ -927,7 +927,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Representability {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
Adt(def, _) => {
|
||||
{
|
||||
// Iterate through stack of previously seen types.
|
||||
|
|
@ -1009,7 +1009,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
/// - `&'a *const &'b u8 -> *const &'b u8`
|
||||
pub fn peel_refs(&'tcx self) -> Ty<'tcx> {
|
||||
let mut ty = self;
|
||||
while let Ref(_, inner_ty, _) = ty.sty {
|
||||
while let Ref(_, inner_ty, _) = ty.kind {
|
||||
ty = inner_ty;
|
||||
}
|
||||
ty
|
||||
|
|
@ -1067,7 +1067,7 @@ fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>
|
|||
|
||||
assert!(!ty.needs_infer());
|
||||
|
||||
NeedsDrop(match ty.sty {
|
||||
NeedsDrop(match ty.kind {
|
||||
// Fast-path for primitive types
|
||||
ty::Infer(ty::FreshIntTy(_)) | ty::Infer(ty::FreshFloatTy(_)) |
|
||||
ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Never |
|
||||
|
|
@ -1170,7 +1170,7 @@ impl<'tcx> ExplicitSelf<'tcx> {
|
|||
{
|
||||
use self::ExplicitSelf::*;
|
||||
|
||||
match self_arg_ty.sty {
|
||||
match self_arg_ty.kind {
|
||||
_ if is_self_ty(self_arg_ty) => ByValue,
|
||||
ty::Ref(region, ty, mutbl) if is_self_ty(ty) => {
|
||||
ByReference(region, mutbl)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ pub fn walk_shallow(ty: Ty<'_>) -> smallvec::IntoIter<TypeWalkerArray<'_>> {
|
|||
// natural order one would expect (basically, the order of the
|
||||
// types as they are written).
|
||||
fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
|
||||
match parent_ty.sty {
|
||||
match parent_ty.kind {
|
||||
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) |
|
||||
ty::Str | ty::Infer(_) | ty::Param(_) | ty::Never | ty::Error |
|
||||
ty::Placeholder(..) | ty::Bound(..) | ty::Foreign(..) => {
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||
let mut subtys = ty0.walk();
|
||||
let param_env = self.param_env;
|
||||
while let Some(ty) = subtys.next() {
|
||||
match ty.sty {
|
||||
match ty.kind {
|
||||
ty::Bool |
|
||||
ty::Char |
|
||||
ty::Int(..) |
|
||||
|
|
@ -407,7 +407,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||
// is satisfied to ensure termination.)
|
||||
ty::Infer(_) => {
|
||||
let ty = self.infcx.shallow_resolve(ty);
|
||||
if let ty::Infer(_) = ty.sty { // not yet resolved...
|
||||
if let ty::Infer(_) = ty.kind { // not yet resolved...
|
||||
if ty == ty0 { // ...this is the type we started from! no progress.
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue