1
Fork 0

Remove stream_to_parser.

It's a zero-value wrapper of `Parser::new`.
This commit is contained in:
Nicholas Nethercote 2024-05-31 13:32:54 +10:00
parent 769ca3f661
commit 3c321b9ea8
7 changed files with 13 additions and 25 deletions

View file

@ -2,6 +2,7 @@ use super::diagnostics::report_suspicious_mismatch_block;
use super::diagnostics::same_indentation_level;
use super::diagnostics::TokenTreeDiagInfo;
use super::{StringReader, UnmatchedDelim};
use crate::Parser;
use rustc_ast::token::{self, Delimiter, Token};
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
use rustc_ast_pretty::pprust::token_to_string;
@ -231,7 +232,7 @@ impl<'psess, 'src> TokenTreesReader<'psess, 'src> {
) -> Vec<PErr<'psess>> {
// If there are unclosed delims, see if there are diff markers and if so, point them
// out instead of complaining about the unclosed delims.
let mut parser = crate::stream_to_parser(self.string_reader.psess, tts, None);
let mut parser = Parser::new(self.string_reader.psess, tts, None);
let mut diff_errs = vec![];
// Suggest removing a `{` we think appears in an `if`/`while` condition.
// We want to suggest removing a `{` only if we think we're in an `if`/`while` condition,

View file

@ -123,7 +123,7 @@ fn maybe_source_file_to_parser(
) -> Result<Parser<'_>, Vec<Diag<'_>>> {
let end_pos = source_file.end_position();
let stream = maybe_source_file_to_stream(psess, source_file, None)?;
let mut parser = stream_to_parser(psess, stream, None);
let mut parser = Parser::new(psess, stream, None);
if parser.token == token::Eof {
parser.token.span = Span::new(end_pos, end_pos, parser.token.span.ctxt(), None);
}
@ -168,15 +168,6 @@ fn maybe_source_file_to_stream<'psess>(
lexer::lex_token_trees(psess, src.as_str(), source_file.start_pos, override_span)
}
/// Given a stream and the `ParseSess`, produces a parser.
pub fn stream_to_parser<'a>(
psess: &'a ParseSess,
stream: TokenStream,
subparser_name: Option<&'static str>,
) -> Parser<'a> {
Parser::new(psess, stream, subparser_name)
}
/// Runs the given subparser `f` on the tokens of the given `attr`'s item.
pub fn parse_in<'a, T>(
psess: &'a ParseSess,