Inline attribute constructors
This commit is contained in:
parent
e41aa8c0d0
commit
8417ac67c3
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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};
|
||||
@ -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,
|
||||
|
@ -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];
|
||||
|
@ -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)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user