diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-07-30 13:50:22 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-07-31 08:55:37 -0400 |
| commit | 0a42badd4c9bfb6cb693f9a2105cc5b2cc674f63 (patch) | |
| tree | f95cbb26c336e447ebc9d9a24a70c8c76f0fb786 /src/libsyntax/attr | |
| parent | 804f0f3c20455bd8a34a903bcf9449297c3de88c (diff) | |
| download | rust-0a42badd4c9bfb6cb693f9a2105cc5b2cc674f63.tar.gz rust-0a42badd4c9bfb6cb693f9a2105cc5b2cc674f63.zip | |
Remove AttrId from Attribute constructors
Diffstat (limited to 'src/libsyntax/attr')
| -rw-r--r-- | src/libsyntax/attr/mod.rs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index ec26ea8d543..11c1b1c56c7 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -6,9 +6,10 @@ pub use builtin::*; pub use IntType::*; pub use ReprAttr::*; pub use StabilityLevel::*; +pub use crate::ast::Attribute; use crate::ast; -use crate::ast::{AttrId, Attribute, AttrStyle, Name, Ident, Path, PathSegment}; +use crate::ast::{AttrId, AttrStyle, Name, Ident, Path, PathSegment}; use crate::ast::{MetaItem, MetaItemKind, NestedMetaItem}; use crate::ast::{Lit, LitKind, Expr, Item, Local, Stmt, StmtKind, GenericParam}; use crate::mut_visit::visit_clobber; @@ -328,13 +329,14 @@ impl Attribute { let meta = mk_name_value_item_str( Ident::with_empty_ctxt(sym::doc), dummy_spanned(Symbol::intern(&strip_doc_comment_decoration(&comment.as_str())))); - let mut attr = if self.style == ast::AttrStyle::Outer { - mk_attr_outer(self.span, self.id, meta) - } else { - mk_attr_inner(self.span, self.id, meta) - }; - attr.is_sugared_doc = true; - f(&attr) + f(&Attribute { + id: self.id, + style: self.style, + path: meta.path, + tokens: meta.node.tokens(meta.span), + is_sugared_doc: true, + span: self.span, + }) } else { f(self) } @@ -377,9 +379,9 @@ pub fn mk_attr_id() -> AttrId { } /// Returns an inner attribute with the given value and span. -pub fn mk_attr_inner(span: Span, id: AttrId, item: MetaItem) -> Attribute { +pub fn mk_attr_inner(span: Span, item: MetaItem) -> Attribute { Attribute { - id, + id: mk_attr_id(), style: ast::AttrStyle::Inner, path: item.path, tokens: item.node.tokens(item.span), @@ -389,9 +391,9 @@ pub fn mk_attr_inner(span: Span, id: AttrId, item: MetaItem) -> Attribute { } /// Returns an outer attribute with the given value and span. -pub fn mk_attr_outer(span: Span, id: AttrId, item: MetaItem) -> Attribute { +pub fn mk_attr_outer(span: Span, item: MetaItem) -> Attribute { Attribute { - id, + id: mk_attr_id(), style: ast::AttrStyle::Outer, path: item.path, tokens: item.node.tokens(item.span), @@ -400,12 +402,12 @@ pub fn mk_attr_outer(span: Span, id: AttrId, item: MetaItem) -> Attribute { } } -pub fn mk_sugared_doc_attr(id: AttrId, text: Symbol, span: Span) -> Attribute { +pub fn mk_sugared_doc_attr(text: Symbol, span: Span) -> Attribute { let style = doc_comment_style(&text.as_str()); let lit_kind = LitKind::Str(text, ast::StrStyle::Cooked); let lit = Lit::from_lit_kind(lit_kind, span); Attribute { - id, + id: mk_attr_id(), style, path: Path::from_ident(Ident::with_empty_ctxt(sym::doc).with_span_pos(span)), tokens: MetaItemKind::NameValue(lit).tokens(span), |
