fix borrowck ICE for consts with fn pointer type - #160314
Conversation
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @davidtwco (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
r? TaKO8Ki |
There was a problem hiding this comment.
Thanks for working on this. For future contributions, please check whether an issue is already assigned or someone has started working on it before opening a PR. I had assigned 160255 to myself and had already begun preparing a fix, so this duplicated ongoing work. If an issue is already assigned, please ask the assignee before starting work on it.
|
Reminder, once the PR becomes ready for a review, use |
|
@bors squash |
This comment has been minimized.
This comment has been minimized.
* fix borrowck ICE for consts with fn pointer type annotate_argument_and_return_for_borrow called tcx.fn_sig on the item being checked whenever its type was FnDef or FnPtr. for a const whose type is a fn pointer that's not a function item, so we ICE'd with "unexpected sort of node in fn_sig". take the signature from the fn ptr type instead and skip the annotation when there's no fn decl. * run rustfmt and refmt * fix borrowck ICE for consts with fn pointer type annotate_argument_and_return_for_borrow called tcx.fn_sig on the item being checked whenever its type was FnDef or FnPtr. for a const whose type is a fn pointer that's not a function item, so we ICE'd with "unexpected sort of node in fn_sig". take the signature from the fn ptr type instead and skip the annotation when there's no fn decl. * edit comment * use ty.fn_sig per review
|
🔨 5 commits were squashed into d443d45. |
f6974e6 to
d443d45
Compare
|
@rustbot ready |
|
@bors r+ rollup |
fix borrowck ICE for consts with fn pointer type `borrowck`'s `annotate_argument_and_return_for_borrow` called `tcx.fn_sig` on the item being checked whenever its type was a `fn def` or `fn ptr`. For a const like `const A: fn()`, that asks for the signature of the const itself, which is not a function item, so we ICE'd with `"unexpected sort of node in fn_sig"`. Now we take the signature from the `fn ptr` type instead and skip the annotation when there's no `fn decl` to annotate. also added a regression test under `tests/ui/borrowck`. fixes: rust-lang#160255
fix borrowck ICE for consts with fn pointer type `borrowck`'s `annotate_argument_and_return_for_borrow` called `tcx.fn_sig` on the item being checked whenever its type was a `fn def` or `fn ptr`. For a const like `const A: fn()`, that asks for the signature of the const itself, which is not a function item, so we ICE'd with `"unexpected sort of node in fn_sig"`. Now we take the signature from the `fn ptr` type instead and skip the annotation when there's no `fn decl` to annotate. also added a regression test under `tests/ui/borrowck`. fixes: rust-lang#160255
…uwer Rollup of 6 pull requests Successful merges: - #159844 (Subtree cg_gcc sync (2026-07-24)) - #160406 (`DepKind` cleanups) - #159303 (Fix ICE for direct inline const generic defaults) - #160314 (fix borrowck ICE for consts with fn pointer type) - #160322 (ElaborateBoxDeref: remove unnecessary projection) - #160384 (Add PR body notes for Cargo lock file maintenance)
fix borrowck ICE for consts with fn pointer type `borrowck`'s `annotate_argument_and_return_for_borrow` called `tcx.fn_sig` on the item being checked whenever its type was a `fn def` or `fn ptr`. For a const like `const A: fn()`, that asks for the signature of the const itself, which is not a function item, so we ICE'd with `"unexpected sort of node in fn_sig"`. Now we take the signature from the `fn ptr` type instead and skip the annotation when there's no `fn decl` to annotate. also added a regression test under `tests/ui/borrowck`. fixes: rust-lang#160255
…uwer Rollup of 21 pull requests Successful merges: - #159844 (Subtree cg_gcc sync (2026-07-24)) - #159326 (Deny multiple EII impls on a single item) - #159535 (Optimize slice::contains for bytewise types) - #159595 (Promote loongarch32-unknown-none* to Tier 2) - #160007 (allow `-Ldependency` search paths for panic runtimes) - #160320 (point at trait definition when it is used as a derive macro) - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names) - #160406 (`DepKind` cleanups) - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism) - #159014 ([rustdoc] Do not take `doc(cfg())` into account when filtering doctests) - #159303 (Fix ICE for direct inline const generic defaults) - #159977 (Add regression test for bool indexing codegen) - #160165 (reject `...` without pattern post-expansion) - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided) - #160305 (Linkify C-SKY targets in `platform-support.md`) - #160314 (fix borrowck ICE for consts with fn pointer type) - #160322 (ElaborateBoxDeref: remove unnecessary projection) - #160338 (Add regression test for supertrait associated type normalization through dyn) - #160340 (Add regression test for unused_parens on contract clauses) - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`) - #160384 (Add PR body notes for Cargo lock file maintenance)
fix borrowck ICE for consts with fn pointer type `borrowck`'s `annotate_argument_and_return_for_borrow` called `tcx.fn_sig` on the item being checked whenever its type was a `fn def` or `fn ptr`. For a const like `const A: fn()`, that asks for the signature of the const itself, which is not a function item, so we ICE'd with `"unexpected sort of node in fn_sig"`. Now we take the signature from the `fn ptr` type instead and skip the annotation when there's no `fn decl` to annotate. also added a regression test under `tests/ui/borrowck`. fixes: rust-lang#160255
…uwer Rollup of 23 pull requests Successful merges: - #153749 (Account for ownership mismatch on argument that doesn't meet bound) - #159326 (Deny multiple EII impls on a single item) - #159535 (Optimize slice::contains for bytewise types) - #159595 (Promote loongarch32-unknown-none* to Tier 2) - #160007 (allow `-Ldependency` search paths for panic runtimes) - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record}) - #160320 (point at trait definition when it is used as a derive macro) - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names) - #160406 (`DepKind` cleanups) - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism) - #159303 (Fix ICE for direct inline const generic defaults) - #159977 (Add regression test for bool indexing codegen) - #160011 (remove InterpError::map_err_info) - #160165 (reject `...` without pattern post-expansion) - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided) - #160305 (Linkify C-SKY targets in `platform-support.md`) - #160314 (fix borrowck ICE for consts with fn pointer type) - #160322 (ElaborateBoxDeref: remove unnecessary projection) - #160338 (Add regression test for supertrait associated type normalization through dyn) - #160340 (Add regression test for unused_parens on contract clauses) - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`) - #160384 (Add PR body notes for Cargo lock file maintenance) - #160435 (bump tracing-tree)
fix borrowck ICE for consts with fn pointer type `borrowck`'s `annotate_argument_and_return_for_borrow` called `tcx.fn_sig` on the item being checked whenever its type was a `fn def` or `fn ptr`. For a const like `const A: fn()`, that asks for the signature of the const itself, which is not a function item, so we ICE'd with `"unexpected sort of node in fn_sig"`. Now we take the signature from the `fn ptr` type instead and skip the annotation when there's no `fn decl` to annotate. also added a regression test under `tests/ui/borrowck`. fixes: rust-lang#160255
borrowck'sannotate_argument_and_return_for_borrowcalledtcx.fn_sigon the item being checked whenever its type was afn deforfn ptr. For a const likeconst A: fn(), that asks for the signature of the const itself, which is not a function item, so we ICE'd with"unexpected sort of node in fn_sig".Now we take the signature from the
fn ptrtype instead and skip the annotation when there's nofn declto annotate.also added a regression test under
tests/ui/borrowck.fixes: #160255