Skip to content

Improve tests for #[track_caller] in async - #161972

Open
theemathas wants to merge 6 commits into
rust-lang:mainfrom
theemathas:async-track_caller-tests
Open

Improve tests for #[track_caller] in async#161972
theemathas wants to merge 6 commits into
rust-lang:mainfrom
theemathas:async-track_caller-tests

Conversation

@theemathas

@theemathas theemathas commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Tracking issue for async_fn_track_caller: #110011

Tracking issue for closure_track_caller: #87417

I recommend reviewing each commit individually.

cc @RalfJung, who requested the test to be added to Miri.


For your convenience, below is the output of diff tests/ui/async-await/track-caller/panic-track-caller.rs src/tools/miri/tests/pass/async-panic-track-caller.rs:

2c2
< // src/tools/miri/tests/pass/async-panic-track-caller.rs
---
> // tests/ui/async-await/track-caller/panic-track-caller.rs
4,6d3
< // FIXME: catch_unwind is broken in gcc. Will be fixed in the next rustc_codegen_gcc sync.
< //@ ignore-backends: gcc
< //@ run-pass
9,10c6,10
< //@ needs-unwind
< // gate-test-async_fn_track_caller
---
> //
> //
> //
> //
> // Padding comment so that the line numbers are the same as panic-track-caller.rs
58a59
> #[cfg_attr(any(cls, nofeat), expect(ungated_async_fn_track_caller))]
60d60
< //[cls,nofeat]~^ WARN `#[track_caller]` on async functions is a no-op
72a73
>     #[cfg_attr(any(cls, nofeat), expect(ungated_async_fn_track_caller))]
74d74
<     //[cls,nofeat]~^ WARN `#[track_caller]` on async functions is a no-op
107a108
> #[cfg_attr(any(cls, nofeat), expect(ungated_async_fn_track_caller))]
109d109
< //[cls,nofeat]~^ WARN `#[track_caller]` on async functions is a no-op

Previously, these tests were testing the wrong feature gate,
and had unnecessary type errors.
This is done so that we can test whether the location used is at
the function call site or the await site.
@rustbot

rustbot commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

miri is developed in its own repository. If the Miri part of this change can be broken out, consider making this change to rust-lang/miri instead. However, if Miri needs adjusting for rustc changes, just ignore this message.

cc @rust-lang/miri

@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 Aug 29, 2026
@rustbot

rustbot commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

r? @ShoyuVanilla

rustbot has assigned @ShoyuVanilla.
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

Why was this reviewer chosen?

The reviewer was selected based on:

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

@rust-log-analyzer

This comment was marked as resolved.

@theemathas

This comment was marked as resolved.

@theemathas

This comment was marked as resolved.

@theemathas

Copy link
Copy Markdown
Contributor Author

Excluded the gcc backend from a test as per @antoyo's advice


//@ edition:2021
//@ revisions: afn cls afn_cls nofeat
//

@RalfJung RalfJung Aug 29, 2026

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.

Suggested change
//
//@ run-native

to ensure the line numbers are indeed correct according to regular rustc

View changes since the review

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants