-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Many functions with rustc_inherit_overflow_checks should also have track_caller #119682
Copy link
Copy link
Closed
Closed
Copy link
Labels
C-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant 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.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
C-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant 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.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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. Fordiv_euclid*, this is perfect. Fornext_multiple_of, this is sufficient. Foradvance_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.