Use Names in hir::{Field, ExprMethodCall, ExprField}

This commit is contained in:
Vadim Petrochenkov 2015-09-20 14:00:18 +03:00
parent a4af958786
commit 64fb709f99
19 changed files with 79 additions and 91 deletions

View file

@ -1436,7 +1436,7 @@ fn is_discr_reassigned(bcx: Block, discr: &hir::Expr, body: &hir::Expr) -> bool
Some(def::DefLocal(vid)) | Some(def::DefUpvar(vid, _, _)) => vid,
_ => return false
};
(vid, Some(mc::NamedField(field.node.name)))
(vid, Some(mc::NamedField(field.node)))
},
hir::ExprTupField(ref base, field) => {
let vid = match bcx.tcx().def_map.borrow().get(&base.id).map(|d| d.full_def()) {

View file

@ -574,7 +574,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let (bv, bt) = const_expr(cx, &**base, param_substs, fn_args);
let brepr = adt::represent_type(cx, bt);
let vinfo = VariantInfo::from_ty(cx.tcx(), bt, None);
let ix = vinfo.field_index(field.node.name);
let ix = vinfo.field_index(field.node);
adt::const_get_field(cx, &*brepr, bv, vinfo.discr, ix)
},
hir::ExprTupField(ref base, idx) => {
@ -742,7 +742,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let VariantInfo { discr, fields } = VariantInfo::of_node(cx.tcx(), ety, e.id);
let cs = fields.iter().enumerate().map(|(ix, &Field(f_name, _))| {
match (fs.iter().find(|f| f_name == f.ident.node.name), base_val) {
match (fs.iter().find(|f| f_name == f.name.node), base_val) {
(Some(ref f), _) => const_expr(cx, &*f.expr, param_substs, fn_args).0,
(_, Some((bv, _))) => adt::const_get_field(cx, &*repr, bv, discr, ix),
(_, None) => cx.sess().span_bug(e.span, "missing struct field"),

View file

@ -664,8 +664,8 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
hir::ExprPath(..) => {
trans_def(bcx, expr, bcx.def(expr.id))
}
hir::ExprField(ref base, ident) => {
trans_rec_field(bcx, &**base, ident.node.name)
hir::ExprField(ref base, name) => {
trans_rec_field(bcx, &**base, name.node)
}
hir::ExprTupField(ref base, idx) => {
trans_rec_tup_field(bcx, &**base, idx.node)
@ -1114,7 +1114,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// trans. Shudder.
fn make_field(field_name: &str, expr: P<hir::Expr>) -> hir::Field {
hir::Field {
ident: codemap::dummy_spanned(token::str_to_ident(field_name)),
name: codemap::dummy_spanned(token::str_to_ident(field_name).name),
expr: expr,
span: codemap::DUMMY_SP,
}
@ -1408,7 +1408,7 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let mut need_base = vec![true; vinfo.fields.len()];
let numbered_fields = fields.iter().map(|field| {
let pos = vinfo.field_index(field.ident.node.name);
let pos = vinfo.field_index(field.name.node);
need_base[pos] = false;
(pos, &*field.expr)
}).collect::<Vec<_>>();