@@ -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 }
@@ -376,46 +378,36 @@ pub fn mk_attr_id() -> AttrId {
376378 AttrId ( id)
377379}
378380
379- /// Returns an inner attribute with the given value.
380- pub fn mk_attr_inner ( span : Span , id : AttrId , item : MetaItem ) -> Attribute {
381- mk_spanned_attr_inner ( span, id, item)
382- }
383-
384381/// Returns an inner attribute with the given value and span.
385- pub fn mk_spanned_attr_inner ( sp : Span , id : AttrId , item : MetaItem ) -> Attribute {
382+ pub fn mk_attr_inner ( item : MetaItem ) -> Attribute {
386383 Attribute {
387- id,
384+ id : mk_attr_id ( ) ,
388385 style : ast:: AttrStyle :: Inner ,
389386 path : item. path ,
390387 tokens : item. node . tokens ( item. span ) ,
391388 is_sugared_doc : false ,
392- span : sp ,
389+ span : item . span ,
393390 }
394391}
395392
396- /// Returns an outer attribute with the given value.
397- pub fn mk_attr_outer ( span : Span , id : AttrId , item : MetaItem ) -> Attribute {
398- mk_spanned_attr_outer ( span, id, item)
399- }
400-
401393/// Returns an outer attribute with the given value and span.
402- pub fn mk_spanned_attr_outer ( sp : Span , id : AttrId , item : MetaItem ) -> Attribute {
394+ pub fn mk_attr_outer ( item : MetaItem ) -> Attribute {
403395 Attribute {
404- id,
396+ id : mk_attr_id ( ) ,
405397 style : ast:: AttrStyle :: Outer ,
406398 path : item. path ,
407399 tokens : item. node . tokens ( item. span ) ,
408400 is_sugared_doc : false ,
409- span : sp ,
401+ span : item . span ,
410402 }
411403}
412404
413- 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 {
414406 let style = doc_comment_style ( & text. as_str ( ) ) ;
415407 let lit_kind = LitKind :: Str ( text, ast:: StrStyle :: Cooked ) ;
416408 let lit = Lit :: from_lit_kind ( lit_kind, span) ;
417409 Attribute {
418- id,
410+ id : mk_attr_id ( ) ,
419411 style,
420412 path : Path :: from_ident ( Ident :: with_empty_ctxt ( sym:: doc) . with_span_pos ( span) ) ,
421413 tokens : MetaItemKind :: NameValue ( lit) . tokens ( span) ,
0 commit comments