diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-12-30 21:38:43 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2020-03-09 20:50:48 +0300 |
| commit | eafeb9a2676e16ed322e9e0695b5ce9407f5de8d (patch) | |
| tree | 24acfbd6311258a234afc28d517efe24863e0c5d | |
| parent | 3dbade652ed8ebac70f903e01f51cd92c4e4302c (diff) | |
| download | rust-eafeb9a2676e16ed322e9e0695b5ce9407f5de8d.tar.gz rust-eafeb9a2676e16ed322e9e0695b5ce9407f5de8d.zip | |
expand/builtin_macros: Minor cleanup
| -rw-r--r-- | src/librustc_builtin_macros/util.rs | 2 | ||||
| -rw-r--r-- | src/librustc_expand/base.rs | 13 | ||||
| -rw-r--r-- | src/librustc_feature/builtin_attrs.rs | 8 |
3 files changed, 5 insertions, 18 deletions
diff --git a/src/librustc_builtin_macros/util.rs b/src/librustc_builtin_macros/util.rs index 8ef76a8657e..b486eadd1a8 100644 --- a/src/librustc_builtin_macros/util.rs +++ b/src/librustc_builtin_macros/util.rs @@ -6,7 +6,7 @@ use rustc_span::Symbol; pub fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaItem, name: Symbol) { // All the built-in macro attributes are "words" at the moment. - let template = AttributeTemplate::only_word(); + let template = AttributeTemplate { word: true, ..Default::default() }; let attr = ecx.attribute(meta_item.clone()); validate_attr::check_builtin_attribute(ecx.parse_sess, &attr, name, template); } diff --git a/src/librustc_expand/base.rs b/src/librustc_expand/base.rs index f15e626c278..55e9c70d637 100644 --- a/src/librustc_expand/base.rs +++ b/src/librustc_expand/base.rs @@ -270,10 +270,9 @@ pub trait MultiItemModifier { ) -> Vec<Annotatable>; } -impl<F, T> MultiItemModifier for F +impl<F> MultiItemModifier for F where - F: Fn(&mut ExtCtxt<'_>, Span, &ast::MetaItem, Annotatable) -> T, - T: Into<Vec<Annotatable>>, + F: Fn(&mut ExtCtxt<'_>, Span, &ast::MetaItem, Annotatable) -> Vec<Annotatable>, { fn expand( &self, @@ -282,13 +281,7 @@ where meta_item: &ast::MetaItem, item: Annotatable, ) -> Vec<Annotatable> { - (*self)(ecx, span, meta_item, item).into() - } -} - -impl Into<Vec<Annotatable>> for Annotatable { - fn into(self) -> Vec<Annotatable> { - vec![self] + self(ecx, span, meta_item, item) } } diff --git a/src/librustc_feature/builtin_attrs.rs b/src/librustc_feature/builtin_attrs.rs index e9a5364c658..e0e38c2dba9 100644 --- a/src/librustc_feature/builtin_attrs.rs +++ b/src/librustc_feature/builtin_attrs.rs @@ -85,19 +85,13 @@ impl AttributeGate { /// A template that the attribute input must match. /// Only top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is considered now. -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Default)] pub struct AttributeTemplate { pub word: bool, pub list: Option<&'static str>, pub name_value_str: Option<&'static str>, } -impl AttributeTemplate { - pub fn only_word() -> Self { - Self { word: true, list: None, name_value_str: None } - } -} - /// A convenience macro for constructing attribute templates. /// E.g., `template!(Word, List: "description")` means that the attribute /// supports forms `#[attr]` and `#[attr(description)]`. |
