Rollup merge of #22613 - nick29581:fix-save-alias, r=huonw

r? @huonw
This commit is contained in:
Manish Goregaokar 2015-02-23 14:44:40 +05:30
commit 90d4aaad3a

View file

@ -1002,18 +1002,28 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
ast::PatStruct(ref path, ref fields, _) => {
self.collected_paths.push((p.id, path.clone(), false, recorder::StructRef));
visit::walk_path(self, path);
let struct_def = match self.lookup_type_ref(p.id) {
Some(sd) => sd,
let def = self.analysis.ty_cx.def_map.borrow()[p.id];
let struct_def = match def {
def::DefConst(..) => None,
def::DefVariant(_, variant_id, _) => Some(variant_id),
_ => {
match ty::ty_to_def_id(ty::node_id_to_type(&self.analysis.ty_cx, p.id)) {
None => {
self.sess.span_bug(p.span,
&format!("Could not find struct_def for `{}`",
self.span.snippet(p.span)));
}
Some(def_id) => Some(def_id),
}
}
};
if let Some(struct_def) = struct_def {
let struct_fields = ty::lookup_struct_fields(&self.analysis.ty_cx, struct_def);
for &Spanned { node: ref field, span } in fields {
let sub_span = self.span.span_for_first_ident(span);
let fields = ty::lookup_struct_fields(&self.analysis.ty_cx, struct_def);
for f in fields {
for f in &struct_fields {
if f.name == field.ident.name {
self.fmt.ref_str(recorder::VarRef,
span,
@ -1026,6 +1036,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
self.visit_pat(&*field.pat);
}
}
}
ast::PatEnum(ref path, _) => {
self.collected_paths.push((p.id, path.clone(), false, recorder::VarRef));
visit::walk_pat(self, p);