Skip to content

Commit

Permalink
Fix a span in parse_ty_bare_fn.
Browse files Browse the repository at this point in the history
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.

This doesn't affect any tests. I found it while debugging some other
code. Not a big deal but an easy fix so I figure it worth doing.
  • Loading branch information
nnethercote committed Jun 20, 2024
1 parent 894f7a4 commit e9a5dae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })))
}

Expand Down

0 comments on commit e9a5dae

Please sign in to comment.