Skip to content

Commit

Permalink
syntax: fix de-@rooting fallout
Browse files Browse the repository at this point in the history
  • Loading branch information
flaper87 committed Apr 23, 2014
1 parent aff620d commit 6e53cfa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
13 changes: 7 additions & 6 deletions src/libsyntax/ast_map.rs
Expand Up @@ -363,14 +363,15 @@ impl Map {
}

pub fn with_attrs<T>(&self, id: NodeId, f: |Option<&[Attribute]>| -> T) -> T {
let attrs = match self.get(id) {
NodeItem(i) => Some(i.attrs.as_slice()),
NodeForeignItem(fi) => Some(fi.attrs.as_slice()),
NodeTraitMethod(tm) => match *tm {
let node = self.get(id);
let attrs = match node {
NodeItem(ref i) => Some(i.attrs.as_slice()),
NodeForeignItem(ref fi) => Some(fi.attrs.as_slice()),
NodeTraitMethod(ref tm) => match **tm {
Required(ref type_m) => Some(type_m.attrs.as_slice()),
Provided(m) => Some(m.attrs.as_slice())
Provided(ref m) => Some(m.attrs.as_slice())
},
NodeMethod(m) => Some(m.attrs.as_slice()),
NodeMethod(ref m) => Some(m.attrs.as_slice()),
NodeVariant(ref v) => Some(v.node.attrs.as_slice()),
// unit/tuple structs take the attributes straight from
// the struct definition.
Expand Down
23 changes: 11 additions & 12 deletions src/libsyntax/ext/deriving/generic.rs
Expand Up @@ -814,26 +814,25 @@ impl<'a> MethodDef<'a> {
"no self match on an enum in \
generic `deriving`");
}

// `ref` inside let matches is buggy. Causes havoc wih rusc.
// let (variant_index, ref self_vec) = matches_so_far[0];
let (variant, self_vec) = match matches_so_far.get(0) {
&(_, v, ref s) => (v, s)
};

// we currently have a vec of vecs, where each
// subvec is the fields of one of the arguments,
// but if the variants all match, we want this as
// vec of tuples, where each tuple represents a
// field.

let substructure;

// most arms don't have matching variants, so do a
// quick check to see if they match (even though
// this means iterating twice) instead of being
// optimistic and doing a pile of allocations etc.
match matching {
let substructure = match matching {
Some(variant_index) => {
// `ref` inside let matches is buggy. Causes havoc wih rusc.
// let (variant_index, ref self_vec) = matches_so_far[0];
let (variant, self_vec) = match matches_so_far.get(0) {
&(_, v, ref s) => (v, s)
};

let mut enum_matching_fields = Vec::from_elem(self_vec.len(), Vec::new());

for triple in matches_so_far.tail().iter() {
Expand All @@ -856,12 +855,12 @@ impl<'a> MethodDef<'a> {
other: (*other).clone()
}
}).collect();
substructure = EnumMatching(variant_index, variant, field_tuples);
EnumMatching(variant_index, variant, field_tuples)
}
None => {
substructure = EnumNonMatching(matches_so_far.as_slice());
EnumNonMatching(matches_so_far.as_slice())
}
}
};
self.call_substructure_method(cx, trait_, type_ident,
self_args, nonself_args,
&substructure)
Expand Down

0 comments on commit 6e53cfa

Please sign in to comment.