Skip to content

Commit c9bd4a0

Browse files
Replace a few Attribute constructors with mk_attr
1 parent f78bf50 commit c9bd4a0

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6396,15 +6396,8 @@ impl<'a> Parser<'a> {
63966396
self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)?;
63976397
// Record that we fetched the mod from an external file
63986398
if warn {
6399-
let attr = Attribute {
6400-
id: attr::mk_attr_id(),
6401-
style: ast::AttrStyle::Outer,
6402-
path: ast::Path::from_ident(
6403-
Ident::with_empty_ctxt(sym::warn_directory_ownership)),
6404-
tokens: TokenStream::empty(),
6405-
is_sugared_doc: false,
6406-
span: DUMMY_SP,
6407-
};
6399+
let attr = attr::mk_attr_outer(
6400+
attr::mk_word_item(Ident::with_empty_ctxt(sym::warn_directory_ownership)));
64086401
attr::mark_known(&attr);
64096402
attrs.push(attr);
64106403
}

src/libsyntax_ext/plugin_macro_defs.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,8 @@ use syntax_pos::hygiene::{ExpnId, ExpnInfo, ExpnKind, MacroKind};
1616
use std::mem;
1717

1818
fn plugin_macro_def(name: Name, span: Span) -> P<Item> {
19-
let rustc_builtin_macro = Attribute {
20-
id: attr::mk_attr_id(),
21-
style: AttrStyle::Outer,
22-
path: Path::from_ident(Ident::new(sym::rustc_builtin_macro, span)),
23-
tokens: TokenStream::empty(),
24-
is_sugared_doc: false,
25-
span,
26-
};
19+
let rustc_builtin_macro = attr::mk_attr_outer(
20+
attr::mk_word_item(Ident::new(sym::rustc_builtin_macro, span)));
2721

2822
let parens: TreeAndJoint = TokenTree::Delimited(
2923
DelimSpan::from_single(span), token::Paren, TokenStream::empty()

src/libsyntax_ext/standard_library_imports.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use syntax::ext::hygiene::{ExpnId, MacroKind};
44
use syntax::ptr::P;
55
use syntax::source_map::{ExpnInfo, ExpnKind, dummy_spanned, respan};
66
use syntax::symbol::{Ident, Symbol, kw, sym};
7-
use syntax::tokenstream::TokenStream;
87
use syntax_pos::DUMMY_SP;
98

109
use std::iter;
@@ -62,14 +61,8 @@ pub fn inject(
6261
));
6362

6463
krate.module.items.insert(0, P(ast::Item {
65-
attrs: vec![ast::Attribute {
66-
style: ast::AttrStyle::Outer,
67-
path: ast::Path::from_ident(ast::Ident::new(sym::prelude_import, span)),
68-
tokens: TokenStream::empty(),
69-
id: attr::mk_attr_id(),
70-
is_sugared_doc: false,
71-
span,
72-
}],
64+
attrs: vec![attr::mk_attr_outer(
65+
attr::mk_word_item(ast::Ident::new(sym::prelude_import, span)))],
7366
vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited),
7467
node: ast::ItemKind::Use(P(ast::UseTree {
7568
prefix: ast::Path {

0 commit comments

Comments
 (0)