Skip to content

Commit 94a5ffd

Browse files
authored
Unrolled build for rust-lang#126724
Rollup merge of rust-lang#126724 - nnethercote:fix-parse_ty_bare_fn-span, r=compiler-errors 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. r? ``@spastorino``
2 parents a299aa5 + cf0251d commit 94a5ffd

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
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

tests/ui/rust-2024/safe-outside-extern.gated.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ error: function pointers cannot be declared with `safe` safety qualifier
2626
--> $DIR/safe-outside-extern.rs:24:14
2727
|
2828
LL | type FnPtr = safe fn(i32, i32) -> i32;
29-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^
3030

3131
error: aborting due to 5 previous errors
3232

tests/ui/rust-2024/safe-outside-extern.ungated.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ error: function pointers cannot be declared with `safe` safety qualifier
2626
--> $DIR/safe-outside-extern.rs:24:14
2727
|
2828
LL | type FnPtr = safe fn(i32, i32) -> i32;
29-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^
3030

3131
error[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental
3232
--> $DIR/safe-outside-extern.rs:4:1

0 commit comments

Comments
 (0)