syntax::attr: remove usage of lexer
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user