Remove Span argument from ExtCtxt::attribute
MetaItem.span was always equivalent
This commit is contained in:
parent
0a42badd4c
commit
b2c5065b04
14 changed files with 22 additions and 24 deletions
|
@ -929,7 +929,7 @@ pub fn find_transparency(
|
|||
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 { word: true, list: None, name_value_str: None };
|
||||
let attr = ecx.attribute(meta_item.span, meta_item.clone());
|
||||
let attr = ecx.attribute(meta_item.clone());
|
||||
check_builtin_attribute(ecx.parse_sess, &attr, name, template);
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ pub trait AstBuilder {
|
|||
generics: Generics) -> P<ast::Item>;
|
||||
fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> P<ast::Item>;
|
||||
|
||||
fn attribute(&self, sp: Span, mi: ast::MetaItem) -> ast::Attribute;
|
||||
fn attribute(&self, mi: ast::MetaItem) -> ast::Attribute;
|
||||
|
||||
fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem;
|
||||
|
||||
|
@ -1134,8 +1134,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
self.item_ty_poly(span, name, ty, Generics::default())
|
||||
}
|
||||
|
||||
fn attribute(&self, sp: Span, mi: ast::MetaItem) -> ast::Attribute {
|
||||
attr::mk_attr_outer(sp, mi)
|
||||
fn attribute(&self, mi: ast::MetaItem) -> ast::Attribute {
|
||||
attr::mk_attr_outer(mi.span, mi)
|
||||
}
|
||||
|
||||
fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem {
|
||||
|
|
|
@ -239,11 +239,11 @@ crate fn add_derived_markers<T: HasAttrs>(
|
|||
item.visit_attrs(|attrs| {
|
||||
if names.contains(&sym::Eq) && names.contains(&sym::PartialEq) {
|
||||
let meta = cx.meta_word(span, sym::structural_match);
|
||||
attrs.push(cx.attribute(span, meta));
|
||||
attrs.push(cx.attribute(meta));
|
||||
}
|
||||
if names.contains(&sym::Copy) {
|
||||
let meta = cx.meta_word(span, sym::rustc_copy_clone_marker);
|
||||
attrs.push(cx.attribute(span, meta));
|
||||
attrs.push(cx.attribute(meta));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt<'_>,
|
|||
}
|
||||
|
||||
let inline = cx.meta_word(span, sym::inline);
|
||||
let attrs = vec![cx.attribute(span, inline)];
|
||||
let attrs = vec![cx.attribute(inline)];
|
||||
let trait_def = TraitDef {
|
||||
span,
|
||||
attributes: Vec::new(),
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt<'_>,
|
|||
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 attrs = vec![cx.attribute(span, inline), cx.attribute(span, doc)];
|
||||
let attrs = vec![cx.attribute(inline), cx.attribute(doc)];
|
||||
let trait_def = TraitDef {
|
||||
span,
|
||||
attributes: Vec::new(),
|
||||
|
|
|
@ -15,7 +15,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt<'_>,
|
|||
item: &Annotatable,
|
||||
push: &mut dyn FnMut(Annotatable)) {
|
||||
let inline = cx.meta_word(span, sym::inline);
|
||||
let attrs = vec![cx.attribute(span, inline)];
|
||||
let attrs = vec![cx.attribute(inline)];
|
||||
let trait_def = TraitDef {
|
||||
span,
|
||||
attributes: Vec::new(),
|
||||
|
|
|
@ -63,7 +63,7 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt<'_>,
|
|||
macro_rules! md {
|
||||
($name:expr, $f:ident) => { {
|
||||
let inline = cx.meta_word(span, sym::inline);
|
||||
let attrs = vec![cx.attribute(span, inline)];
|
||||
let attrs = vec![cx.attribute(inline)];
|
||||
MethodDef {
|
||||
name: $name,
|
||||
generics: LifetimeBounds::empty(),
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt<'_>,
|
|||
macro_rules! md {
|
||||
($name:expr, $op:expr, $equal:expr) => { {
|
||||
let inline = cx.meta_word(span, sym::inline);
|
||||
let attrs = vec![cx.attribute(span, inline)];
|
||||
let attrs = vec![cx.attribute(inline)];
|
||||
MethodDef {
|
||||
name: $name,
|
||||
generics: LifetimeBounds::empty(),
|
||||
|
@ -43,7 +43,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt<'_>,
|
|||
PathKind::Std));
|
||||
|
||||
let inline = cx.meta_word(span, sym::inline);
|
||||
let attrs = vec![cx.attribute(span, inline)];
|
||||
let attrs = vec![cx.attribute(inline)];
|
||||
|
||||
let partial_cmp_def = MethodDef {
|
||||
name: "partial_cmp",
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt<'_>,
|
|||
item: &Annotatable,
|
||||
push: &mut dyn FnMut(Annotatable)) {
|
||||
let inline = cx.meta_word(span, sym::inline);
|
||||
let attrs = vec![cx.attribute(span, inline)];
|
||||
let attrs = vec![cx.attribute(inline)];
|
||||
let trait_def = TraitDef {
|
||||
span,
|
||||
attributes: Vec::new(),
|
||||
|
|
|
@ -666,14 +666,13 @@ impl<'a> TraitDef<'a> {
|
|||
let path = cx.path_all(self.span, false, vec![type_ident], self_params, vec![]);
|
||||
let self_type = cx.ty_path(path);
|
||||
|
||||
let attr = cx.attribute(self.span,
|
||||
cx.meta_word(self.span, sym::automatically_derived));
|
||||
let attr = cx.attribute(cx.meta_word(self.span, sym::automatically_derived));
|
||||
// Just mark it now since we know that it'll end up used downstream
|
||||
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(self.span, cx.meta_list(self.span, sym::allow, vec![word]))
|
||||
cx.attribute(cx.meta_list(self.span, sym::allow, vec![word]))
|
||||
};
|
||||
|
||||
let mut a = vec![attr, unused_qual];
|
||||
|
|
|
@ -110,7 +110,7 @@ impl AllocFnFactory<'_, '_> {
|
|||
fn attrs(&self) -> Vec<Attribute> {
|
||||
let special = sym::rustc_std_internal_symbol;
|
||||
let special = self.cx.meta_word(self.span, special);
|
||||
vec![self.cx.attribute(self.span, special)]
|
||||
vec![self.cx.attribute(special)]
|
||||
}
|
||||
|
||||
fn arg_ty(
|
||||
|
|
|
@ -337,7 +337,7 @@ fn mk_decls(
|
|||
|
||||
let hidden = cx.meta_list_item_word(span, sym::hidden);
|
||||
let doc = cx.meta_list(span, sym::doc, vec![hidden]);
|
||||
let doc_hidden = cx.attribute(span, doc);
|
||||
let doc_hidden = cx.attribute(doc);
|
||||
|
||||
let proc_macro = Ident::with_empty_ctxt(sym::proc_macro);
|
||||
let krate = cx.item(span,
|
||||
|
@ -394,7 +394,7 @@ fn mk_decls(
|
|||
cx.expr_vec_slice(span, decls),
|
||||
).map(|mut i| {
|
||||
let attr = cx.meta_word(span, sym::rustc_proc_macro_decls);
|
||||
i.attrs.push(cx.attribute(span, attr));
|
||||
i.attrs.push(cx.attribute(attr));
|
||||
i.vis = respan(span, ast::VisibilityKind::Public);
|
||||
i
|
||||
});
|
||||
|
|
|
@ -36,8 +36,7 @@ pub fn expand_test_case(
|
|||
item.vis = respan(item.vis.span, ast::VisibilityKind::Public);
|
||||
item.ident = item.ident.gensym();
|
||||
item.attrs.push(
|
||||
ecx.attribute(sp,
|
||||
ecx.meta_word(sp, sym::rustc_test_marker))
|
||||
ecx.attribute(ecx.meta_word(sp, sym::rustc_test_marker))
|
||||
);
|
||||
item
|
||||
});
|
||||
|
@ -150,11 +149,11 @@ pub fn expand_test_or_bench(
|
|||
let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name, sp).gensym(),
|
||||
vec![
|
||||
// #[cfg(test)]
|
||||
cx.attribute(attr_sp, cx.meta_list(attr_sp, sym::cfg, vec![
|
||||
cx.attribute(cx.meta_list(attr_sp, sym::cfg, vec![
|
||||
cx.meta_list_item_word(attr_sp, sym::test)
|
||||
])),
|
||||
// #[rustc_test_marker]
|
||||
cx.attribute(attr_sp, cx.meta_word(attr_sp, sym::rustc_test_marker)),
|
||||
cx.attribute(cx.meta_word(attr_sp, sym::rustc_test_marker)),
|
||||
],
|
||||
// const $ident: test::TestDescAndFn =
|
||||
ast::ItemKind::Const(cx.ty(sp, ast::TyKind::Path(None, test_path("TestDescAndFn"))),
|
||||
|
|
|
@ -294,7 +294,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
|
|||
|
||||
// #![main]
|
||||
let main_meta = ecx.meta_word(sp, sym::main);
|
||||
let main_attr = ecx.attribute(sp, main_meta);
|
||||
let main_attr = ecx.attribute(main_meta);
|
||||
|
||||
// extern crate test as test_gensym
|
||||
let test_extern_stmt = ecx.stmt_item(sp, ecx.item(sp,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue