@@ -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
}
@@ -376,46 +378,36 @@ pub fn mk_attr_id() -> AttrId {
376
378
AttrId ( id)
377
379
}
378
380
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
-
384
381
/// 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 {
386
383
Attribute {
387
- id,
384
+ id : mk_attr_id ( ) ,
388
385
style : ast:: AttrStyle :: Inner ,
389
386
path : item. path ,
390
387
tokens : item. node . tokens ( item. span ) ,
391
388
is_sugared_doc : false ,
392
- span : sp ,
389
+ span : item . span ,
393
390
}
394
391
}
395
392
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
-
401
393
/// 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 {
403
395
Attribute {
404
- id,
396
+ id : mk_attr_id ( ) ,
405
397
style : ast:: AttrStyle :: Outer ,
406
398
path : item. path ,
407
399
tokens : item. node . tokens ( item. span ) ,
408
400
is_sugared_doc : false ,
409
- span : sp ,
401
+ span : item . span ,
410
402
}
411
403
}
412
404
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 {
414
406
let style = doc_comment_style ( & text. as_str ( ) ) ;
415
407
let lit_kind = LitKind :: Str ( text, ast:: StrStyle :: Cooked ) ;
416
408
let lit = Lit :: from_lit_kind ( lit_kind, span) ;
417
409
Attribute {
418
- id,
410
+ id : mk_attr_id ( ) ,
419
411
style,
420
412
path : Path :: from_ident ( Ident :: with_empty_ctxt ( sym:: doc) . with_span_pos ( span) ) ,
421
413
tokens : MetaItemKind :: NameValue ( lit) . tokens ( span) ,
0 commit comments