Skip to content

Commit ef2da4a

Browse files
committed
Remove reached_eof from ParseSess
It was only ever set in a function which isn't called anywhere.
1 parent 5f3abbc commit ef2da4a

File tree

4 files changed

+1
-24
lines changed

4 files changed

+1
-24
lines changed

compiler/rustc_parse/src/lexer/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ pub(crate) fn parse_token_trees<'a>(
7474
// because the delimiter mismatch is more likely to be the root cause of error
7575

7676
let mut buffer = Vec::with_capacity(1);
77-
// Not using `emit_unclosed_delims` to use `db.buffer`
7877
for unmatched in unmatched_delims {
7978
if let Some(err) = make_unclosed_delims_error(unmatched, &sess) {
8079
err.buffer(&mut buffer);

compiler/rustc_parse/src/parser/mod.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use rustc_ast::{Async, AttrArgs, AttrArgsEq, Expr, ExprKind, Mutability, StrLit}
2929
use rustc_ast::{HasAttrs, HasTokens, Unsafe, Visibility, VisibilityKind};
3030
use rustc_ast_pretty::pprust;
3131
use rustc_data_structures::fx::FxHashMap;
32-
use rustc_data_structures::sync::Ordering;
3332
use rustc_errors::PResult;
3433
use rustc_errors::{
3534
Applicability, DiagnosticBuilder, ErrorGuaranteed, FatalError, IntoDiagnostic, MultiSpan,
@@ -1455,18 +1454,6 @@ pub(crate) fn make_unclosed_delims_error(
14551454
Some(err)
14561455
}
14571456

1458-
pub fn emit_unclosed_delims(unclosed_delims: &mut Vec<UnmatchedDelim>, sess: &ParseSess) {
1459-
let _ = sess.reached_eof.fetch_or(
1460-
unclosed_delims.iter().any(|unmatched_delim| unmatched_delim.found_delim.is_none()),
1461-
Ordering::Relaxed,
1462-
);
1463-
for unmatched in unclosed_delims.drain(..) {
1464-
if let Some(mut e) = make_unclosed_delims_error(unmatched, sess) {
1465-
e.emit();
1466-
}
1467-
}
1468-
}
1469-
14701457
/// A helper struct used when building an `AttrTokenStream` from
14711458
/// a `LazyAttrTokenStream`. Both delimiter and non-delimited tokens
14721459
/// are stored as `FlatToken::Token`. A vector of `FlatToken`s

compiler/rustc_passes/src/entry.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,6 @@ fn sigpipe(tcx: TyCtxt<'_>, def_id: DefId) -> u8 {
187187

188188
fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_>) {
189189
let sp = tcx.def_span(CRATE_DEF_ID);
190-
if tcx.sess.parse_sess.reached_eof.load(rustc_data_structures::sync::Ordering::Relaxed) {
191-
// There's an unclosed brace that made the parser reach `Eof`, we shouldn't complain about
192-
// the missing `fn main()` then as it might have been hidden inside an unclosed block.
193-
tcx.sess.delay_span_bug(sp, "`main` not found, but expected unclosed brace error");
194-
return;
195-
}
196190

197191
// There is no main function.
198192
let mut has_filename = true;

compiler/rustc_session/src/parse.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::lint::{
88
};
99
use rustc_ast::node_id::NodeId;
1010
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
11-
use rustc_data_structures::sync::{AppendOnlyVec, AtomicBool, Lock, Lrc};
11+
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
1212
use rustc_errors::{emitter::SilentEmitter, Handler};
1313
use rustc_errors::{
1414
fallback_fluent_bundle, Diagnostic, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
@@ -204,8 +204,6 @@ pub struct ParseSess {
204204
pub ambiguous_block_expr_parse: Lock<FxHashMap<Span, Span>>,
205205
pub gated_spans: GatedSpans,
206206
pub symbol_gallery: SymbolGallery,
207-
/// The parser has reached `Eof` due to an unclosed brace. Used to silence unnecessary errors.
208-
pub reached_eof: AtomicBool,
209207
/// Environment variables accessed during the build and their values when they exist.
210208
pub env_depinfo: Lock<FxHashSet<(Symbol, Option<Symbol>)>>,
211209
/// File paths accessed during the build.
@@ -242,7 +240,6 @@ impl ParseSess {
242240
ambiguous_block_expr_parse: Lock::new(FxHashMap::default()),
243241
gated_spans: GatedSpans::default(),
244242
symbol_gallery: SymbolGallery::default(),
245-
reached_eof: AtomicBool::new(false),
246243
env_depinfo: Default::default(),
247244
file_depinfo: Default::default(),
248245
assume_incomplete_release: false,

0 commit comments

Comments
 (0)