1
1
use super :: { SeqSep , Parser , TokenType , PathStyle } ;
2
2
use crate :: attr;
3
3
use crate :: ast;
4
+ use crate :: parse:: lexer:: comments;
4
5
use crate :: token:: { self , Nonterminal , DelimToken } ;
5
6
use crate :: tokenstream:: { TokenStream , TokenTree } ;
6
7
use crate :: source_map:: Span ;
7
8
9
+ use syntax_pos:: Symbol ;
8
10
use errors:: PResult ;
9
11
10
12
use log:: debug;
@@ -45,7 +47,7 @@ impl<'a> Parser<'a> {
45
47
just_parsed_doc_comment = false ;
46
48
}
47
49
token:: DocComment ( s) => {
48
- let attr = attr :: mk_doc_comment ( s, self . token . span ) ;
50
+ let attr = self . mk_doc_comment ( s) ;
49
51
if attr. style != ast:: AttrStyle :: Outer {
50
52
let mut err = self . fatal ( "expected outer doc comment" ) ;
51
53
err. note ( "inner doc comments like this (starting with \
@@ -62,6 +64,11 @@ impl<'a> Parser<'a> {
62
64
Ok ( attrs)
63
65
}
64
66
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
+
65
72
/// Matches `attribute = # ! [ meta_item ]`.
66
73
///
67
74
/// If `permit_inner` is `true`, then a leading `!` indicates an inner
@@ -230,7 +237,7 @@ impl<'a> Parser<'a> {
230
237
}
231
238
token:: DocComment ( s) => {
232
239
// 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) ;
234
241
if attr. style == ast:: AttrStyle :: Inner {
235
242
attrs. push ( attr) ;
236
243
self . bump ( ) ;
0 commit comments