Skip to content

Commit b2603d6

Browse files
authored
Rollup merge of rust-lang#63272 - Mark-Simulacrum:clean-attr, r=petrochenkov
Some more libsyntax::attr cleanup Much smaller patch than the last one, mostly just finishing up by removing some Span arguments. r? @petrochenkov
2 parents 61da2f4 + 8849149 commit b2603d6

File tree

7 files changed

+16
-20
lines changed

7 files changed

+16
-20
lines changed

src/librustc/hir/lowering.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -5176,11 +5176,10 @@ impl<'a> LoweringContext<'a> {
51765176
let attr = {
51775177
// `allow(unreachable_code)`
51785178
let allow = {
5179-
let allow_ident = Ident::with_empty_ctxt(sym::allow).with_span_pos(e.span);
5180-
let uc_ident = Ident::with_empty_ctxt(sym::unreachable_code)
5181-
.with_span_pos(e.span);
5179+
let allow_ident = Ident::new(sym::allow, e.span);
5180+
let uc_ident = Ident::new(sym::unreachable_code, e.span);
51825181
let uc_nested = attr::mk_nested_word_item(uc_ident);
5183-
attr::mk_list_item(e.span, allow_ident, vec![uc_nested])
5182+
attr::mk_list_item(allow_ident, vec![uc_nested])
51845183
};
51855184
attr::mk_attr_outer(allow)
51865185
};

src/librustdoc/clean/cfg/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ fn test_parse_ok() {
211211
fn test_parse_err() {
212212
with_default_globals(|| {
213213
let mi = attr::mk_name_value_item(
214-
DUMMY_SP,
215214
Ident::from_str("foo"),
216215
LitKind::Bool(false),
217216
DUMMY_SP,

src/libsyntax/attr/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -347,16 +347,17 @@ impl Attribute {
347347

348348
pub fn mk_name_value_item_str(ident: Ident, value: Spanned<Symbol>) -> MetaItem {
349349
let lit_kind = LitKind::Str(value.node, ast::StrStyle::Cooked);
350-
mk_name_value_item(ident.span.to(value.span), ident, lit_kind, value.span)
350+
mk_name_value_item(ident, lit_kind, value.span)
351351
}
352352

353-
pub fn mk_name_value_item(span: Span, ident: Ident, lit_kind: LitKind, lit_span: Span) -> MetaItem {
353+
pub fn mk_name_value_item(ident: Ident, lit_kind: LitKind, lit_span: Span) -> MetaItem {
354354
let lit = Lit::from_lit_kind(lit_kind, lit_span);
355+
let span = ident.span.to(lit_span);
355356
MetaItem { path: Path::from_ident(ident), span, node: MetaItemKind::NameValue(lit) }
356357
}
357358

358-
pub fn mk_list_item(span: Span, ident: Ident, items: Vec<NestedMetaItem>) -> MetaItem {
359-
MetaItem { path: Path::from_ident(ident), span, node: MetaItemKind::List(items) }
359+
pub fn mk_list_item(ident: Ident, items: Vec<NestedMetaItem>) -> MetaItem {
360+
MetaItem { path: Path::from_ident(ident), span: ident.span, node: MetaItemKind::List(items) }
360361
}
361362

362363
pub fn mk_word_item(ident: Ident) -> MetaItem {
@@ -367,7 +368,7 @@ pub fn mk_nested_word_item(ident: Ident) -> NestedMetaItem {
367368
NestedMetaItem::MetaItem(mk_word_item(ident))
368369
}
369370

370-
pub fn mk_attr_id() -> AttrId {
371+
crate fn mk_attr_id() -> AttrId {
371372
use std::sync::atomic::AtomicUsize;
372373
use std::sync::atomic::Ordering;
373374

src/libsyntax/ext/build.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -879,13 +879,12 @@ impl<'a> ExtCtxt<'a> {
879879

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

885885
pub fn meta_name_value(&self, span: Span, name: ast::Name, lit_kind: ast::LitKind)
886886
-> ast::MetaItem {
887-
attr::mk_name_value_item(span, Ident::new(name, span),
888-
lit_kind, span)
887+
attr::mk_name_value_item(Ident::new(name, span), lit_kind, span)
889888
}
890889

891890
pub fn item_use(&self, sp: Span,

src/libsyntax/ext/expand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
12721272
];
12731273

12741274
let include_ident = Ident::with_empty_ctxt(sym::include);
1275-
let item = attr::mk_list_item(DUMMY_SP, include_ident, include_info);
1275+
let item = attr::mk_list_item(include_ident, include_info);
12761276
items.push(ast::NestedMetaItem::MetaItem(item));
12771277
}
12781278
Err(e) => {
@@ -1333,7 +1333,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
13331333
}
13341334
}
13351335

1336-
let meta = attr::mk_list_item(DUMMY_SP, Ident::with_empty_ctxt(sym::doc), items);
1336+
let meta = attr::mk_list_item(Ident::with_empty_ctxt(sym::doc), items);
13371337
*at = attr::Attribute {
13381338
span: at.span,
13391339
id: at.id,

src/libsyntax/print/pprust.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::tokenstream::{self, TokenStream, TokenTree};
1515

1616
use rustc_target::spec::abi::{self, Abi};
1717
use syntax_pos::{self, BytePos};
18-
use syntax_pos::{DUMMY_SP, FileName, Span};
18+
use syntax_pos::{FileName, Span};
1919

2020
use std::borrow::Cow;
2121

@@ -124,8 +124,7 @@ pub fn print_crate<'a>(cm: &'a SourceMap,
124124

125125
// #![feature(prelude_import)]
126126
let pi_nested = attr::mk_nested_word_item(ast::Ident::with_empty_ctxt(sym::prelude_import));
127-
let list = attr::mk_list_item(
128-
DUMMY_SP, ast::Ident::with_empty_ctxt(sym::feature), vec![pi_nested]);
127+
let list = attr::mk_list_item(ast::Ident::with_empty_ctxt(sym::feature), vec![pi_nested]);
129128
let fake_attr = attr::mk_attr_inner(list);
130129
s.print_attribute(&fake_attr);
131130

src/libsyntax_ext/test_harness.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ impl MutVisitor for EntryPointCleaner {
157157
item.map(|ast::Item {id, ident, attrs, node, vis, span, tokens}| {
158158
let allow_ident = Ident::with_empty_ctxt(sym::allow);
159159
let dc_nested = attr::mk_nested_word_item(Ident::from_str("dead_code"));
160-
let allow_dead_code_item = attr::mk_list_item(DUMMY_SP, allow_ident,
161-
vec![dc_nested]);
160+
let allow_dead_code_item = attr::mk_list_item(allow_ident, vec![dc_nested]);
162161
let allow_dead_code = attr::mk_attr_outer(allow_dead_code_item);
163162

164163
ast::Item {

0 commit comments

Comments
 (0)