diff options
| author | Taiki Endo <te316e89@gmail.com> | 2019-02-07 02:33:01 +0900 |
|---|---|---|
| committer | Taiki Endo <te316e89@gmail.com> | 2019-02-07 02:33:01 +0900 |
| commit | 7bb082d27fe472f52b103de0ae9fc6fa7e6546cc (patch) | |
| tree | dfed08e00fc6e88022fd7249bd5017e5d57110a7 /src/libsyntax/parse/lexer | |
| parent | 2596bc1368d1e3d34c9a7841ad87a3100f01cbad (diff) | |
| download | rust-7bb082d27fe472f52b103de0ae9fc6fa7e6546cc.tar.gz rust-7bb082d27fe472f52b103de0ae9fc6fa7e6546cc.zip | |
libsyntax => 2018
Diffstat (limited to 'src/libsyntax/parse/lexer')
| -rw-r--r-- | src/libsyntax/parse/lexer/comments.rs | 29 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 35 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/tokentrees.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/unicode_chars.rs | 2 |
4 files changed, 41 insertions, 33 deletions
diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index ffc480d829d..4632d814d5c 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -1,11 +1,13 @@ -pub use self::CommentStyle::*; +pub use CommentStyle::*; + +use crate::ast; +use crate::source_map::SourceMap; +use crate::parse::lexer::{is_block_doc_comment, is_pattern_whitespace}; +use crate::parse::lexer::{self, ParseSess, StringReader, TokenAndSpan}; +use crate::print::pprust; -use ast; -use source_map::SourceMap; use syntax_pos::{BytePos, CharPos, Pos, FileName}; -use parse::lexer::{is_block_doc_comment, is_pattern_whitespace}; -use parse::lexer::{self, ParseSess, StringReader, TokenAndSpan}; -use print::pprust; +use log::debug; use std::io::Read; use std::usize; @@ -135,7 +137,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String { panic!("not a doc-comment: {}", comment); } -fn push_blank_line_comment(rdr: &StringReader, comments: &mut Vec<Comment>) { +fn push_blank_line_comment(rdr: &StringReader<'_>, comments: &mut Vec<Comment>) { debug!(">>> blank-line comment"); comments.push(Comment { style: BlankLine, @@ -144,7 +146,10 @@ fn push_blank_line_comment(rdr: &StringReader, comments: &mut Vec<Comment>) { }); } -fn consume_whitespace_counting_blank_lines(rdr: &mut StringReader, comments: &mut Vec<Comment>) { +fn consume_whitespace_counting_blank_lines( + rdr: &mut StringReader<'_>, + comments: &mut Vec<Comment> +) { while is_pattern_whitespace(rdr.ch) && !rdr.is_eof() { if rdr.ch_is('\n') { push_blank_line_comment(rdr, &mut *comments); @@ -153,7 +158,7 @@ fn consume_whitespace_counting_blank_lines(rdr: &mut StringReader, comments: &mu } } -fn read_shebang_comment(rdr: &mut StringReader, +fn read_shebang_comment(rdr: &mut StringReader<'_>, code_to_the_left: bool, comments: &mut Vec<Comment>) { debug!(">>> shebang comment"); @@ -166,7 +171,7 @@ fn read_shebang_comment(rdr: &mut StringReader, }); } -fn read_line_comments(rdr: &mut StringReader, +fn read_line_comments(rdr: &mut StringReader<'_>, code_to_the_left: bool, comments: &mut Vec<Comment>) { debug!(">>> line comments"); @@ -222,7 +227,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut Vec<String>, s: String, col: lines.push(s1); } -fn read_block_comment(rdr: &mut StringReader, +fn read_block_comment(rdr: &mut StringReader<'_>, code_to_the_left: bool, comments: &mut Vec<Comment>) { debug!(">>> block comment"); @@ -312,7 +317,7 @@ fn read_block_comment(rdr: &mut StringReader, } -fn consume_comment(rdr: &mut StringReader, +fn consume_comment(rdr: &mut StringReader<'_>, comments: &mut Vec<Comment>, code_to_the_left: &mut bool, anything_to_the_left: &mut bool) { diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 06f9162a400..2e3233c8ed8 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1,9 +1,10 @@ -use ast::{self, Ident}; +use crate::ast::{self, Ident}; +use crate::source_map::{SourceMap, FilePathMapping}; +use crate::errors::{Applicability, FatalError, Diagnostic, DiagnosticBuilder}; +use crate::parse::{token, ParseSess}; +use crate::symbol::{Symbol, keywords}; + use syntax_pos::{self, BytePos, CharPos, Pos, Span, NO_EXPANSION}; -use source_map::{SourceMap, FilePathMapping}; -use errors::{Applicability, FatalError, Diagnostic, DiagnosticBuilder}; -use parse::{token, ParseSess}; -use symbol::{Symbol, keywords}; use core::unicode::property::Pattern_White_Space; use std::borrow::Cow; @@ -11,6 +12,7 @@ use std::char; use std::iter; use std::mem::replace; use rustc_data_structures::sync::Lrc; +use log::debug; pub mod comments; mod tokentrees; @@ -449,7 +451,7 @@ impl<'a> StringReader<'a> { } return s.into(); - fn translate_crlf_(rdr: &StringReader, + fn translate_crlf_(rdr: &StringReader<'_>, start: BytePos, s: &str, mut j: usize, @@ -1866,19 +1868,20 @@ fn char_at(s: &str, byte: usize) -> char { mod tests { use super::*; - use ast::{Ident, CrateConfig}; - use symbol::Symbol; - use syntax_pos::{BytePos, Span, NO_EXPANSION}; - use source_map::SourceMap; - use errors; - use feature_gate::UnstableFeatures; - use parse::token; + use crate::ast::{Ident, CrateConfig}; + use crate::symbol::Symbol; + use crate::source_map::SourceMap; + use crate::errors; + use crate::feature_gate::UnstableFeatures; + use crate::parse::token; + use crate::diagnostics::plugin::ErrorMap; + use crate::with_globals; use std::io; use std::path::PathBuf; - use diagnostics::plugin::ErrorMap; + use syntax_pos::{BytePos, Span, NO_EXPANSION}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::Lock; - use with_globals; + fn mk_sess(sm: Lrc<SourceMap>) -> ParseSess { let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()), Some(sm.clone()), @@ -1943,7 +1946,7 @@ mod tests { // check that the given reader produces the desired stream // of tokens (stop checking after exhausting the expected vec) - fn check_tokenization(mut string_reader: StringReader, expected: Vec<token::Token>) { + fn check_tokenization(mut string_reader: StringReader<'_>, expected: Vec<token::Token>) { for expected_tok in &expected { assert_eq!(&string_reader.next_token().tok, expected_tok); } diff --git a/src/libsyntax/parse/lexer/tokentrees.rs b/src/libsyntax/parse/lexer/tokentrees.rs index d219f29f06c..7699d9eab22 100644 --- a/src/libsyntax/parse/lexer/tokentrees.rs +++ b/src/libsyntax/parse/lexer/tokentrees.rs @@ -1,7 +1,7 @@ -use print::pprust::token_to_string; -use parse::lexer::StringReader; -use parse::{token, PResult}; -use tokenstream::{DelimSpan, IsJoint::*, TokenStream, TokenTree, TreeAndJoint}; +use crate::print::pprust::token_to_string; +use crate::parse::lexer::StringReader; +use crate::parse::{token, PResult}; +use crate::tokenstream::{DelimSpan, IsJoint::*, TokenStream, TokenTree, TreeAndJoint}; impl<'a> StringReader<'a> { // Parse a stream of tokens into a list of `TokenTree`s, up to an `Eof`. diff --git a/src/libsyntax/parse/lexer/unicode_chars.rs b/src/libsyntax/parse/lexer/unicode_chars.rs index 7da4284c0e4..75862178169 100644 --- a/src/libsyntax/parse/lexer/unicode_chars.rs +++ b/src/libsyntax/parse/lexer/unicode_chars.rs @@ -2,7 +2,7 @@ // http://www.unicode.org/Public/security/10.0.0/confusables.txt use syntax_pos::{Span, NO_EXPANSION}; -use errors::{Applicability, DiagnosticBuilder}; +use crate::errors::{Applicability, DiagnosticBuilder}; use super::StringReader; const UNICODE_ARRAY: &[(char, &str, char)] = &[ |
