Skip to content

Commit 6e53cfa

Browse files
committed
syntax: fix de-@rooting fallout
1 parent aff620d commit 6e53cfa

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/libsyntax/ast_map.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -363,14 +363,15 @@ impl Map {
363363
}
364364

365365
pub fn with_attrs<T>(&self, id: NodeId, f: |Option<&[Attribute]>| -> T) -> T {
366-
let attrs = match self.get(id) {
367-
NodeItem(i) => Some(i.attrs.as_slice()),
368-
NodeForeignItem(fi) => Some(fi.attrs.as_slice()),
369-
NodeTraitMethod(tm) => match *tm {
366+
let node = self.get(id);
367+
let attrs = match node {
368+
NodeItem(ref i) => Some(i.attrs.as_slice()),
369+
NodeForeignItem(ref fi) => Some(fi.attrs.as_slice()),
370+
NodeTraitMethod(ref tm) => match **tm {
370371
Required(ref type_m) => Some(type_m.attrs.as_slice()),
371-
Provided(m) => Some(m.attrs.as_slice())
372+
Provided(ref m) => Some(m.attrs.as_slice())
372373
},
373-
NodeMethod(m) => Some(m.attrs.as_slice()),
374+
NodeMethod(ref m) => Some(m.attrs.as_slice()),
374375
NodeVariant(ref v) => Some(v.node.attrs.as_slice()),
375376
// unit/tuple structs take the attributes straight from
376377
// the struct definition.

src/libsyntax/ext/deriving/generic.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -814,26 +814,25 @@ impl<'a> MethodDef<'a> {
814814
"no self match on an enum in \
815815
generic `deriving`");
816816
}
817+
818+
// `ref` inside let matches is buggy. Causes havoc wih rusc.
819+
// let (variant_index, ref self_vec) = matches_so_far[0];
820+
let (variant, self_vec) = match matches_so_far.get(0) {
821+
&(_, v, ref s) => (v, s)
822+
};
823+
817824
// we currently have a vec of vecs, where each
818825
// subvec is the fields of one of the arguments,
819826
// but if the variants all match, we want this as
820827
// vec of tuples, where each tuple represents a
821828
// field.
822829

823-
let substructure;
824-
825830
// most arms don't have matching variants, so do a
826831
// quick check to see if they match (even though
827832
// this means iterating twice) instead of being
828833
// optimistic and doing a pile of allocations etc.
829-
match matching {
834+
let substructure = match matching {
830835
Some(variant_index) => {
831-
// `ref` inside let matches is buggy. Causes havoc wih rusc.
832-
// let (variant_index, ref self_vec) = matches_so_far[0];
833-
let (variant, self_vec) = match matches_so_far.get(0) {
834-
&(_, v, ref s) => (v, s)
835-
};
836-
837836
let mut enum_matching_fields = Vec::from_elem(self_vec.len(), Vec::new());
838837

839838
for triple in matches_so_far.tail().iter() {
@@ -856,12 +855,12 @@ impl<'a> MethodDef<'a> {
856855
other: (*other).clone()
857856
}
858857
}).collect();
859-
substructure = EnumMatching(variant_index, variant, field_tuples);
858+
EnumMatching(variant_index, variant, field_tuples)
860859
}
861860
None => {
862-
substructure = EnumNonMatching(matches_so_far.as_slice());
861+
EnumNonMatching(matches_so_far.as_slice())
863862
}
864-
}
863+
};
865864
self.call_substructure_method(cx, trait_, type_ident,
866865
self_args, nonself_args,
867866
&substructure)

0 commit comments

Comments
 (0)