Skip to content

Commit 8417ac6

Browse files
Inline attribute constructors
1 parent e41aa8c commit 8417ac6

File tree

4 files changed

+10
-21
lines changed

4 files changed

+10
-21
lines changed

src/libsyntax/ext/build.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -640,18 +640,4 @@ impl<'a> ExtCtxt<'a> {
640640
pub fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem {
641641
attr::mk_word_item(Ident::new(w, sp))
642642
}
643-
644-
pub fn meta_list_item_word(&self, sp: Span, w: ast::Name) -> ast::NestedMetaItem {
645-
attr::mk_nested_word_item(Ident::new(w, sp))
646-
}
647-
648-
pub fn meta_list(&self, sp: Span, name: ast::Name, mis: Vec<ast::NestedMetaItem>)
649-
-> ast::MetaItem {
650-
attr::mk_list_item(Ident::new(name, sp), mis)
651-
}
652-
653-
pub fn meta_name_value(&self, span: Span, name: ast::Name, lit_kind: ast::LitKind)
654-
-> ast::MetaItem {
655-
attr::mk_name_value_item(Ident::new(name, span), lit_kind, span)
656-
}
657643
}

src/libsyntax_ext/deriving/cmp/eq.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::deriving::path_std;
22
use crate::deriving::generic::*;
33
use crate::deriving::generic::ty::*;
44

5-
use syntax::ast::{self, Expr, MetaItem, GenericArg};
5+
use syntax::ast::{self, Ident, Expr, MetaItem, GenericArg};
66
use syntax::ext::base::{Annotatable, ExtCtxt, SpecialDerives};
77
use syntax::ptr::P;
88
use syntax::symbol::{sym, Symbol};
@@ -16,8 +16,8 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt<'_>,
1616
cx.resolver.add_derives(cx.current_expansion.id.expn_data().parent, SpecialDerives::EQ);
1717

1818
let inline = cx.meta_word(span, sym::inline);
19-
let hidden = cx.meta_list_item_word(span, sym::hidden);
20-
let doc = cx.meta_list(span, sym::doc, vec![hidden]);
19+
let hidden = syntax::attr::mk_nested_word_item(Ident::new(sym::hidden, span));
20+
let doc = syntax::attr::mk_list_item(Ident::new(sym::doc, span), vec![hidden]);
2121
let attrs = vec![cx.attribute(inline), cx.attribute(doc)];
2222
let trait_def = TraitDef {
2323
span,

src/libsyntax_ext/deriving/generic/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,11 @@ impl<'a> TraitDef<'a> {
672672
attr::mark_used(&attr);
673673
let opt_trait_ref = Some(trait_ref);
674674
let unused_qual = {
675-
let word = cx.meta_list_item_word(self.span, Symbol::intern("unused_qualifications"));
676-
cx.attribute(cx.meta_list(self.span, sym::allow, vec![word]))
675+
let word = syntax::attr::mk_nested_word_item(
676+
Ident::new(Symbol::intern("unused_qualifications"), self.span));
677+
let list = syntax::attr::mk_list_item(
678+
Ident::new(sym::allow, self.span), vec![word]);
679+
cx.attribute(list)
677680
};
678681

679682
let mut a = vec![attr, unused_qual];

src/libsyntax_ext/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ pub fn expand_test_or_bench(
145145
let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name, sp),
146146
vec![
147147
// #[cfg(test)]
148-
cx.attribute(cx.meta_list(attr_sp, sym::cfg, vec![
149-
cx.meta_list_item_word(attr_sp, sym::test)
148+
cx.attribute(attr::mk_list_item(ast::Ident::new(sym::cfg, attr_sp), vec![
149+
attr::mk_nested_word_item(ast::Ident::new(sym::test, attr_sp))
150150
])),
151151
// #[rustc_test_marker]
152152
cx.attribute(cx.meta_word(attr_sp, sym::rustc_test_marker)),

0 commit comments

Comments
 (0)