// FnMut | copied -> &'env mut | upvar -> &'env mut -> &'up bk
// FnOnce | copied | upvar -> &'up bk
- let kind = match self.node_ty(fn_hir_id)?.sty {
+ let ty = self.node_ty(fn_hir_id)?;
+ let kind = match ty.sty {
ty::Generator(..) => ty::ClosureKind::FnOnce,
ty::Closure(closure_def_id, closure_substs) => {
match self.infcx {
.closure_kind(closure_def_id, self.tcx.global_tcx()),
}
}
- ref t => span_bug!(span, "unexpected type for fn in mem_categorization: {:?}", t),
+ _ => span_bug!(span, "unexpected type for fn in mem_categorization: {:?}", ty),
};
let closure_expr_def_id = self.tcx.hir().local_def_id(fn_node_id);
let bk = ty::BorrowKind::from_mutbl(mutbl);
BorrowedPtr(bk, r)
}
- ref ty => bug!("unexpected type in cat_deref: {:?}", ty)
+ _ => bug!("unexpected type in cat_deref: {:?}", base_cmt.ty)
};
let ret = cmt_ {
hir_id: node.hir_id(),
self.tcx.adt_def(enum_def).variant_with_id(def_id).fields.len())
}
Def::StructCtor(_, CtorKind::Fn) | Def::SelfCtor(..) => {
- match self.pat_ty_unadjusted(&pat)?.sty {
+ let ty = self.pat_ty_unadjusted(&pat)?;
+ match ty.sty {
ty::Adt(adt_def, _) => {
(cmt, adt_def.non_enum_variant().fields.len())
}
- ref ty => {
+ _ => {
span_bug!(pat.span,
"tuple struct pattern unexpected type {:?}", ty);
}
PatKind::Tuple(ref subpats, ddpos) => {
// (p1, ..., pN)
- let expected_len = match self.pat_ty_unadjusted(&pat)?.sty {
+ let ty = self.pat_ty_unadjusted(&pat)?;
+ let expected_len = match ty.sty {
ty::Tuple(ref tys) => tys.len(),
- ref ty => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty),
+ _ => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty),
};
for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) {
let subpat_ty = self.pat_ty_adjusted(&subpat)?; // see (*2)
_ => vec![ArgKind::empty()],
};
- let expected = match expected_trait_ref.skip_binder().substs.type_at(1).sty {
+ let expected_ty = expected_trait_ref.skip_binder().substs.type_at(1);
+ let expected = match expected_ty.sty {
ty::Tuple(ref tys) => tys.iter()
.map(|t| ArgKind::from_expected_ty(t, Some(span))).collect(),
- ref sty => vec![ArgKind::Arg("_".to_owned(), sty.to_string())],
+ _ => vec![ArgKind::Arg("_".to_owned(), expected_ty.to_string())],
};
if found.len() == expected.len() {
ty::Tuple(ref tys) => ArgKind::Tuple(
span,
tys.iter()
- .map(|ty| ("_".to_owned(), ty.sty.to_string()))
+ .map(|ty| ("_".to_owned(), ty.to_string()))
.collect::<Vec<_>>()
),
- _ => ArgKind::Arg("_".to_owned(), t.sty.to_string()),
+ _ => ArgKind::Arg("_".to_owned(), t.to_string()),
}
}
}
where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
{
let tcx = relation.tcx();
- let a_sty = &a.sty;
- let b_sty = &b.sty;
- debug!("super_relate_tys: a_sty={:?} b_sty={:?}", a_sty, b_sty);
- match (a_sty, b_sty) {
+ debug!("super_relate_tys: a={:?} b={:?}", a, b);
+ match (&a.sty, &b.sty) {
(&ty::Infer(_), _) |
(_, &ty::Infer(_)) =>
{
/// N.B., if you change this, you'll probably want to change the corresponding
/// AST structure in `libsyntax/ast.rs` as well.
-#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug,
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
RustcEncodable, RustcDecodable, HashStable)]
pub enum TyKind<'tcx> {
/// The primitive boolean type. Written as `bool`.
///
/// If you have an inference context, use `infcx.closure_sig()`.
pub fn closure_sig(self, def_id: DefId, tcx: TyCtxt<'_, 'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> {
- match self.closure_sig_ty(def_id, tcx).sty {
+ let ty = self.closure_sig_ty(def_id, tcx);
+ match ty.sty {
ty::FnPtr(sig) => sig,
- ref t => bug!("closure_sig_ty is not a fn-ptr: {:?}", t),
+ _ => bug!("closure_sig_ty is not a fn-ptr: {:?}", ty),
}
}
}
}
define_print! {
- ('tcx) ty::TyKind<'tcx>, (self, f, cx) {
+ ('tcx) ty::TyS<'tcx>, (self, f, cx) {
display {
- match *self {
+ match self.sty {
Bool => write!(f, "bool"),
Char => write!(f, "char"),
Int(t) => write!(f, "{}", t.ty_to_string()),
}
}
}
- }
-}
-
-define_print! {
- ('tcx) ty::TyS<'tcx>, (self, f, cx) {
- display {
- self.sty.print(f, cx)
- }
debug {
- self.sty.print_display(f, cx)
+ self.print_display(f, cx)
}
}
}
},
"fadd_fast" | "fsub_fast" | "fmul_fast" | "fdiv_fast" | "frem_fast" => {
- let sty = &arg_tys[0].sty;
- match float_type_width(sty) {
+ match float_type_width(arg_tys[0]) {
Some(_width) =>
match name {
"fadd_fast" => self.fadd_fast(args[0].immediate(), args[1].immediate()),
span_invalid_monomorphization_error(
tcx.sess, span,
&format!("invalid monomorphization of `{}` intrinsic: \
- expected basic float type, found `{}`", name, sty));
+ expected basic float type, found `{}`", name, arg_tys[0]));
return;
}
}
require!(false, "expected element type `{}` of second argument `{}` \
to be a pointer to the element type `{}` of the first \
argument `{}`, found `{}` != `*_ {}`",
- arg_tys[1].simd_type(tcx).sty, arg_tys[1], in_elem, in_ty,
- arg_tys[1].simd_type(tcx).sty, in_elem);
+ arg_tys[1].simd_type(tcx), arg_tys[1], in_elem, in_ty,
+ arg_tys[1].simd_type(tcx), in_elem);
unreachable!();
}
};
_ => {
require!(false, "expected element type `{}` of third argument `{}` \
to be a signed integer type",
- arg_tys[2].simd_type(tcx).sty, arg_tys[2]);
+ arg_tys[2].simd_type(tcx), arg_tys[2]);
}
}
require!(false, "expected element type `{}` of second argument `{}` \
to be a pointer to the element type `{}` of the first \
argument `{}`, found `{}` != `*mut {}`",
- arg_tys[1].simd_type(tcx).sty, arg_tys[1], in_elem, in_ty,
- arg_tys[1].simd_type(tcx).sty, in_elem);
+ arg_tys[1].simd_type(tcx), arg_tys[1], in_elem, in_ty,
+ arg_tys[1].simd_type(tcx), in_elem);
unreachable!();
}
};
_ => {
require!(false, "expected element type `{}` of third argument `{}` \
to be a signed integer type",
- arg_tys[2].simd_type(tcx).sty, arg_tys[2]);
+ arg_tys[2].simd_type(tcx), arg_tys[2]);
}
}
}
}
-// Returns the width of a float TypeVariant
+// Returns the width of a float Ty
// Returns None if the type is not a float
-fn float_type_width<'tcx>(sty: &ty::TyKind<'tcx>) -> Option<u64> {
- match *sty {
+fn float_type_width(ty: Ty) -> Option<u64> {
+ match ty.sty {
ty::Float(t) => Some(t.bit_width() as u64),
_ => None,
}
let field_ty = c.ty.builtin_index().unwrap();
let fields = match c.ty.sty {
ty::Array(_, n) => n.unwrap_usize(bx.tcx()),
- ref other => bug!("invalid simd shuffle type: {}", other),
+ _ => bug!("invalid simd shuffle type: {}", c.ty),
};
let values: Vec<_> = (0..fields).map(|field| {
let field = const_field(
match tail.sty {
ty::Foreign(..) => false,
ty::Str | ty::Slice(..) | ty::Dynamic(..) => true,
- _ => bug!("unexpected unsized tail: {:?}", tail.sty),
+ _ => bug!("unexpected unsized tail: {:?}", tail),
}
}
}
// (https://github.com/rust-lang/rfcs/pull/1546)
bug!(
"End-user description not implemented for field access on `{:?}`",
- ty.sty
+ ty
);
}
}
let user_provided_types = cx.tables.user_provided_types();
let user_provided_type = user_provided_types.get(expr.hir_id).map(|u_ty| *u_ty);
debug!("convert_path_expr: user_provided_type={:?}", user_provided_type);
- match cx.tables().node_type(expr.hir_id).sty {
+ let ty = cx.tables().node_type(expr.hir_id);
+ match ty.sty {
// A unit struct/variant which is used as a value.
// We return a completely different ExprKind here to account for this special case.
ty::Adt(adt_def, substs) => {
base: None,
}
}
- ref sty => bug!("unexpected sty: {:?}", sty),
+ _ => bug!("unexpected ty: {:?}", ty),
}
}
ty::Error => { // Avoid ICE
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
}
- ref sty =>
+ _ =>
span_bug!(
pat.span,
"unexpanded type for vector pattern: {:?}",
- sty),
+ ty),
}
}
ty::Error => { // Avoid ICE (#50577)
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
}
- ref sty => span_bug!(pat.span, "unexpected type for tuple pattern: {:?}", sty),
+ _ => span_bug!(pat.span, "unexpected type for tuple pattern: {:?}", ty),
}
}
}
_ => span_bug!(pat.span,
"tuple struct pattern not applied to an ADT {:?}",
- ty.sty),
+ ty),
};
let variant_def = adt_def.variant_of_def(def);
ty::Error => { // Avoid ICE (#50585)
return PatternKind::Wild;
}
- _ => bug!("inappropriate type for def: {:?}", ty.sty),
+ _ => bug!("inappropriate type for def: {:?}", ty),
};
PatternKind::Variant {
adt_def,
let user_provided_types = self.tables().user_provided_types();
let mut user_ty = *user_provided_types.get(hir_id)?;
debug!("user_subts_applied_to_ty_of_hir_id: user_ty={:?}", user_ty);
- match &self.tables().node_type(hir_id).sty {
+ let ty = self.tables().node_type(hir_id);
+ match ty.sty {
ty::Adt(adt_def, ..) => {
if let UserType::TypeOf(ref mut did, _) = &mut user_ty.value {
*did = adt_def.did;
Some(user_ty)
}
ty::FnDef(..) => Some(user_ty),
- sty =>
- bug!("sty: {:?} should not have user provided type {:?} recorded ", sty, user_ty),
+ _ => bug!(
+ "ty: {:?} should not have user provided type {:?} recorded ",
+ ty,
+ user_ty
+ ),
}
}
}
let fn_ptr = self.memory.create_fn_alloc(instance?).with_default_tag();
self.write_scalar(Scalar::Ptr(fn_ptr.into()), dest)?;
}
- ref other => bug!("reify fn pointer on {:?}", other),
+ _ => bug!("reify fn pointer on {:?}", src.layout.ty),
}
}
// No change to value
self.write_immediate(*src, dest)?;
}
- ref other => bug!("fn to unsafe fn cast on {:?}", other),
+ _ => bug!("fn to unsafe fn cast on {:?}", dest.layout.ty),
}
}
let val = Immediate::Scalar(Scalar::Ptr(fn_ptr.into()).into());
self.write_immediate(val, dest)?;
}
- ref other => bug!("closure fn pointer on {:?}", other),
+ _ => bug!("closure fn pointer on {:?}", src.layout.ty),
}
}
}
let layout = val.layout;
let val = val.to_scalar()?;
- trace!("Running unary op {:?}: {:?} ({:?})", un_op, val, layout.ty.sty);
+ trace!("Running unary op {:?}: {:?} ({:?})", un_op, val, layout.ty);
match layout.ty.sty {
ty::Bool => {
ty::Ref(_, _, mutbl) => Some(mutbl),
ty::Adt(def, _) if def.is_box() => Some(hir::MutMutable),
ty::RawPtr(_) => None,
- _ => bug!("Unexpected pointer type {}", val.layout.ty.sty),
+ _ => bug!("Unexpected pointer type {}", val.layout.ty),
};
place.mplace.ptr = M::tag_dereference(self, place, mutbl)?;
Ok(place)
match tail.sty {
ty::Foreign(..) => false,
ty::Str | ty::Slice(..) | ty::Dynamic(..) => true,
- _ => bug!("unexpected unsized tail: {:?}", tail.sty),
+ _ => bug!("unexpected unsized tail: {:?}", tail),
}
};
if type_has_metadata(inner_source) {
/// removing the dummy `Self` type (`TRAIT_OBJECT_DUMMY_SELF`).
fn trait_ref_to_existential(&self, trait_ref: ty::TraitRef<'tcx>)
-> ty::ExistentialTraitRef<'tcx> {
- assert_eq!(trait_ref.self_ty().sty, TRAIT_OBJECT_DUMMY_SELF);
+ if trait_ref.self_ty().sty != TRAIT_OBJECT_DUMMY_SELF {
+ bug!("trait_ref_to_existential called on {:?} with non-dummy Self", trait_ref);
+ }
ty::ExistentialTraitRef::erase_self_ty(self.tcx(), trait_ref)
}
// See the examples in `run-pass/match-defbm*.rs`.
let mut pat_adjustments = vec![];
while let ty::Ref(_, inner_ty, inner_mutability) = exp_ty.sty {
- debug!("inspecting {:?} with type {:?}", exp_ty, exp_ty.sty);
+ debug!("inspecting {:?}", exp_ty);
debug!("current discriminant is Ref, inserting implicit deref");
// Preserve the reference type. We'll need it later during HAIR lowering.
subpats.len() < variant.fields.len() && ddpos.is_some() {
let substs = match pat_ty.sty {
ty::Adt(_, substs) => substs,
- ref ty => bug!("unexpected pattern type {:?}", ty),
+ _ => bug!("unexpected pattern type {:?}", pat_ty),
};
for (i, subpat) in subpats.iter().enumerate_and_adjust(variant.fields.len(), ddpos) {
let field_ty = self.field_ty(subpat.span, &variant.fields[i], substs);
ty::Adt(adt, substs) => {
Some((adt.variant_of_def(def), adt.did, substs))
}
- _ => bug!("unexpected type: {:?}", ty.sty)
+ _ => bug!("unexpected type: {:?}", ty)
}
}
Def::Struct(..) | Def::Union(..) | Def::TyAlias(..) |
debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.node);
let sp = ty.span;
let ty = AstConv::ast_ty_to_ty(self, ty);
- debug!("suggest_missing_return_type: return type sty {:?}", ty.sty);
- debug!("suggest_missing_return_type: expected type sty {:?}", ty.sty);
+ debug!("suggest_missing_return_type: return type {:?}", ty);
+ debug!("suggest_missing_return_type: expected type {:?}", ty);
if ty.sty == expected.sty {
err.span_label(sp, format!("expected `{}` because of return type",
expected));
);
// Extract the type of the closure.
- let (closure_def_id, substs) = match self.node_ty(closure_hir_id).sty {
+ let ty = self.node_ty(closure_hir_id);
+ let (closure_def_id, substs) = match ty.sty {
ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)),
ty::Generator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)),
ty::Error => {
// #51714: skip analysis when we have already encountered type errors
return;
}
- ref t => {
+ _ => {
span_bug!(
span,
"type of closure expr {:?} is not a closure {:?}",
closure_hir_id,
- t
+ ty
);
}
};
span: Span,
ty: Ty<'tcx>,
) -> Vec<ty::Predicate<'tcx>> {
- trace!("check_existential_types: {:?}, {:?}", ty, ty.sty);
+ trace!("check_existential_types: {:?}", ty);
let mut substituted_predicates = Vec::new();
ty.fold_with(&mut ty::fold::BottomUpFolder {
tcx: fcx.tcx,
instantiated_ty.fold_with(&mut BottomUpFolder {
tcx: self.tcx().global_tcx(),
fldop: |ty| {
- trace!("checking type {:?}: {:#?}", ty, ty.sty);
+ trace!("checking type {:?}", ty);
// find a type parameter
if let ty::Param(..) = ty.sty {
// look it up in the substitution list