about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-07-07 04:18:47 +0000
committerbors <bors@rust-lang.org>2022-07-07 04:18:47 +0000
commite78e747f53c36e53ff99c94438d2efa26830fc4b (patch)
tree8278ec9a3214579c91d45a5d5b15d388f3bd7990 /compiler/rustc_parse/src/parser
parentfac8fa56726f7a5b2d4880a4719c5f99beec8328 (diff)
parent02fb345964cead725bca5e9dea745210ed6c9c37 (diff)
downloadrust-e78e747f53c36e53ff99c94438d2efa26830fc4b.tar.gz
rust-e78e747f53c36e53ff99c94438d2efa26830fc4b.zip
Auto merge of #98827 - aDotInTheVoid:suggest-extern-block, r=nagisa
Suggest using block for `extern "abi" fn` with no body

`@rustbot` modify labels: +A-diagnostics
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index 00002f6f59b..67e6402c0ae 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -1353,7 +1353,16 @@ impl<'a> Parser<'a> {
 
     /// Parses `extern string_literal?`.
     fn parse_extern(&mut self) -> Extern {
-        if self.eat_keyword(kw::Extern) { Extern::from_abi(self.parse_abi()) } else { Extern::None }
+        if self.eat_keyword(kw::Extern) {
+            let mut extern_span = self.prev_token.span;
+            let abi = self.parse_abi();
+            if let Some(abi) = abi {
+                extern_span = extern_span.to(abi.span);
+            }
+            Extern::from_abi(abi, extern_span)
+        } else {
+            Extern::None
+        }
     }
 
     /// Parses a string literal as an ABI spec.