11use super :: { SeqSep , Parser , TokenType , PathStyle } ;
22use crate :: attr;
33use crate :: ast;
4+ use crate :: parse:: lexer:: comments;
45use crate :: token:: { self , Nonterminal , DelimToken } ;
56use crate :: tokenstream:: { TokenStream , TokenTree } ;
67use crate :: source_map:: Span ;
78
9+ use syntax_pos:: Symbol ;
810use errors:: PResult ;
911
1012use log:: debug;
@@ -45,7 +47,7 @@ impl<'a> Parser<'a> {
4547 just_parsed_doc_comment = false ;
4648 }
4749 token:: DocComment ( s) => {
48- let attr = attr :: mk_doc_comment ( s, self . token . span ) ;
50+ let attr = self . mk_doc_comment ( s) ;
4951 if attr. style != ast:: AttrStyle :: Outer {
5052 let mut err = self . fatal ( "expected outer doc comment" ) ;
5153 err. note ( "inner doc comments like this (starting with \
@@ -62,6 +64,11 @@ impl<'a> Parser<'a> {
6264 Ok ( attrs)
6365 }
6466
67+ fn mk_doc_comment ( & self , s : Symbol ) -> ast:: Attribute {
68+ let style = comments:: doc_comment_style ( & s. as_str ( ) ) ;
69+ attr:: mk_doc_comment ( style, s, self . token . span )
70+ }
71+
6572 /// Matches `attribute = # ! [ meta_item ]`.
6673 ///
6774 /// If `permit_inner` is `true`, then a leading `!` indicates an inner
@@ -230,7 +237,7 @@ impl<'a> Parser<'a> {
230237 }
231238 token:: DocComment ( s) => {
232239 // We need to get the position of this token before we bump.
233- let attr = attr :: mk_doc_comment ( s, self . token . span ) ;
240+ let attr = self . mk_doc_comment ( s) ;
234241 if attr. style == ast:: AttrStyle :: Inner {
235242 attrs. push ( attr) ;
236243 self . bump ( ) ;
0 commit comments