Skip to content
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

Linux: Clean up raw pointer casts #71

Merged
merged 4 commits into from May 13, 2016
Merged

Conversation

@antrik
Copy link
Contributor

antrik commented May 13, 2016

Various cleanups to make raw pointer casts simpler and more consistent.

antrik added 4 commits May 13, 2016
The intermediate cast to `*mut _` is completely useless here: the input
is already a `*mut`.
The idea here presumably was for the first cast just to turn the `*mut`
into a `*const`, without changing the targe type; however, the input
actually was not `u8` to begin with -- so this was actually casting to a
completely bogus interediate type...
For casts that only change a reference into a raw pointer, or change
between `*const` and `*mut`, always use `_` instead of a full type, to
make it clear that the target type doesn't change.
While it might have been necessary at some point in the cast between
`*mut` and `*const` in a separate step from casting between different
target types, it is definitely not needed with current Rust.

One might argue that doing it in a separate step makes the change more
explicit. However, in some cases it's obvious anyway (when the source is
`.as_ptr()` or `.as_mut_prt()`) -- and even where it's not quite as
obvious, it's not clear at all that the unnecessary extra step isn't
actually adding more confusion...
@mbrubeck
Copy link

mbrubeck commented May 13, 2016

@bors-servo
Copy link
Contributor

bors-servo commented May 13, 2016

📌 Commit 07ac214 has been approved by mbrubeck

@bors-servo
Copy link
Contributor

bors-servo commented May 13, 2016

Testing commit 07ac214 with merge 8c55262...

bors-servo added a commit that referenced this pull request May 13, 2016
Linux: Clean up raw pointer casts

Various cleanups to make raw pointer casts simpler and more consistent.
@bors-servo
Copy link
Contributor

bors-servo commented May 13, 2016

☀️ Test successful - travis

@bors-servo bors-servo merged commit 07ac214 into servo:master May 13, 2016
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.