You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've found myself somewhat frequently disabling the needless_lifetimes lint for functions that are, or contain, unsafe, primarily because I felt like it was better to be explicit in those case. (One example: more limited wrappers around pointer casts / transmutes).
IMO, given that unsafe can be used to circumvent the borrow checker, eliding the lifetimes increases complexity, since it's one more thing that authors and reviewers have to pay attention to (because they can't rely on the compiler to catch incorrect lifetimes / elision).
I don't know if such an exception would be too broad, but I believe that if a function is, or contains, unsafe, there's a high likelihood of explicit lifetimes being intentional.
And, maybe more importantly, getting the elision wrong can have more serious consequences, see e.g. #9360.
(Nothing prevents authors from eliding the lifetimes on their own (i.e. I'm not advocating for an "use explicit lifetimes with unsafe" lint), but I don't think Clippy should suggest removing explicit lifetimes from these functions if they are present).
Version
No response
Additional Labels
No response
The text was updated successfully, but these errors were encountered:
Description
I've found myself somewhat frequently disabling the
needless_lifetimes
lint for functions that are, or contain,unsafe
, primarily because I felt like it was better to be explicit in those case. (One example: more limited wrappers around pointer casts / transmutes).IMO, given that
unsafe
can be used to circumvent the borrow checker, eliding the lifetimes increases complexity, since it's one more thing that authors and reviewers have to pay attention to (because they can't rely on the compiler to catch incorrect lifetimes / elision).I don't know if such an exception would be too broad, but I believe that if a function is, or contains,
unsafe
, there's a high likelihood of explicit lifetimes being intentional.And, maybe more importantly, getting the elision wrong can have more serious consequences, see e.g. #9360.
(Nothing prevents authors from eliding the lifetimes on their own (i.e. I'm not advocating for an "use explicit lifetimes with
unsafe
" lint), but I don't think Clippy should suggest removing explicit lifetimes from these functions if they are present).Version
No response
Additional Labels
No response
The text was updated successfully, but these errors were encountered: