Skip to content

Commit

Permalink
Inline attribute constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Sep 21, 2019
1 parent e41aa8c commit 8417ac6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
14 changes: 0 additions & 14 deletions src/libsyntax/ext/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,18 +640,4 @@ impl<'a> ExtCtxt<'a> {
pub fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem {
attr::mk_word_item(Ident::new(w, sp))
}

pub fn meta_list_item_word(&self, sp: Span, w: ast::Name) -> ast::NestedMetaItem {
attr::mk_nested_word_item(Ident::new(w, sp))
}

pub fn meta_list(&self, sp: Span, name: ast::Name, mis: Vec<ast::NestedMetaItem>)
-> ast::MetaItem {
attr::mk_list_item(Ident::new(name, sp), mis)
}

pub fn meta_name_value(&self, span: Span, name: ast::Name, lit_kind: ast::LitKind)
-> ast::MetaItem {
attr::mk_name_value_item(Ident::new(name, span), lit_kind, span)
}
}
6 changes: 3 additions & 3 deletions src/libsyntax_ext/deriving/cmp/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::deriving::path_std;
use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;

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

let inline = cx.meta_word(span, sym::inline);
let hidden = cx.meta_list_item_word(span, sym::hidden);
let doc = cx.meta_list(span, sym::doc, vec![hidden]);
let hidden = syntax::attr::mk_nested_word_item(Ident::new(sym::hidden, span));
let doc = syntax::attr::mk_list_item(Ident::new(sym::doc, span), vec![hidden]);
let attrs = vec![cx.attribute(inline), cx.attribute(doc)];
let trait_def = TraitDef {
span,
Expand Down
7 changes: 5 additions & 2 deletions src/libsyntax_ext/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,11 @@ impl<'a> TraitDef<'a> {
attr::mark_used(&attr);
let opt_trait_ref = Some(trait_ref);
let unused_qual = {
let word = cx.meta_list_item_word(self.span, Symbol::intern("unused_qualifications"));
cx.attribute(cx.meta_list(self.span, sym::allow, vec![word]))
let word = syntax::attr::mk_nested_word_item(
Ident::new(Symbol::intern("unused_qualifications"), self.span));
let list = syntax::attr::mk_list_item(
Ident::new(sym::allow, self.span), vec![word]);
cx.attribute(list)
};

let mut a = vec![attr, unused_qual];
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax_ext/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ pub fn expand_test_or_bench(
let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name, sp),
vec![
// #[cfg(test)]
cx.attribute(cx.meta_list(attr_sp, sym::cfg, vec![
cx.meta_list_item_word(attr_sp, sym::test)
cx.attribute(attr::mk_list_item(ast::Ident::new(sym::cfg, attr_sp), vec![
attr::mk_nested_word_item(ast::Ident::new(sym::test, attr_sp))
])),
// #[rustc_test_marker]
cx.attribute(cx.meta_word(attr_sp, sym::rustc_test_marker)),
Expand Down

0 comments on commit 8417ac6

Please sign in to comment.