@@ -6,9 +6,10 @@ pub use builtin::*;
66pub use IntType :: * ;
77pub use ReprAttr :: * ;
88pub use StabilityLevel :: * ;
9+ pub use crate :: ast:: Attribute ;
910
1011use crate :: ast;
11- use crate :: ast:: { AttrId , Attribute , AttrStyle , Name , Ident , Path , PathSegment } ;
12+ use crate :: ast:: { AttrId , AttrStyle , Name , Ident , Path , PathSegment } ;
1213use crate :: ast:: { MetaItem , MetaItemKind , NestedMetaItem } ;
1314use crate :: ast:: { Lit , LitKind , Expr , Item , Local , Stmt , StmtKind , GenericParam } ;
1415use crate :: mut_visit:: visit_clobber;
@@ -328,13 +329,14 @@ impl Attribute {
328329 let meta = mk_name_value_item_str (
329330 Ident :: with_empty_ctxt ( sym:: doc) ,
330331 dummy_spanned ( Symbol :: intern ( & strip_doc_comment_decoration ( & comment. as_str ( ) ) ) ) ) ;
331- let mut attr = if self . style == ast:: AttrStyle :: Outer {
332- mk_attr_outer ( self . span , self . id , meta)
333- } else {
334- mk_attr_inner ( self . span , self . id , meta)
335- } ;
336- attr. is_sugared_doc = true ;
337- f ( & attr)
332+ f ( & Attribute {
333+ id : self . id ,
334+ style : self . style ,
335+ path : meta. path ,
336+ tokens : meta. node . tokens ( meta. span ) ,
337+ is_sugared_doc : true ,
338+ span : self . span ,
339+ } )
338340 } else {
339341 f ( self )
340342 }
@@ -377,9 +379,9 @@ pub fn mk_attr_id() -> AttrId {
377379}
378380
379381/// Returns an inner attribute with the given value and span.
380- pub fn mk_attr_inner ( span : Span , id : AttrId , item : MetaItem ) -> Attribute {
382+ pub fn mk_attr_inner ( span : Span , item : MetaItem ) -> Attribute {
381383 Attribute {
382- id,
384+ id : mk_attr_id ( ) ,
383385 style : ast:: AttrStyle :: Inner ,
384386 path : item. path ,
385387 tokens : item. node . tokens ( item. span ) ,
@@ -389,9 +391,9 @@ pub fn mk_attr_inner(span: Span, id: AttrId, item: MetaItem) -> Attribute {
389391}
390392
391393/// Returns an outer attribute with the given value and span.
392- pub fn mk_attr_outer ( span : Span , id : AttrId , item : MetaItem ) -> Attribute {
394+ pub fn mk_attr_outer ( span : Span , item : MetaItem ) -> Attribute {
393395 Attribute {
394- id,
396+ id : mk_attr_id ( ) ,
395397 style : ast:: AttrStyle :: Outer ,
396398 path : item. path ,
397399 tokens : item. node . tokens ( item. span ) ,
@@ -400,12 +402,12 @@ pub fn mk_attr_outer(span: Span, id: AttrId, item: MetaItem) -> Attribute {
400402 }
401403}
402404
403- pub fn mk_sugared_doc_attr ( id : AttrId , text : Symbol , span : Span ) -> Attribute {
405+ pub fn mk_sugared_doc_attr ( text : Symbol , span : Span ) -> Attribute {
404406 let style = doc_comment_style ( & text. as_str ( ) ) ;
405407 let lit_kind = LitKind :: Str ( text, ast:: StrStyle :: Cooked ) ;
406408 let lit = Lit :: from_lit_kind ( lit_kind, span) ;
407409 Attribute {
408- id,
410+ id : mk_attr_id ( ) ,
409411 style,
410412 path : Path :: from_ident ( Ident :: with_empty_ctxt ( sym:: doc) . with_span_pos ( span) ) ,
411413 tokens : MetaItemKind :: NameValue ( lit) . tokens ( span) ,
0 commit comments