From 454e2aa8c99850c9393fb2314e1a71da08120063 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Mon, 28 Oct 2019 17:44:20 -0700 Subject: Do not complain about missing `fn main()` in some cases --- src/libsyntax/parse/parser/diagnostics.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/libsyntax/parse/parser') diff --git a/src/libsyntax/parse/parser/diagnostics.rs b/src/libsyntax/parse/parser/diagnostics.rs index be1441d1c3f..fcf3b4c0aa8 100644 --- a/src/libsyntax/parse/parser/diagnostics.rs +++ b/src/libsyntax/parse/parser/diagnostics.rs @@ -1141,6 +1141,11 @@ impl<'a> Parser<'a> { // Don't attempt to recover from this unclosed delimiter more than once. let unmatched = self.unclosed_delims.remove(pos); let delim = TokenType::Token(token::CloseDelim(unmatched.expected_delim)); + if unmatched.found_delim.is_none() { + // We encountered `Eof`, set this fact here to avoid complaining about missing + // `fn main()` when we found place to suggest the closing brace. + *self.sess.reached_eof.borrow_mut() = true; + } // We want to suggest the inclusion of the closing delimiter where it makes // the most sense, which is immediately after the last token: -- cgit 1.4.1-3-g733a5