Skip to content

Commit c39b86a

Browse files
committed
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. 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.
1 parent 894f7a4 commit c39b86a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

compiler/rustc_ast/src/ast.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,8 @@ pub struct BareFnTy {
21262126
pub ext: Extern,
21272127
pub generic_params: ThinVec<GenericParam>,
21282128
pub decl: P<FnDecl>,
2129-
/// Span of the `fn(...) -> ...` part.
2129+
/// Span of the `[unsafe] [extern] fn(...) -> ...` part, i.e. everything
2130+
/// after the generic params (if there are any, e.g. `for<'a>`).
21302131
pub decl_span: Span,
21312132
}
21322133

compiler/rustc_parse/src/parser/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ impl<'a> Parser<'a> {
608608
self.dcx().emit_err(FnPointerCannotBeAsync { span: whole_span, qualifier: span });
609609
}
610610
// FIXME(gen_blocks): emit a similar error for `gen fn()`
611-
let decl_span = span_start.to(self.token.span);
611+
let decl_span = span_start.to(self.prev_token.span);
612612
Ok(TyKind::BareFn(P(BareFnTy { ext, safety, generic_params: params, decl, decl_span })))
613613
}
614614

0 commit comments

Comments
 (0)