diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-11 14:14:30 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-11-07 13:59:13 +0100 |
| commit | a1571b68552b0d56d85080c5f92fdab233775de4 (patch) | |
| tree | f98a9e52d3a8771fb83981ed79d9ed6207b7d5b4 /src/libsyntax/parse/parser | |
| parent | 255b12a8d3ef3639b4b389fc56d93bd80f03d087 (diff) | |
| download | rust-a1571b68552b0d56d85080c5f92fdab233775de4.tar.gz rust-a1571b68552b0d56d85080c5f92fdab233775de4.zip | |
syntax::attr: remove usage of lexer
Diffstat (limited to 'src/libsyntax/parse/parser')
| -rw-r--r-- | src/libsyntax/parse/parser/attr.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser/attr.rs b/src/libsyntax/parse/parser/attr.rs index 2f1b87da7e9..920e7a521ef 100644 --- a/src/libsyntax/parse/parser/attr.rs +++ b/src/libsyntax/parse/parser/attr.rs @@ -1,10 +1,12 @@ use super::{SeqSep, Parser, TokenType, PathStyle}; use crate::attr; use crate::ast; +use crate::parse::lexer::comments; use crate::token::{self, Nonterminal, DelimToken}; use crate::tokenstream::{TokenStream, TokenTree}; use crate::source_map::Span; +use syntax_pos::Symbol; use errors::PResult; use log::debug; @@ -45,7 +47,7 @@ impl<'a> Parser<'a> { just_parsed_doc_comment = false; } token::DocComment(s) => { - let attr = attr::mk_doc_comment(s, self.token.span); + let attr = self.mk_doc_comment(s); if attr.style != ast::AttrStyle::Outer { let mut err = self.fatal("expected outer doc comment"); err.note("inner doc comments like this (starting with \ @@ -62,6 +64,11 @@ impl<'a> Parser<'a> { Ok(attrs) } + fn mk_doc_comment(&self, s: Symbol) -> ast::Attribute { + let style = comments::doc_comment_style(&s.as_str()); + attr::mk_doc_comment(style, s, self.token.span) + } + /// Matches `attribute = # ! [ meta_item ]`. /// /// If `permit_inner` is `true`, then a leading `!` indicates an inner @@ -230,7 +237,7 @@ impl<'a> Parser<'a> { } token::DocComment(s) => { // We need to get the position of this token before we bump. - let attr = attr::mk_doc_comment(s, self.token.span); + let attr = self.mk_doc_comment(s); if attr.style == ast::AttrStyle::Inner { attrs.push(attr); self.bump(); |
