-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Replace trivial casts with type ascription #23542
Comments
Do you have some examples of where this occurs in the source? I can take a look at this. |
Not yet, I haven't landed the patch :-) We haven't landed type ascription either yet, so its not possible to do this yet. Once the two have landed (I'll try to ping this issue when they do), you can grep for |
Oh, oops, looks like I didn't read the issue closely enough :). I'll sit tight for now and revisit this when it's ready. |
(Blocked by #23416 then, I guess.) |
Not easy, type ascription hasn't landed yet 😄 |
Type ascription has now landed, so it might be possible to start this (although type ascription does not yet cause coercion, so maybe it can't be just yet). Here are all the uses of trivial_casts in any case: https://dxr.mozilla.org/rust/search?q=trivial_casts&redirect=true&case=true |
It feels like based on the following we don't really use trivial casts in the compiler based on the lint allows, though there are a few instances of trivial numeric casts. I've provided a list below of what I could find as of now with a simple grep. I'm uncertain as to whether it's possible to use type ascription already, but I feel like the answer is possibly no.
|
Type ascription is a nightly-only feature, right? |
Yes, it is. The tracking issue is #23416. |
I'm going to close this as type ascription to me isn't yet ready and won't be for a while; it also doesn't really seem like they kind of cleanup that's super helpful. |
There are a bunch of places in the libs and compiler where we use a trivial case where type ascription would be more appropriate. These currently require
#![allow(trivial_casts)]
. Without that we get a warning (and an error when bootstrapping). When type ascription lands these should be converted to use that. E.g.,*self as *const T
should become*self: *const T
.The text was updated successfully, but these errors were encountered: