-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implement conversion traits for usize/isize together with a portability lint #70460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Some notable considerations and use case here (note: speaking for myself here, not for any team):
People have expressed the desire for checked
In addition, code that explicitly declares that it only works on a 64-bit target should be able to use |
I would be interested in picking this up. |
@joshtriplett IIU the portability lint RFC correctly, non-portable APIs must be linted no matter how rare the exception cases are, so we'd need to lint even, e.g., @c3st7n Looks like nobody else has spoken up so far, so it's all yours! |
On Mon, Apr 06, 2020 at 05:00:43PM -0700, Joshua Liebow-Feeser wrote:
@joshtriplett IIU the [portability lint RFC](https://github.com/rust-lang/rfcs/blob/master/text/1868-portability-lint.md) correctly, non-portable APIs must be linted no matter how rare the exception cases are, so we'd need to lint even, e.g., `impl From<u16> for usize`.
I'm arguing that that shouldn't necessarily be the case.
|
Pretty sure that'd need another RFC or at least some other kind of official approval process? |
@joshlf
The intent was to not warn by default on non-portability to rare platforms, #37423 also implemented the "portability to 16-bit targets" lint as allow-by-default. |
Huh TIL. Thanks for clarifying! |
I'm removing the nomination since I think T-lang doesn't have anything else to say, and I don't think @rust-lang/libs has any objections. @c3st7n, in terms of implementation work, do you know how to get started? |
@nikomatsakis I thought I did, my plan was to implement a macro like in @petrochenkov's original PR to add the impl from for each usize/uXX combination, with appropriate target_pointer_width cfg values. Where I am getting stuck/confused is the portability lint parts. I'm not sure if I am fully understanding them, is the best documentation the RFC (if so, this seems a little odd to me and I would expect something concrete in say the rust book or similar). The above thread refer to warning on different platforms and scenarios, but the way I read the portability lint RFC if I annotate a function with |
The portability lint has never been implemented. |
I think that probably means I would need a fair bit of help to understand this work or for it to be re-assigned. Happy to carry on if someone can give me some pointers. |
The portability lint in #37423 was different from what the RFC described. |
Ok, this is starting to make a lot more sense to me. I completely misunderstood the full scope of the task and thought there were already portability lints that existed but I was just failing to find/understand them. I will do some further reading and make sure I understand the original PR. |
PR #71360 proposes an alternative to this without a portability lint, using instead the same pattern as |
I haven't even tried working on this by the way because I am assuming from @SimonSapin comment that this will be made redundant. |
Looks like that attempt was abandoned: #71360 (comment) |
This PR was closed 3.5 years ago just prior to the development of the portability lint RFC. In light of the portability lint RFC having been accepted, we should be able to resurrect that PR.
This issue tracks that work. I've submitted it to TWiR's CFP.
The text was updated successfully, but these errors were encountered: