-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Do not use as
to convert reference to pointer
#3305
Comments
we can't remember what we were doing where it broke inference... we're struggling to figure out a test case which demonstrates it tho. sorry about that. |
(ps: we believe this example to be unsound, specifically due to the |
Following up on this as we’re prepping for the 2024 Edition update to the book—I honestly am having a hard time figuring out from that code exactly what the issue is—I don’t see type inference issues when I try to build it. Do you have some code which exercises it which does show the issue? |
deprecating |
Those may all be true, but it’s not clear to me from merely those assertions how a reader of the book should think about them in Rust today, where |
ah, yeah... personally we'd rather pretend as if |
main
branch to see if this has already been fixedURL to the section(s) of the book with this problem:
https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html#dereferencing-a-raw-pointer
Description of the problem:
This uses
as
to convert the reference to a pointer. We've ran into issues in the past withas
, e.g. RustyYato/cell-project#4. Specifically, it breaks inference in a bad way.Suggested fix:
Use type ascription instead of
as
, e.g.let r1: *const i32
.The text was updated successfully, but these errors were encountered: