Skip to content

Commit eafeb9a

Browse files
committed
expand/builtin_macros: Minor cleanup
1 parent 3dbade6 commit eafeb9a

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

src/librustc_builtin_macros/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_span::Symbol;
66

77
pub fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaItem, name: Symbol) {
88
// All the built-in macro attributes are "words" at the moment.
9-
let template = AttributeTemplate::only_word();
9+
let template = AttributeTemplate { word: true, ..Default::default() };
1010
let attr = ecx.attribute(meta_item.clone());
1111
validate_attr::check_builtin_attribute(ecx.parse_sess, &attr, name, template);
1212
}

src/librustc_expand/base.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,9 @@ pub trait MultiItemModifier {
270270
) -> Vec<Annotatable>;
271271
}
272272

273-
impl<F, T> MultiItemModifier for F
273+
impl<F> MultiItemModifier for F
274274
where
275-
F: Fn(&mut ExtCtxt<'_>, Span, &ast::MetaItem, Annotatable) -> T,
276-
T: Into<Vec<Annotatable>>,
275+
F: Fn(&mut ExtCtxt<'_>, Span, &ast::MetaItem, Annotatable) -> Vec<Annotatable>,
277276
{
278277
fn expand(
279278
&self,
@@ -282,13 +281,7 @@ where
282281
meta_item: &ast::MetaItem,
283282
item: Annotatable,
284283
) -> Vec<Annotatable> {
285-
(*self)(ecx, span, meta_item, item).into()
286-
}
287-
}
288-
289-
impl Into<Vec<Annotatable>> for Annotatable {
290-
fn into(self) -> Vec<Annotatable> {
291-
vec![self]
284+
self(ecx, span, meta_item, item)
292285
}
293286
}
294287

src/librustc_feature/builtin_attrs.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,13 @@ impl AttributeGate {
8585

8686
/// A template that the attribute input must match.
8787
/// Only top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is considered now.
88-
#[derive(Clone, Copy)]
88+
#[derive(Clone, Copy, Default)]
8989
pub struct AttributeTemplate {
9090
pub word: bool,
9191
pub list: Option<&'static str>,
9292
pub name_value_str: Option<&'static str>,
9393
}
9494

95-
impl AttributeTemplate {
96-
pub fn only_word() -> Self {
97-
Self { word: true, list: None, name_value_str: None }
98-
}
99-
}
100-
10195
/// A convenience macro for constructing attribute templates.
10296
/// E.g., `template!(Word, List: "description")` means that the attribute
10397
/// supports forms `#[attr]` and `#[attr(description)]`.

0 commit comments

Comments
 (0)