Skip to content

Commit

Permalink
Rollup merge of rust-lang#64513 - varkor:sty-begone, r=eddyb
Browse files Browse the repository at this point in the history
Rename `TyS.sty` to `TyS.kind`

Fixes rust-lang#64353.

r? @eddyb
  • Loading branch information
Centril committed Sep 26, 2019
2 parents 33ef5dd + bc2a373 commit 64e8527
Show file tree
Hide file tree
Showing 179 changed files with 735 additions and 736 deletions.
2 changes: 1 addition & 1 deletion src/librustc/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/canonical/query_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/equate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
18 changes: 9 additions & 9 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(_))
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 \
Expand All @@ -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(_), _) |
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/freshen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/fudge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/lattice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions src/librustc/infer/nll_relate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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() =>
{
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/outlives/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/type_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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")
};
Expand Down Expand Up @@ -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);
}
}
Expand Down
Loading

0 comments on commit 64e8527

Please sign in to comment.