use diagnostics::Error;
pub use path::PathStyle;
-use log::debug;
use rustc_ast::ast::DUMMY_NODE_ID;
use rustc_ast::ast::{self, AttrStyle, AttrVec, Const, CrateSugar, Extern, Unsafe};
use rustc_ast::ast::{
use rustc_ast::ptr::P;
use rustc_ast::token::{self, DelimToken, Token, TokenKind};
use rustc_ast::tokenstream::{self, DelimSpan, TokenStream, TokenTree, TreeAndJoint};
-use rustc_ast::util::comments::{doc_comment_style, strip_doc_comment_decoration};
use rustc_ast_pretty::pprust;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, FatalError, PResult};
use rustc_session::parse::ParseSess;
use rustc_span::source_map::{respan, Span, DUMMY_SP};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
+use tracing::debug;
use std::{cmp, mem, slice};
/// error.
pub(super) unclosed_delims: Vec<UnmatchedBrace>,
last_unexpected_token_span: Option<Span>,
+ /// Span pointing at the `:` for the last type ascription the parser has seen, and whether it
+ /// looked like it could have been a mistyped path or literal `Option:Some(42)`).
pub last_type_ascription: Option<(Span, bool /* likely path typo */)>,
/// If present, this `Parser` is not parsing Rust code but rather a macro call.
subparser_name: Option<&'static str>,
}
fn next_desugared(&mut self) -> Token {
- let (name, sp) = match self.next() {
- Token { kind: token::DocComment(name), span } => (name, span),
+ let (data, attr_style, sp) = match self.next() {
+ Token { kind: token::DocComment(_, attr_style, data), span } => {
+ (data, attr_style, span)
+ }
tok => return tok,
};
- let stripped = strip_doc_comment_decoration(name);
-
// Searches for the occurrences of `"#*` and returns the minimum number of `#`s
// required to wrap the text.
let mut num_of_hashes = 0;
let mut count = 0;
- for ch in stripped.chars() {
+ for ch in data.as_str().chars() {
count = match ch {
'"' => 1,
'#' if count > 0 => count + 1,
[
TokenTree::token(token::Ident(sym::doc, false), sp),
TokenTree::token(token::Eq, sp),
- TokenTree::token(
- TokenKind::lit(token::StrRaw(num_of_hashes), Symbol::intern(&stripped), None),
- sp,
- ),
+ TokenTree::token(TokenKind::lit(token::StrRaw(num_of_hashes), data, None), sp),
]
.iter()
.cloned()
TokenCursorFrame::new(
delim_span,
token::NoDelim,
- &if doc_comment_style(name) == AttrStyle::Inner {
+ &if attr_style == AttrStyle::Inner {
[TokenTree::token(token::Pound, sp), TokenTree::token(token::Not, sp), body]
.iter()
.cloned()