Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add fixme note
  • Loading branch information
nbdd0121 committed Dec 5, 2022
commit 34c377335bc6b855722eb1f4a0866de29af0f2c9
2 changes: 2 additions & 0 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,8 @@ impl<'hir> LoweringContext<'_, 'hir> {

let async_body = this.make_async_expr(
Copy link
Member

Choose a reason for hiding this comment

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

Async closures should probably also support #[track_caller]

Copy link
Member Author

@nbdd0121 nbdd0121 Dec 2, 2022

Choose a reason for hiding this comment

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

It currently doesn't, so that's why I haven't changed it in this PR.

It isn't difficult change to make, but it does require lifting the attribute lowering up from after ExprKind lowering to before it. Do you happen to know why we currently lower ID and attributes after ExprKind?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think there's a particular reason why we do it -- it shouldn't matter to change the lowering order. I guess if you're not keen to make the change, can you at least add a FIXME? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Added. I then changed Option<HirId> to HirId to simplify code. We don't need to special case async blocks as #[track_caller] is not legal on async block. But I added a test anyway to avoid accidentally allow this on normal async block.

Copy link
Member Author

Choose a reason for hiding this comment

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

I know the reason now, because paren expr is special 😅

PTAL

Copy link
Member

Choose a reason for hiding this comment

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

Given the incremental issues, maybe we can revert the last change and go with Option<HirId>? Or are those test failures unrelated to the last change?

capture_clause,
// FIXME(nbdd0121): This should also use a proper HIR id so `#[track_caller]`
// can be applied on async closures as well.
None,
inner_closure_id,
async_ret_ty,
Expand Down