Skip to content

Commit b2c5065

Browse files
Remove Span argument from ExtCtxt::attribute
MetaItem.span was always equivalent
1 parent 0a42bad commit b2c5065

File tree

14 files changed

+22
-24
lines changed

14 files changed

+22
-24
lines changed

src/libsyntax/attr/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ pub fn find_transparency(
929929
pub fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaItem, name: Symbol) {
930930
// All the built-in macro attributes are "words" at the moment.
931931
let template = AttributeTemplate { word: true, list: None, name_value_str: None };
932-
let attr = ecx.attribute(meta_item.span, meta_item.clone());
932+
let attr = ecx.attribute(meta_item.clone());
933933
check_builtin_attribute(ecx.parse_sess, &attr, name, template);
934934
}
935935

src/libsyntax/ext/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ pub trait AstBuilder {
259259
generics: Generics) -> P<ast::Item>;
260260
fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> P<ast::Item>;
261261

262-
fn attribute(&self, sp: Span, mi: ast::MetaItem) -> ast::Attribute;
262+
fn attribute(&self, mi: ast::MetaItem) -> ast::Attribute;
263263

264264
fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem;
265265

@@ -1134,8 +1134,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
11341134
self.item_ty_poly(span, name, ty, Generics::default())
11351135
}
11361136

1137-
fn attribute(&self, sp: Span, mi: ast::MetaItem) -> ast::Attribute {
1138-
attr::mk_attr_outer(sp, mi)
1137+
fn attribute(&self, mi: ast::MetaItem) -> ast::Attribute {
1138+
attr::mk_attr_outer(mi.span, mi)
11391139
}
11401140

11411141
fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem {

src/libsyntax/ext/proc_macro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,11 @@ crate fn add_derived_markers<T: HasAttrs>(
239239
item.visit_attrs(|attrs| {
240240
if names.contains(&sym::Eq) && names.contains(&sym::PartialEq) {
241241
let meta = cx.meta_word(span, sym::structural_match);
242-
attrs.push(cx.attribute(span, meta));
242+
attrs.push(cx.attribute(meta));
243243
}
244244
if names.contains(&sym::Copy) {
245245
let meta = cx.meta_word(span, sym::rustc_copy_clone_marker);
246-
attrs.push(cx.attribute(span, meta));
246+
attrs.push(cx.attribute(meta));
247247
}
248248
});
249249
}

src/libsyntax_ext/deriving/clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt<'_>,
7777
}
7878

7979
let inline = cx.meta_word(span, sym::inline);
80-
let attrs = vec![cx.attribute(span, inline)];
80+
let attrs = vec![cx.attribute(inline)];
8181
let trait_def = TraitDef {
8282
span,
8383
attributes: Vec::new(),

src/libsyntax_ext/deriving/cmp/eq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt<'_>,
1717
let inline = cx.meta_word(span, sym::inline);
1818
let hidden = cx.meta_list_item_word(span, sym::hidden);
1919
let doc = cx.meta_list(span, sym::doc, vec![hidden]);
20-
let attrs = vec![cx.attribute(span, inline), cx.attribute(span, doc)];
20+
let attrs = vec![cx.attribute(inline), cx.attribute(doc)];
2121
let trait_def = TraitDef {
2222
span,
2323
attributes: Vec::new(),

src/libsyntax_ext/deriving/cmp/ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt<'_>,
1515
item: &Annotatable,
1616
push: &mut dyn FnMut(Annotatable)) {
1717
let inline = cx.meta_word(span, sym::inline);
18-
let attrs = vec![cx.attribute(span, inline)];
18+
let attrs = vec![cx.attribute(inline)];
1919
let trait_def = TraitDef {
2020
span,
2121
attributes: Vec::new(),

src/libsyntax_ext/deriving/cmp/partial_eq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt<'_>,
6363
macro_rules! md {
6464
($name:expr, $f:ident) => { {
6565
let inline = cx.meta_word(span, sym::inline);
66-
let attrs = vec![cx.attribute(span, inline)];
66+
let attrs = vec![cx.attribute(inline)];
6767
MethodDef {
6868
name: $name,
6969
generics: LifetimeBounds::empty(),

src/libsyntax_ext/deriving/cmp/partial_ord.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt<'_>,
1919
macro_rules! md {
2020
($name:expr, $op:expr, $equal:expr) => { {
2121
let inline = cx.meta_word(span, sym::inline);
22-
let attrs = vec![cx.attribute(span, inline)];
22+
let attrs = vec![cx.attribute(inline)];
2323
MethodDef {
2424
name: $name,
2525
generics: LifetimeBounds::empty(),
@@ -43,7 +43,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt<'_>,
4343
PathKind::Std));
4444

4545
let inline = cx.meta_word(span, sym::inline);
46-
let attrs = vec![cx.attribute(span, inline)];
46+
let attrs = vec![cx.attribute(inline)];
4747

4848
let partial_cmp_def = MethodDef {
4949
name: "partial_cmp",

src/libsyntax_ext/deriving/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt<'_>,
1616
item: &Annotatable,
1717
push: &mut dyn FnMut(Annotatable)) {
1818
let inline = cx.meta_word(span, sym::inline);
19-
let attrs = vec![cx.attribute(span, inline)];
19+
let attrs = vec![cx.attribute(inline)];
2020
let trait_def = TraitDef {
2121
span,
2222
attributes: Vec::new(),

src/libsyntax_ext/deriving/generic/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,14 +666,13 @@ impl<'a> TraitDef<'a> {
666666
let path = cx.path_all(self.span, false, vec![type_ident], self_params, vec![]);
667667
let self_type = cx.ty_path(path);
668668

669-
let attr = cx.attribute(self.span,
670-
cx.meta_word(self.span, sym::automatically_derived));
669+
let attr = cx.attribute(cx.meta_word(self.span, sym::automatically_derived));
671670
// Just mark it now since we know that it'll end up used downstream
672671
attr::mark_used(&attr);
673672
let opt_trait_ref = Some(trait_ref);
674673
let unused_qual = {
675674
let word = cx.meta_list_item_word(self.span, Symbol::intern("unused_qualifications"));
676-
cx.attribute(self.span, cx.meta_list(self.span, sym::allow, vec![word]))
675+
cx.attribute(cx.meta_list(self.span, sym::allow, vec![word]))
677676
};
678677

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

src/libsyntax_ext/global_allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl AllocFnFactory<'_, '_> {
110110
fn attrs(&self) -> Vec<Attribute> {
111111
let special = sym::rustc_std_internal_symbol;
112112
let special = self.cx.meta_word(self.span, special);
113-
vec![self.cx.attribute(self.span, special)]
113+
vec![self.cx.attribute(special)]
114114
}
115115

116116
fn arg_ty(

src/libsyntax_ext/proc_macro_harness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ fn mk_decls(
337337

338338
let hidden = cx.meta_list_item_word(span, sym::hidden);
339339
let doc = cx.meta_list(span, sym::doc, vec![hidden]);
340-
let doc_hidden = cx.attribute(span, doc);
340+
let doc_hidden = cx.attribute(doc);
341341

342342
let proc_macro = Ident::with_empty_ctxt(sym::proc_macro);
343343
let krate = cx.item(span,
@@ -394,7 +394,7 @@ fn mk_decls(
394394
cx.expr_vec_slice(span, decls),
395395
).map(|mut i| {
396396
let attr = cx.meta_word(span, sym::rustc_proc_macro_decls);
397-
i.attrs.push(cx.attribute(span, attr));
397+
i.attrs.push(cx.attribute(attr));
398398
i.vis = respan(span, ast::VisibilityKind::Public);
399399
i
400400
});

src/libsyntax_ext/test.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ pub fn expand_test_case(
3636
item.vis = respan(item.vis.span, ast::VisibilityKind::Public);
3737
item.ident = item.ident.gensym();
3838
item.attrs.push(
39-
ecx.attribute(sp,
40-
ecx.meta_word(sp, sym::rustc_test_marker))
39+
ecx.attribute(ecx.meta_word(sp, sym::rustc_test_marker))
4140
);
4241
item
4342
});
@@ -150,11 +149,11 @@ pub fn expand_test_or_bench(
150149
let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name, sp).gensym(),
151150
vec![
152151
// #[cfg(test)]
153-
cx.attribute(attr_sp, cx.meta_list(attr_sp, sym::cfg, vec![
152+
cx.attribute(cx.meta_list(attr_sp, sym::cfg, vec![
154153
cx.meta_list_item_word(attr_sp, sym::test)
155154
])),
156155
// #[rustc_test_marker]
157-
cx.attribute(attr_sp, cx.meta_word(attr_sp, sym::rustc_test_marker)),
156+
cx.attribute(cx.meta_word(attr_sp, sym::rustc_test_marker)),
158157
],
159158
// const $ident: test::TestDescAndFn =
160159
ast::ItemKind::Const(cx.ty(sp, ast::TyKind::Path(None, test_path("TestDescAndFn"))),

src/libsyntax_ext/test_harness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
294294

295295
// #![main]
296296
let main_meta = ecx.meta_word(sp, sym::main);
297-
let main_attr = ecx.attribute(sp, main_meta);
297+
let main_attr = ecx.attribute(main_meta);
298298

299299
// extern crate test as test_gensym
300300
let test_extern_stmt = ecx.stmt_item(sp, ecx.item(sp,

0 commit comments

Comments
 (0)