use errors::Applicability;
-use syntax::parse::lexer::{TokenAndSpan, StringReader as Lexer};
+use syntax::parse::lexer::{StringReader as Lexer};
use syntax::parse::{ParseSess, token};
use syntax::source_map::FilePathMapping;
-use syntax_pos::FileName;
+use syntax_pos::{InnerSpan, FileName};
use crate::clean;
use crate::core::DocContext;
description: "validates syntax inside Rust code blocks",
};
-pub fn check_code_block_syntax(krate: clean::Crate, cx: &DocContext<'_, '_, '_>) -> clean::Crate {
+pub fn check_code_block_syntax(krate: clean::Crate, cx: &DocContext<'_>) -> clean::Crate {
SyntaxChecker { cx }.fold_crate(krate)
}
-struct SyntaxChecker<'a, 'tcx: 'a, 'rcx: 'a> {
- cx: &'a DocContext<'a, 'tcx, 'rcx>,
+struct SyntaxChecker<'a, 'tcx: 'a> {
+ cx: &'a DocContext<'tcx>,
}
-impl<'a, 'tcx, 'rcx> SyntaxChecker<'a, 'tcx, 'rcx> {
+impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> {
fn check_rust_syntax(&self, item: &clean::Item, dox: &str, code_block: RustCodeBlock) {
let sess = ParseSess::new(FilePathMapping::empty());
let source_file = sess.source_map().new_source_file(
);
let errors = Lexer::new_or_buffered_errs(&sess, source_file, None).and_then(|mut lexer| {
- while let Ok(TokenAndSpan { tok, .. }) = lexer.try_next_token() {
- if tok == token::Eof {
+ while let Ok(token::Token { kind, .. }) = lexer.try_next_token() {
+ if kind == token::Eof {
break;
}
}
}
if code_block.syntax.is_none() && code_block.is_fenced {
- let sp = sp.from_inner_byte_pos(0, 3);
+ let sp = sp.from_inner(InnerSpan::new(0, 3));
diag.span_suggestion(
sp,
"mark blocks that do not contain Rust code as text",
}
}
-impl<'a, 'tcx, 'rcx> DocFolder for SyntaxChecker<'a, 'tcx, 'rcx> {
+impl<'a, 'tcx> DocFolder for SyntaxChecker<'a, 'tcx> {
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
if let Some(dox) = &item.attrs.collapsed_doc_value() {
for code_block in markdown::rust_code_blocks(&dox) {