Rollup merge of #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
This commit is contained in:
commit
b2603d6386
@ -5176,11 +5176,10 @@ impl<'a> LoweringContext<'a> {
|
||||
let attr = {
|
||||
// `allow(unreachable_code)`
|
||||
let allow = {
|
||||
let allow_ident = Ident::with_empty_ctxt(sym::allow).with_span_pos(e.span);
|
||||
let uc_ident = Ident::with_empty_ctxt(sym::unreachable_code)
|
||||
.with_span_pos(e.span);
|
||||
let allow_ident = Ident::new(sym::allow, e.span);
|
||||
let uc_ident = Ident::new(sym::unreachable_code, e.span);
|
||||
let uc_nested = attr::mk_nested_word_item(uc_ident);
|
||||
attr::mk_list_item(e.span, allow_ident, vec![uc_nested])
|
||||
attr::mk_list_item(allow_ident, vec![uc_nested])
|
||||
};
|
||||
attr::mk_attr_outer(allow)
|
||||
};
|
||||
|
@ -211,7 +211,6 @@ fn test_parse_ok() {
|
||||
fn test_parse_err() {
|
||||
with_default_globals(|| {
|
||||
let mi = attr::mk_name_value_item(
|
||||
DUMMY_SP,
|
||||
Ident::from_str("foo"),
|
||||
LitKind::Bool(false),
|
||||
DUMMY_SP,
|
||||
|
@ -347,16 +347,17 @@ impl Attribute {
|
||||
|
||||
pub fn mk_name_value_item_str(ident: Ident, value: Spanned<Symbol>) -> MetaItem {
|
||||
let lit_kind = LitKind::Str(value.node, ast::StrStyle::Cooked);
|
||||
mk_name_value_item(ident.span.to(value.span), ident, lit_kind, value.span)
|
||||
mk_name_value_item(ident, lit_kind, value.span)
|
||||
}
|
||||
|
||||
pub fn mk_name_value_item(span: Span, ident: Ident, lit_kind: LitKind, lit_span: Span) -> MetaItem {
|
||||
pub fn mk_name_value_item(ident: Ident, lit_kind: LitKind, lit_span: Span) -> MetaItem {
|
||||
let lit = Lit::from_lit_kind(lit_kind, lit_span);
|
||||
let span = ident.span.to(lit_span);
|
||||
MetaItem { path: Path::from_ident(ident), span, node: MetaItemKind::NameValue(lit) }
|
||||
}
|
||||
|
||||
pub fn mk_list_item(span: Span, ident: Ident, items: Vec<NestedMetaItem>) -> MetaItem {
|
||||
MetaItem { path: Path::from_ident(ident), span, node: MetaItemKind::List(items) }
|
||||
pub fn mk_list_item(ident: Ident, items: Vec<NestedMetaItem>) -> MetaItem {
|
||||
MetaItem { path: Path::from_ident(ident), span: ident.span, node: MetaItemKind::List(items) }
|
||||
}
|
||||
|
||||
pub fn mk_word_item(ident: Ident) -> MetaItem {
|
||||
@ -367,7 +368,7 @@ pub fn mk_nested_word_item(ident: Ident) -> NestedMetaItem {
|
||||
NestedMetaItem::MetaItem(mk_word_item(ident))
|
||||
}
|
||||
|
||||
pub fn mk_attr_id() -> AttrId {
|
||||
crate fn mk_attr_id() -> AttrId {
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
|
@ -879,13 +879,12 @@ impl<'a> ExtCtxt<'a> {
|
||||
|
||||
pub fn meta_list(&self, sp: Span, name: ast::Name, mis: Vec<ast::NestedMetaItem>)
|
||||
-> ast::MetaItem {
|
||||
attr::mk_list_item(sp, Ident::new(name, sp), mis)
|
||||
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(span, Ident::new(name, span),
|
||||
lit_kind, span)
|
||||
attr::mk_name_value_item(Ident::new(name, span), lit_kind, span)
|
||||
}
|
||||
|
||||
pub fn item_use(&self, sp: Span,
|
||||
|
@ -1272,7 +1272,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
||||
];
|
||||
|
||||
let include_ident = Ident::with_empty_ctxt(sym::include);
|
||||
let item = attr::mk_list_item(DUMMY_SP, include_ident, include_info);
|
||||
let item = attr::mk_list_item(include_ident, include_info);
|
||||
items.push(ast::NestedMetaItem::MetaItem(item));
|
||||
}
|
||||
Err(e) => {
|
||||
@ -1333,7 +1333,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
let meta = attr::mk_list_item(DUMMY_SP, Ident::with_empty_ctxt(sym::doc), items);
|
||||
let meta = attr::mk_list_item(Ident::with_empty_ctxt(sym::doc), items);
|
||||
*at = attr::Attribute {
|
||||
span: at.span,
|
||||
id: at.id,
|
||||
|
@ -15,7 +15,7 @@ use crate::tokenstream::{self, TokenStream, TokenTree};
|
||||
|
||||
use rustc_target::spec::abi::{self, Abi};
|
||||
use syntax_pos::{self, BytePos};
|
||||
use syntax_pos::{DUMMY_SP, FileName, Span};
|
||||
use syntax_pos::{FileName, Span};
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
@ -124,8 +124,7 @@ pub fn print_crate<'a>(cm: &'a SourceMap,
|
||||
|
||||
// #![feature(prelude_import)]
|
||||
let pi_nested = attr::mk_nested_word_item(ast::Ident::with_empty_ctxt(sym::prelude_import));
|
||||
let list = attr::mk_list_item(
|
||||
DUMMY_SP, ast::Ident::with_empty_ctxt(sym::feature), vec![pi_nested]);
|
||||
let list = attr::mk_list_item(ast::Ident::with_empty_ctxt(sym::feature), vec![pi_nested]);
|
||||
let fake_attr = attr::mk_attr_inner(list);
|
||||
s.print_attribute(&fake_attr);
|
||||
|
||||
|
@ -157,8 +157,7 @@ impl MutVisitor for EntryPointCleaner {
|
||||
item.map(|ast::Item {id, ident, attrs, node, vis, span, tokens}| {
|
||||
let allow_ident = Ident::with_empty_ctxt(sym::allow);
|
||||
let dc_nested = attr::mk_nested_word_item(Ident::from_str("dead_code"));
|
||||
let allow_dead_code_item = attr::mk_list_item(DUMMY_SP, allow_ident,
|
||||
vec![dc_nested]);
|
||||
let allow_dead_code_item = attr::mk_list_item(allow_ident, vec![dc_nested]);
|
||||
let allow_dead_code = attr::mk_attr_outer(allow_dead_code_item);
|
||||
|
||||
ast::Item {
|
||||
|
Loading…
x
Reference in New Issue
Block a user