about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/ty.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-06-17 18:47:09 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2024-06-26 08:23:57 +1000
commitcf0251d92ced77d926a2292df96cb9ad3ce14f97 (patch)
tree9fa25773980565f87635d79fd747bba7541b99a5 /compiler/rustc_parse/src/parser/ty.rs
parentc290e9de32e8ba6a673ef125fde40eadd395d170 (diff)
downloadrust-cf0251d92ced77d926a2292df96cb9ad3ce14f97.tar.gz
rust-cf0251d92ced77d926a2292df96cb9ad3ce14f97.zip
Fix a span in `parse_ty_bare_fn`.
It currently goes one token too far.

Example: line 259 of `tests/ui/abi/compatibility.rs`:
```
test_abi_compatible!(fn_fn, fn(), fn(i32) -> i32);
```
This commit changes the span for the second element from `fn(),` to
`fn()`, i.e. removes the extraneous comma.
Diffstat (limited to 'compiler/rustc_parse/src/parser/ty.rs')
-rw-r--r--compiler/rustc_parse/src/parser/ty.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs
index fcd623b477f..d2043c353fe 100644
--- a/compiler/rustc_parse/src/parser/ty.rs
+++ b/compiler/rustc_parse/src/parser/ty.rs
@@ -608,7 +608,7 @@ impl<'a> Parser<'a> {
             self.dcx().emit_err(FnPointerCannotBeAsync { span: whole_span, qualifier: span });
         }
         // FIXME(gen_blocks): emit a similar error for `gen fn()`
-        let decl_span = span_start.to(self.token.span);
+        let decl_span = span_start.to(self.prev_token.span);
         Ok(TyKind::BareFn(P(BareFnTy { ext, safety, generic_params: params, decl, decl_span })))
     }