Skip to content

polish: add #[track_caller] to functions that can panic #4413

Closed
@carllerche

Description

@carllerche

Our current MSRV is 1.46, which introduced track_caller which can be used to make panic messages better.

We should ensure that all methods that can panic when misused are annotated with #[track_caller] so the panic message includes the file/line where the user called the Tokio method instead of showing the file/line inside the Tokio source. If the panic is a few calls deep in Tokio, then I believe each internal method needs its own #[track_caller]

One example where this should be done: Handle::current(), but there probably are others.

Ideally, we also add tests that verify the behavior.

Metadata

Metadata

Assignees

Labels

A-tokioArea: The main tokio crateC-feature-requestCategory: A feature request.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions