about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-10-11 14:14:30 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2019-11-07 13:59:13 +0100
commita1571b68552b0d56d85080c5f92fdab233775de4 (patch)
treef98a9e52d3a8771fb83981ed79d9ed6207b7d5b4 /src/libsyntax
parent255b12a8d3ef3639b4b389fc56d93bd80f03d087 (diff)
downloadrust-a1571b68552b0d56d85080c5f92fdab233775de4.tar.gz
rust-a1571b68552b0d56d85080c5f92fdab233775de4.zip
syntax::attr: remove usage of lexer
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/attr/mod.rs5
-rw-r--r--src/libsyntax/parse/parser/attr.rs11
2 files changed, 11 insertions, 5 deletions
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs
index d609225a54f..c639431794c 100644
--- a/src/libsyntax/attr/mod.rs
+++ b/src/libsyntax/attr/mod.rs
@@ -14,7 +14,6 @@ use crate::ast::{MetaItem, MetaItemKind, NestedMetaItem};
 use crate::ast::{Lit, LitKind, Expr, Item, Local, Stmt, StmtKind, GenericParam};
 use crate::mut_visit::visit_clobber;
 use crate::source_map::{BytePos, Spanned};
-use crate::parse::lexer::comments::doc_comment_style;
 use crate::parse;
 use crate::token::{self, Token};
 use crate::ptr::P;
@@ -401,11 +400,11 @@ pub fn mk_attr_outer(item: MetaItem) -> Attribute {
     mk_attr(AttrStyle::Outer, item.path, item.kind.tokens(item.span), item.span)
 }
 
-pub fn mk_doc_comment(comment: Symbol, span: Span) -> Attribute {
+pub fn mk_doc_comment(style: AttrStyle, comment: Symbol, span: Span) -> Attribute {
     Attribute {
         kind: AttrKind::DocComment(comment),
         id: mk_attr_id(),
-        style: doc_comment_style(&comment.as_str()),
+        style,
         span,
     }
 }
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();