diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2021-09-08 14:48:12 -0400 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2021-09-16 09:11:36 -0700 |
| commit | 73c80cde8c2f05ad74c8f9228c7b538847ba9274 (patch) | |
| tree | 9f01f3fda26dc820d8b9be3217d7585fdaafe4e8 | |
| parent | 983c1b1544d01f998dae27be9aee47ba63c3ff3f (diff) | |
| download | rust-73c80cde8c2f05ad74c8f9228c7b538847ba9274.tar.gz rust-73c80cde8c2f05ad74c8f9228c7b538847ba9274.zip | |
Re-add 71a7f8f1884b2c83eeb4a545eef16df1f2ea6476 post-revert.
(cherry picked from commit f26f1ed9a7208c0d928f0413cdd5f0966fa2c399)
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 29e20f2747f..c5b961f12b2 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1469,7 +1469,10 @@ impl<'a> Parser<'a> { let (ident, is_raw) = self.ident_or_err()?; if !is_raw && ident.is_reserved() { let err = if self.check_fn_front_matter(false) { - let _ = self.parse_fn(&mut Vec::new(), |_| true, lo); + // We use `parse_fn` to get a span for the function + if let Err(mut db) = self.parse_fn(&mut Vec::new(), |_| true, lo) { + db.delay_as_bug(); + } let mut err = self.struct_span_err( lo.to(self.prev_token.span), &format!("functions are not allowed in {} definitions", adt_ty), |
