Skip to content

Commit 384bc37

Browse files
committed
no need to return unmatched_delims from tokentrees
1 parent 8ddefe6 commit 384bc37

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

compiler/rustc_expand/src/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ pub(crate) fn string_to_stream(source_str: String) -> TokenStream {
4343
ps.source_map().new_source_file(PathBuf::from("bogofile").into(), source_str),
4444
None,
4545
)
46-
.0
4746
}
4847

4948
/// Parses a string, returns a crate.

compiler/rustc_parse/src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub const MACRO_ARGUMENTS: Option<&str> = Some("macro arguments");
3030

3131
#[macro_use]
3232
pub mod parser;
33-
use parser::{emit_unclosed_delims, make_unclosed_delims_error, Parser};
33+
use parser::{make_unclosed_delims_error, Parser};
3434
pub mod lexer;
3535
pub mod validate_attr;
3636

@@ -96,10 +96,7 @@ pub fn parse_stream_from_source_str(
9696
sess: &ParseSess,
9797
override_span: Option<Span>,
9898
) -> TokenStream {
99-
let (stream, mut errors) =
100-
source_file_to_stream(sess, sess.source_map().new_source_file(name, source), override_span);
101-
emit_unclosed_delims(&mut errors, &sess);
102-
stream
99+
source_file_to_stream(sess, sess.source_map().new_source_file(name, source), override_span)
103100
}
104101

105102
/// Creates a new parser from a source string.
@@ -135,9 +132,8 @@ fn maybe_source_file_to_parser(
135132
source_file: Lrc<SourceFile>,
136133
) -> Result<Parser<'_>, Vec<Diagnostic>> {
137134
let end_pos = source_file.end_pos;
138-
let (stream, unclosed_delims) = maybe_file_to_stream(sess, source_file, None)?;
135+
let stream = maybe_file_to_stream(sess, source_file, None)?;
139136
let mut parser = stream_to_parser(sess, stream, None);
140-
parser.unclosed_delims = unclosed_delims;
141137
if parser.token == token::Eof {
142138
parser.token.span = Span::new(end_pos, end_pos, parser.token.span.ctxt(), None);
143139
}
@@ -182,7 +178,7 @@ pub fn source_file_to_stream(
182178
sess: &ParseSess,
183179
source_file: Lrc<SourceFile>,
184180
override_span: Option<Span>,
185-
) -> (TokenStream, Vec<lexer::UnmatchedDelim>) {
181+
) -> TokenStream {
186182
panictry_buffer!(&sess.span_diagnostic, maybe_file_to_stream(sess, source_file, override_span))
187183
}
188184

@@ -192,7 +188,7 @@ pub fn maybe_file_to_stream(
192188
sess: &ParseSess,
193189
source_file: Lrc<SourceFile>,
194190
override_span: Option<Span>,
195-
) -> Result<(TokenStream, Vec<lexer::UnmatchedDelim>), Vec<Diagnostic>> {
191+
) -> Result<TokenStream, Vec<Diagnostic>> {
196192
let src = source_file.src.as_ref().unwrap_or_else(|| {
197193
sess.span_diagnostic.bug(&format!(
198194
"cannot lex `source_file` without source: {}",
@@ -204,7 +200,7 @@ pub fn maybe_file_to_stream(
204200
lexer::parse_token_trees(sess, src.as_str(), source_file.start_pos, override_span);
205201

206202
match token_trees {
207-
Ok(stream) if unmatched_delims.is_empty() => Ok((stream, unmatched_delims)),
203+
Ok(stream) if unmatched_delims.is_empty() => Ok(stream),
208204
_ => {
209205
// Return error if there are unmatched delimiters or unclosng delimiters.
210206
// We emit delimiter mismatch errors first, then emit the unclosing delimiter mismatch

0 commit comments

Comments
 (0)