Skip to content

Many functions with rustc_inherit_overflow_checks should also have track_caller #119682

Closed
@NCGThompson

Description

@NCGThompson

In general, if a library function panics due to invalid input, its best if the error message point to the function call and explain why the input was invalid. An overflow in a core library function with the #[rustc_inherit_overflow_checks] attribute is probably due to invalid input.

Assuming a function could only panic due to incorrect input, the only potential drawback to #[track_caller] I can see is the panic message not adequately explaining why the input was invalid. Until we get #111466, we can only pass the text of the overflow error. For div_euclid*, this is perfect. For next_multiple_of, this is sufficient. For advance_by, I'm not sure.

Adding the attribute is trivial. I'm only making this issue to ask if/what functions I should add the attribute to and if I need to.

See also: #102024 #114841

* Edit: The division function might be a confusing example since it doesn't care about #[rustc_inherit_overflow_checks]. However, it should have #[track_caller] like the others.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.T-libsRelevant to the library team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions