Skip to content

Add regression test for closure in array-length const generic - #159850

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
zakrad:regr-test-closure-array-len
Jul 29, 2026
Merged

Add regression test for closure in array-length const generic#159850
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
zakrad:regr-test-closure-array-len

Conversation

@zakrad

@zakrad zakrad commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Adds a regression test for #119316

The MCVE (a closure inside an array-length const in a generic async fn)
used to ICE with "expected type of closure to be a closure". It's since
been fixed and just emits ordinary errors now, so this adds a UI test to
lock that in.

Closes #119316

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 24, 2026
@rustbot

rustbot commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @tiif (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 (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 74 candidates
  • Random selection from 18 candidates

@Kivooeo

Kivooeo commented Jul 25, 2026

Copy link
Copy Markdown
Member

why edition 2021 was chosed for this test?

@zakrad

zakrad commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

why edition 2021 was chosed for this test?

2021 was an arbitrary decision, it seems 2018 edition is the min edition that the test can use, thanks for the catch.

@zakrad
zakrad force-pushed the regr-test-closure-array-len branch from 8cd5fd4 to 51fb937 Compare July 25, 2026 12:12

@tiif tiif left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! Ping me again when the CI is green.

View changes since this review

Comment on lines +6 to +10
async fn foo<const N: usize>() {
let _data = &mut [0u8; { N + (|| 42)() }];
//~^ ERROR overly complex generic constant
//~| ERROR cannot call non-const closure in constants
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ICE can only be reproduced when it is async fn foo<'a>(), we will need to use the test written in the issue.

#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

async fn foo<'a>() {
    let _data = &mut [0u8; { N + (|| 42)() }];
}

fn main() {}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, switched to the async fn foo<'a>() from the issue, now errors with E0425

@tiif tiif added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 27, 2026
A closure inside an array-length constant in a generic async function used to ICE
with "expected type of closure to be a closure"; it now emits ordinary errors. Add
a regression test locking that in.
@zakrad
zakrad force-pushed the regr-test-closure-array-len branch from 51fb937 to e62c86f Compare July 27, 2026 11:40
@zakrad

zakrad commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@tiif CI is green now, thanks for the review
@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 27, 2026
@zakrad
zakrad requested a review from tiif July 27, 2026 13:27
@tiif

tiif commented Jul 29, 2026

Copy link
Copy Markdown
Member

Thanks!

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

📌 Commit e62c86f has been approved by tiif

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 29, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 29, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #158460 (Remove llvm_enzyme feature outside of bootstrap)
 - #159509 (Generate `valid_range`s for enums sign-agnostically)
 - #159632 (CFI: Add support for the adt_const_params feature)
 - #159671 (Add semver check test command for checking API compatibility of stdlib)
 - #157058 (Rustdoc label badge for notable traits)
 - #159717 (Add `-Zimplicit-sysroot-deps`)
 - #159850 (Add regression test for closure in array-length const generic)
 - #159994 (Show jobs where a given test was executed in `test-dashboard`)
 - #160110 (convert rustc_hir::Target inherent methods to From impls)
 - #160123 (add additional license option for third-party dependencies)
 - #160131 (bootstrap: remove temporary bors email lookup)
rust-bors Bot pushed a commit that referenced this pull request Jul 29, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #158460 (Remove llvm_enzyme feature outside of bootstrap)
 - #159509 (Generate `valid_range`s for enums sign-agnostically)
 - #159632 (CFI: Add support for the adt_const_params feature)
 - #159671 (Add semver check test command for checking API compatibility of stdlib)
 - #157058 (Rustdoc label badge for notable traits)
 - #159717 (Add `-Zimplicit-sysroot-deps`)
 - #159850 (Add regression test for closure in array-length const generic)
 - #159994 (Show jobs where a given test was executed in `test-dashboard`)
 - #160110 (convert rustc_hir::Target inherent methods to From impls)
 - #160123 (add additional license option for third-party dependencies)
 - #160131 (bootstrap: remove temporary bors email lookup)
@rust-bors
rust-bors Bot merged commit 11c2b5a into rust-lang:main Jul 29, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 29, 2026
rust-timer added a commit that referenced this pull request Jul 29, 2026
Rollup merge of #159850 - zakrad:regr-test-closure-array-len, r=tiif

Add regression test for closure in array-length const generic

Adds a regression test for #119316

The MCVE (a closure inside an array-length const in a generic async fn)
used to ICE with "expected type of closure to be a closure". It's since
been fixed and just emits ordinary errors now, so this adds a UI test to
lock that in.

Closes #119316
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: gce: expected type of closure to be a closure

4 participants