diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2019-10-28 17:44:20 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2019-10-30 12:05:26 -0700 |
| commit | 454e2aa8c99850c9393fb2314e1a71da08120063 (patch) | |
| tree | 89912fba3e2938a85bf7bbf8712989562db897f4 /src/libsyntax/parse/parser | |
| parent | 053a09529a41931a217daecbe879b88386101249 (diff) | |
| download | rust-454e2aa8c99850c9393fb2314e1a71da08120063.tar.gz rust-454e2aa8c99850c9393fb2314e1a71da08120063.zip | |
Do not complain about missing `fn main()` in some cases
Diffstat (limited to 'src/libsyntax/parse/parser')
| -rw-r--r-- | src/libsyntax/parse/parser/diagnostics.rs | 5 |
1 files changed, 5 insertions, 0 deletions
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: |
