Skip to content

Commit d0a26ac

Browse files
committed
Address review comments.
1 parent 7f7e216 commit d0a26ac

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

Diff for: compiler/rustc_lexer/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@
2323
// We want to be able to build this crate with a stable compiler, so no
2424
// `#![feature]` attributes should be added.
2525

26-
pub mod cursor;
26+
mod cursor;
2727
pub mod unescape;
2828

2929
#[cfg(test)]
3030
mod tests;
3131

32+
pub use crate::cursor::Cursor;
33+
3234
use self::LiteralKind::*;
3335
use self::TokenKind::*;
34-
use crate::cursor::{Cursor, EOF_CHAR};
36+
use crate::cursor::EOF_CHAR;
3537
use std::convert::TryFrom;
3638

3739
/// Parsed token.

Diff for: compiler/rustc_parse/src/lexer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use rustc_ast::token::{self, CommentKind, Delimiter, Token, TokenKind};
44
use rustc_ast::tokenstream::TokenStream;
55
use rustc_ast::util::unicode::contains_text_flow_control_chars;
66
use rustc_errors::{error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult};
7-
use rustc_lexer::cursor::Cursor;
87
use rustc_lexer::unescape::{self, Mode};
8+
use rustc_lexer::Cursor;
99
use rustc_lexer::{Base, DocStyle, RawStrError};
1010
use rustc_session::lint::builtin::{
1111
RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX, TEXT_DIRECTION_CODEPOINT_IN_COMMENT,

Diff for: compiler/rustc_parse/src/lexer/tokentrees.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'a> TokenTreesReader<'a> {
5353
token::OpenDelim(delim) => buf.push(self.parse_token_tree_open_delim(delim)),
5454
token::CloseDelim(delim) => return Err(self.close_delim_err(delim)),
5555
token::Eof => return Ok(buf.into_token_stream()),
56-
_ => buf.push(self.parse_token_tree_other()),
56+
_ => buf.push(self.parse_token_tree_non_delim_non_eof()),
5757
}
5858
}
5959
}
@@ -66,11 +66,10 @@ impl<'a> TokenTreesReader<'a> {
6666
token::OpenDelim(delim) => buf.push(self.parse_token_tree_open_delim(delim)),
6767
token::CloseDelim(..) => return buf.into_token_stream(),
6868
token::Eof => {
69-
let mut err = self.eof_err();
70-
err.emit();
69+
self.eof_err().emit();
7170
return buf.into_token_stream();
7271
}
73-
_ => buf.push(self.parse_token_tree_other()),
72+
_ => buf.push(self.parse_token_tree_non_delim_non_eof()),
7473
}
7574
}
7675
}
@@ -245,9 +244,10 @@ impl<'a> TokenTreesReader<'a> {
245244
}
246245

247246
#[inline]
248-
fn parse_token_tree_other(&mut self) -> TokenTree {
249-
// `spacing` for the returned token is determined by the next token:
250-
// its kind and its `preceded_by_whitespace` status.
247+
fn parse_token_tree_non_delim_non_eof(&mut self) -> TokenTree {
248+
// `this_spacing` for the returned token refers to whether the token is
249+
// immediately followed by another op token. It is determined by the
250+
// next token: its kind and its `preceded_by_whitespace` status.
251251
let (next_tok, is_next_tok_preceded_by_whitespace) = self.string_reader.next_token();
252252
let this_spacing = if is_next_tok_preceded_by_whitespace || !next_tok.is_op() {
253253
Spacing::Alone

Diff for: src/librustdoc/html/highlight.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::collections::VecDeque;
1313
use std::fmt::{Display, Write};
1414

1515
use rustc_data_structures::fx::FxHashMap;
16-
use rustc_lexer::cursor::Cursor;
16+
use rustc_lexer::Cursor;
1717
use rustc_lexer::{LiteralKind, TokenKind};
1818
use rustc_span::edition::Edition;
1919
use rustc_span::symbol::Symbol;

0 commit comments

Comments
 (0)