use middle::ty::adjustment;
use middle::ty::{self, Ty};
-use rustc_front::hir::{MutImmutable, MutMutable};
+use rustc_front::hir::{MutImmutable, MutMutable, PatKind};
use rustc_front::hir;
use syntax::ast;
use syntax::codemap::Span;
fn from_local(tcx: &ty::ctxt, id: ast::NodeId) -> MutabilityCategory {
let ret = match tcx.map.get(id) {
ast_map::NodeLocal(p) => match p.node {
- hir::PatIdent(bind_mode, _, _) => {
+ PatKind::Ident(bind_mode, _, _) => {
if bind_mode == hir::BindByValue(hir::MutMutable) {
McDeclared
} else {
// *being borrowed* is. But ideally we would put in a more
// fundamental fix to this conflated use of the node id.
let ret_ty = match pat.node {
- hir::PatIdent(hir::BindByRef(_), _, _) => {
+ PatKind::Ident(hir::BindByRef(_), _, _) => {
// a bind-by-ref means that the base_ty will be the type of the ident itself,
// but what we want here is the type of the underlying value being borrowed.
// So peel off one-level, turning the &T into T.
adjustment::AdjustReifyFnPointer |
adjustment::AdjustUnsafeFnPointer |
+ adjustment::AdjustMutToConstPointer |
adjustment::AdjustDerefRef(_) => {
debug!("cat_expr({:?}): {:?}",
adjustment,
let expr_ty = try!(self.expr_ty(expr));
match expr.node {
hir::ExprUnary(hir::UnDeref, ref e_base) => {
- let base_cmt = try!(self.cat_expr(&**e_base));
+ let base_cmt = try!(self.cat_expr(&e_base));
self.cat_deref(expr, base_cmt, 0, None)
}
hir::ExprField(ref base, f_name) => {
- let base_cmt = try!(self.cat_expr(&**base));
+ let base_cmt = try!(self.cat_expr(&base));
debug!("cat_expr(cat_field): id={} expr={:?} base={:?}",
expr.id,
expr,
}
hir::ExprTupField(ref base, idx) => {
- let base_cmt = try!(self.cat_expr(&**base));
+ let base_cmt = try!(self.cat_expr(&base));
Ok(self.cat_tup_field(expr, base_cmt, idx.node, expr_ty))
}
self.cat_deref_common(expr, base_cmt, 1, elem_ty, Some(context), true)
}
None => {
- self.cat_index(expr, try!(self.cat_expr(&**base)), context)
+ self.cat_index(expr, try!(self.cat_expr(&base)), context)
}
}
}
}
hir::ExprType(ref e, _) => {
- self.cat_expr(&**e)
+ self.cat_expr(&e)
}
hir::ExprAddrOf(..) | hir::ExprCall(..) |
hir::ExprAssign(..) | hir::ExprAssignOp(..) |
hir::ExprClosure(..) | hir::ExprRet(..) |
- hir::ExprUnary(..) | hir::ExprRange(..) |
+ hir::ExprUnary(..) |
hir::ExprMethodCall(..) | hir::ExprCast(..) |
hir::ExprVec(..) | hir::ExprTup(..) | hir::ExprIf(..) |
hir::ExprBinary(..) | hir::ExprWhile(..) |
None => {
self.tcx().sess.span_bug(
span,
- &*format!("No closure kind for {:?}", closure_id));
+ &format!("No closure kind for {:?}", closure_id));
}
}
}
None
};
- // Note: This goes up here (rather than within the PatEnum arm
+ // Note: This goes up here (rather than within the PatKind::TupleStruct arm
// alone) because struct patterns can refer to struct types or
// to struct variants within enums.
let cmt = match opt_def {
};
match pat.node {
- hir::PatWild => {
+ PatKind::Wild => {
// _
}
- hir::PatEnum(_, None) => {
+ PatKind::TupleStruct(_, None) => {
// variant(..)
}
- hir::PatEnum(_, Some(ref subpats)) => {
+ PatKind::TupleStruct(_, Some(ref subpats)) => {
match opt_def {
Some(Def::Variant(..)) => {
// variant(x, y, z)
for (i, subpat) in subpats.iter().enumerate() {
- let subpat_ty = try!(self.pat_ty(&**subpat)); // see (*2)
+ let subpat_ty = try!(self.pat_ty(&subpat)); // see (*2)
let subcmt =
self.cat_imm_interior(
pat, cmt.clone(), subpat_ty,
InteriorField(PositionalField(i)));
- try!(self.cat_pattern_(subcmt, &**subpat, op));
+ try!(self.cat_pattern_(subcmt, &subpat, op));
}
}
Some(Def::Struct(..)) => {
for (i, subpat) in subpats.iter().enumerate() {
- let subpat_ty = try!(self.pat_ty(&**subpat)); // see (*2)
+ let subpat_ty = try!(self.pat_ty(&subpat)); // see (*2)
let cmt_field =
self.cat_imm_interior(
pat, cmt.clone(), subpat_ty,
InteriorField(PositionalField(i)));
- try!(self.cat_pattern_(cmt_field, &**subpat, op));
+ try!(self.cat_pattern_(cmt_field, &subpat, op));
}
}
Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => {
for subpat in subpats {
- try!(self.cat_pattern_(cmt.clone(), &**subpat, op));
+ try!(self.cat_pattern_(cmt.clone(), &subpat, op));
}
}
_ => {
}
}
- hir::PatQPath(..) => {
- // Lone constant: ignore
+ PatKind::Path(..) | PatKind::QPath(..) | PatKind::Ident(_, _, None) => {
+ // Lone constant, or unit variant or identifier: ignore
}
- hir::PatIdent(_, _, Some(ref subpat)) => {
- try!(self.cat_pattern_(cmt, &**subpat, op));
+ PatKind::Ident(_, _, Some(ref subpat)) => {
+ try!(self.cat_pattern_(cmt, &subpat, op));
}
- hir::PatIdent(_, _, None) => {
- // nullary variant or identifier: ignore
- }
-
- hir::PatStruct(_, ref field_pats, _) => {
+ PatKind::Struct(_, ref field_pats, _) => {
// {f1: p1, ..., fN: pN}
for fp in field_pats {
- let field_ty = try!(self.pat_ty(&*fp.node.pat)); // see (*2)
+ let field_ty = try!(self.pat_ty(&fp.node.pat)); // see (*2)
let cmt_field = self.cat_field(pat, cmt.clone(), fp.node.name, field_ty);
- try!(self.cat_pattern_(cmt_field, &*fp.node.pat, op));
+ try!(self.cat_pattern_(cmt_field, &fp.node.pat, op));
}
}
- hir::PatTup(ref subpats) => {
+ PatKind::Tup(ref subpats) => {
// (p1, ..., pN)
for (i, subpat) in subpats.iter().enumerate() {
- let subpat_ty = try!(self.pat_ty(&**subpat)); // see (*2)
+ let subpat_ty = try!(self.pat_ty(&subpat)); // see (*2)
let subcmt =
self.cat_imm_interior(
pat, cmt.clone(), subpat_ty,
InteriorField(PositionalField(i)));
- try!(self.cat_pattern_(subcmt, &**subpat, op));
+ try!(self.cat_pattern_(subcmt, &subpat, op));
}
}
- hir::PatBox(ref subpat) | hir::PatRegion(ref subpat, _) => {
+ PatKind::Box(ref subpat) | PatKind::Ref(ref subpat, _) => {
// box p1, &p1, &mut p1. we can ignore the mutability of
- // PatRegion since that information is already contained
+ // PatKind::Ref since that information is already contained
// in the type.
let subcmt = try!(self.cat_deref(pat, cmt, 0, None));
- try!(self.cat_pattern_(subcmt, &**subpat, op));
+ try!(self.cat_pattern_(subcmt, &subpat, op));
}
- hir::PatVec(ref before, ref slice, ref after) => {
+ PatKind::Vec(ref before, ref slice, ref after) => {
let context = InteriorOffsetKind::Pattern;
let vec_cmt = try!(self.deref_vec(pat, cmt, context));
let elt_cmt = try!(self.cat_index(pat, vec_cmt, context));
for before_pat in before {
- try!(self.cat_pattern_(elt_cmt.clone(), &**before_pat, op));
+ try!(self.cat_pattern_(elt_cmt.clone(), &before_pat, op));
}
if let Some(ref slice_pat) = *slice {
- let slice_ty = try!(self.pat_ty(&**slice_pat));
+ let slice_ty = try!(self.pat_ty(&slice_pat));
let slice_cmt = self.cat_rvalue_node(pat.id(), pat.span(), slice_ty);
- try!(self.cat_pattern_(slice_cmt, &**slice_pat, op));
+ try!(self.cat_pattern_(slice_cmt, &slice_pat, op));
}
for after_pat in after {
- try!(self.cat_pattern_(elt_cmt.clone(), &**after_pat, op));
+ try!(self.cat_pattern_(elt_cmt.clone(), &after_pat, op));
}
}
- hir::PatLit(_) | hir::PatRange(_, _) => {
+ PatKind::Lit(_) | PatKind::Range(_, _) => {
/*always ok*/
}
}