@@ -6,9 +6,10 @@ pub use builtin::*;
6
6
pub use IntType :: * ;
7
7
pub use ReprAttr :: * ;
8
8
pub use StabilityLevel :: * ;
9
+ pub use crate :: ast:: Attribute ;
9
10
10
11
use crate :: ast;
11
- use crate :: ast:: { AttrId , Attribute , AttrStyle , Name , Ident , Path , PathSegment } ;
12
+ use crate :: ast:: { AttrId , AttrStyle , Name , Ident , Path , PathSegment } ;
12
13
use crate :: ast:: { MetaItem , MetaItemKind , NestedMetaItem } ;
13
14
use crate :: ast:: { Lit , LitKind , Expr , Item , Local , Stmt , StmtKind , GenericParam } ;
14
15
use crate :: mut_visit:: visit_clobber;
@@ -328,13 +329,14 @@ impl Attribute {
328
329
let meta = mk_name_value_item_str (
329
330
Ident :: with_empty_ctxt ( sym:: doc) ,
330
331
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
+ } )
338
340
} else {
339
341
f ( self )
340
342
}
@@ -377,9 +379,9 @@ pub fn mk_attr_id() -> AttrId {
377
379
}
378
380
379
381
/// 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 {
381
383
Attribute {
382
- id,
384
+ id : mk_attr_id ( ) ,
383
385
style : ast:: AttrStyle :: Inner ,
384
386
path : item. path ,
385
387
tokens : item. node . tokens ( item. span ) ,
@@ -389,9 +391,9 @@ pub fn mk_attr_inner(span: Span, id: AttrId, item: MetaItem) -> Attribute {
389
391
}
390
392
391
393
/// 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 {
393
395
Attribute {
394
- id,
396
+ id : mk_attr_id ( ) ,
395
397
style : ast:: AttrStyle :: Outer ,
396
398
path : item. path ,
397
399
tokens : item. node . tokens ( item. span ) ,
@@ -400,12 +402,12 @@ pub fn mk_attr_outer(span: Span, id: AttrId, item: MetaItem) -> Attribute {
400
402
}
401
403
}
402
404
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 {
404
406
let style = doc_comment_style ( & text. as_str ( ) ) ;
405
407
let lit_kind = LitKind :: Str ( text, ast:: StrStyle :: Cooked ) ;
406
408
let lit = Lit :: from_lit_kind ( lit_kind, span) ;
407
409
Attribute {
408
- id,
410
+ id : mk_attr_id ( ) ,
409
411
style,
410
412
path : Path :: from_ident ( Ident :: with_empty_ctxt ( sym:: doc) . with_span_pos ( span) ) ,
411
413
tokens : MetaItemKind :: NameValue ( lit) . tokens ( span) ,
0 commit comments