Skip to content

Conversation

@ThanhNguyxn
Copy link
Contributor

@ThanhNguyxn ThanhNguyxn commented Jan 22, 2026

Adds a regression test for #138225.

The compiler used to ICE with ReferencesError when compiling code with:

  • An undefined type in a struct field
  • An async function returning a static reference to that struct
  • Optimizations enabled (-C opt-level=1 or higher)

The bug has been fixed and now correctly reports E0425: cannot find type.

Test file: tests/ui/async-await/ice-static-in-async-fn-issue-138225.rs
Closes #138225

@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 Jan 22, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 22, 2026

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

This comment has been minimized.

@Kivooeo
Copy link
Member

Kivooeo commented Jan 22, 2026

  1. Remove links from commits
  2. Don't use AI to generate your PR description

@ThanhNguyxn ThanhNguyxn force-pushed the fix/add-test-issue-138225 branch from a7efde9 to 6eacc80 Compare January 22, 2026 11:29
@ThanhNguyxn
Copy link
Contributor Author

Thanks for the feedback @Kivooeo!

Done:

  1. Squashed commits and removed issue links from commit message
  2. Rewrote PR description in plain language

The test file name still references the issue number for traceability (as is common in the test suite), but commit/PR messages are now clean.

@rust-log-analyzer

This comment has been minimized.

@ThanhNguyxn
Copy link
Contributor Author

The x86_64-gnu-tools failure appears unrelated to this PR - it's failing on tests/rustdoc-gui/globals.goml which tests the search index, while this PR only adds a UI test for an ICE regression.

@bors retry

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 22, 2026

@ThanhNguyxn: 🔑 Insufficient privileges: not in review users

@BoxyUwU BoxyUwU closed this Jan 22, 2026
@BoxyUwU BoxyUwU reopened this Jan 22, 2026
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 22, 2026
@rust-log-analyzer

This comment has been minimized.

@ThanhNguyxn
Copy link
Contributor Author

This failure is also unrelated - CI failed to clone rust-toolstate repo:

Command `git clone --depth=1 https://github.com/rust-lang-nursery/rust-toolstate rust-toolstate` failed with exit code 128

This is an infrastructure/network issue, not related to the PR changes. Will need a maintainer to retry.

@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 22, 2026

You can close/reopen the PR yourself to restart CI I think

@Kivooeo Kivooeo closed this Jan 22, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 22, 2026
@Kivooeo Kivooeo reopened this Jan 22, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 22, 2026
@ThanhNguyxn
Copy link
Contributor Author

You can close/reopen the PR yourself to restart CI I think

I can only close it, I aint reopen it. Im sorry I cant

@Kivooeo Kivooeo assigned Kivooeo and unassigned BoxyUwU Jan 30, 2026
@ThanhNguyxn ThanhNguyxn force-pushed the fix/add-test-issue-138225 branch from 6eacc80 to 2be6948 Compare January 31, 2026 06:06
@rustbot
Copy link
Collaborator

rustbot commented Jan 31, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@ThanhNguyxn
Copy link
Contributor Author

why do we need edition 2021 for this test

Sr, I forgot earlier, but I've corrected it now

@Kivooeo
Copy link
Member

Kivooeo commented Jan 31, 2026

consider removing issue link from commit

@ThanhNguyxn ThanhNguyxn force-pushed the fix/add-test-issue-138225 branch from 05ff335 to f12641e Compare January 31, 2026 06:19
@rust-log-analyzer

This comment has been minimized.

@ThanhNguyxn ThanhNguyxn force-pushed the fix/add-test-issue-138225 branch 2 times, most recently from 63c5ee1 to f5029aa Compare January 31, 2026 07:10
@ThanhNguyxn
Copy link
Contributor Author

I tried adding an edition directive to get the async test passing, but removed it again per your request. If the 2015 default causes CI to fail again, let me know and I can adjust the test another way.

@rust-log-analyzer

This comment has been minimized.

@Kivooeo
Copy link
Member

Kivooeo commented Jan 31, 2026

can you rebless this test?

@ThanhNguyxn ThanhNguyxn force-pushed the fix/add-test-issue-138225 branch from f5029aa to 0423285 Compare January 31, 2026 08:04
@ThanhNguyxn
Copy link
Contributor Author

Reblessed tests/ui/mir/gvn-opt-138225.rs; expected stderr now includes the Rust 2015 async fn error (E0670) along with E0425.

Comment on lines 9 to 11
pub async fn func1() -> &'static A {
static RES: A = A { name: None };
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub async fn func1() -> &'static A {
static RES: A = A { name: None };
pub async fn func1() -> &'static A {
//~^ ERROR `async fn` is not permitted in Rust 2015
static RES: A = A { name: None };

@rust-log-analyzer

This comment has been minimized.

@ThanhNguyxn ThanhNguyxn force-pushed the fix/add-test-issue-138225 branch from 0423285 to 565b772 Compare January 31, 2026 08:50
@ThanhNguyxn
Copy link
Contributor Author

Added inline expected error for Rust 2015 async fn (E0670) next to the async fn, per review. Expected stderr already includes E0670 + E0425.

@reddevilmidzy
Copy link
Member

@ThanhNguyxn If you add close #{issue_number} to the PR description, the issue will be automatically closed when the PR is merged.

https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword

@Kivooeo
Copy link
Member

Kivooeo commented Feb 1, 2026

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 1, 2026

📌 Commit 565b772 has been approved by Kivooeo

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 Feb 1, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 1, 2026
…225, r=Kivooeo

Add regression test for issue rust-lang#138225

Adds a regression test for rust-lang#138225.

The compiler used to ICE with `ReferencesError` when compiling code with:
- An undefined type in a struct field
- An async function returning a static reference to that struct
- Optimizations enabled (`-C opt-level=1` or higher)

The bug has been fixed and now correctly reports `E0425: cannot find type`.

Test file: `tests/ui/async-await/ice-static-in-async-fn-issue-138225.rs`
Closes rust-lang#138225
rust-bors bot pushed a commit that referenced this pull request Feb 1, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #150428 (UnixStream/UnixListener on Windows )
 - #147400 (TryFrom<integer> for bool)
 - #150993 (std: sys: uefi: os: Implement join_paths)
 - #151483 (Add regression test for issue #138225)
 - #151568 (Update hexagon target linker configurations)
 - #151725 (Fix outdated Debian Ports ISO reference)
 - #151895 (Move UI tests batch)
 - #151923 (Fix ICE when projection error reporting sees opaque alias terms)
 - #151947 (Include assoc const projections in CFI trait object)
 - #151948 (Handle unbalanced delimiters gracefully in make_attr_token_stream)
rust-bors bot pushed a commit that referenced this pull request Feb 2, 2026
Rollup of 11 pull requests

Successful merges:

 - #151756 (Avoid miri error in `slice::sort` under Stacked Borrows)
 - #147400 (TryFrom<integer> for bool)
 - #150993 (std: sys: uefi: os: Implement join_paths)
 - #151483 (Add regression test for issue #138225)
 - #151568 (Update hexagon target linker configurations)
 - #151725 (Fix outdated Debian Ports ISO reference)
 - #151895 (Move UI tests batch)
 - #151923 (Fix ICE when projection error reporting sees opaque alias terms)
 - #151947 (Include assoc const projections in CFI trait object)
 - #151948 (Handle unbalanced delimiters gracefully in make_attr_token_stream)
 - #151963 (Add regression test for negative literal in a range of unsigned type)
rust-bors bot pushed a commit that referenced this pull request Feb 2, 2026
Rollup of 11 pull requests

Successful merges:

 - #151756 (Avoid miri error in `slice::sort` under Stacked Borrows)
 - #147400 (TryFrom<integer> for bool)
 - #150993 (std: sys: uefi: os: Implement join_paths)
 - #151483 (Add regression test for issue #138225)
 - #151568 (Update hexagon target linker configurations)
 - #151725 (Fix outdated Debian Ports ISO reference)
 - #151895 (Move UI tests batch)
 - #151923 (Fix ICE when projection error reporting sees opaque alias terms)
 - #151947 (Include assoc const projections in CFI trait object)
 - #151948 (Handle unbalanced delimiters gracefully in make_attr_token_stream)
 - #151963 (Add regression test for negative literal in a range of unsigned type)
@rust-bors rust-bors bot merged commit 2cc38ff into rust-lang:main Feb 2, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 2, 2026
rust-timer added a commit that referenced this pull request Feb 2, 2026
Rollup merge of #151483 - ThanhNguyxn:fix/add-test-issue-138225, r=Kivooeo

Add regression test for issue #138225

Adds a regression test for #138225.

The compiler used to ICE with `ReferencesError` when compiling code with:
- An undefined type in a struct field
- An async function returning a static reference to that struct
- Optimizations enabled (`-C opt-level=1` or higher)

The bug has been fixed and now correctly reports `E0425: cannot find type`.

Test file: `tests/ui/async-await/ice-static-in-async-fn-issue-138225.rs`
Closes #138225
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:called Result::unwrap() on an Err value: ReferencesError(ErrorGuaranteed(()))

6 participants