diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr/mod.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 2 |
5 files changed, 9 insertions, 4 deletions
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 5404420988c..64876659477 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -455,6 +455,11 @@ pub fn find_by_name<'a>(attrs: &'a [Attribute], name: &str) -> Option<&'a Attrib attrs.iter().find(|attr| attr.check_name(name)) } +pub fn filter_by_name<'a>(attrs: &'a [Attribute], name: &'a str) + -> impl Iterator<Item = &'a Attribute> { + attrs.iter().filter(move |attr| attr.check_name(name)) +} + pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: &str) -> Option<Symbol> { attrs.iter() .find(|at| at.check_name(name)) diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index f5d1bd6255e..e1ba8897a47 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -126,7 +126,7 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::T } } - Box::new(ExpandResult { p: p }) + Box::new(ExpandResult { p }) } // include_str! : read the given file, insert it as a literal string expr diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index cb15c517c17..55652c481bd 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1614,7 +1614,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } ast::ItemKind::Struct(..) => { - if let Some(attr) = attr::find_by_name(&i.attrs[..], "repr") { + for attr in attr::filter_by_name(&i.attrs[..], "repr") { for item in attr.meta_item_list().unwrap_or_else(Vec::new) { if item.check_name("simd") { gate_feature_post!(&self, repr_simd, attr.span, diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index bec193548e1..0e6e2f90693 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -945,7 +945,7 @@ pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind { ItemKind::Enum(enum_definition, generics) => { let generics = folder.fold_generics(generics); let variants = enum_definition.variants.move_map(|x| folder.fold_variant(x)); - ItemKind::Enum(ast::EnumDef { variants: variants }, generics) + ItemKind::Enum(ast::EnumDef { variants }, generics) } ItemKind::Struct(struct_def, generics) => { let generics = folder.fold_generics(generics); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7e29eaae4e8..c8a686da179 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6929,7 +6929,7 @@ impl<'a> Parser<'a> { _ => () } - Ok(ast::EnumDef { variants: variants }) + Ok(ast::EnumDef { variants }) } /// Parse an "enum" declaration |
