Skip to content

wtf8, char: Replace uses of mem::transmute with more specific functions #27233

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

Merged
merged 2 commits into from
Jul 25, 2015

Conversation

tbu-
Copy link
Contributor

@tbu- tbu- commented Jul 23, 2015

No description provided.

@rust-highfive
Copy link
Contributor

r? @pcwalton

(rust_highfive has picked a reviewer for you, use r? to override)

@pnkfelix
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 23, 2015

📌 Commit 0eb552a has been approved by pnkfelix

/// Converts a `u32` to an `char`, not checking whether it is a valid unicode
/// codepoint.
#[inline]
pub unsafe fn from_u32_unchecked(i: u32) -> char {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an explicit #[unstable] annotation to this function? It should have its own feature name as well.

@alexcrichton
Copy link
Member

@bors: r-

Just wanna make sure that new public API surface area is documented with #[unsafe] #[unstable]

@tamird
Copy link
Contributor

tamird commented Jul 23, 2015

s/unsafe/unstable/

@tbu-
Copy link
Contributor Author

tbu- commented Jul 23, 2015

@alexcrichton
Done.

/// Converts a `u32` to an `char`, not checking whether it is a valid unicode
/// codepoint.
#[inline]
#[unstable(feature = "char_from_unchecked")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a reason here along the lines of reason = "recently added API" ? Helps us keep track as to why it's unstable.

@tbu-
Copy link
Contributor Author

tbu- commented Jul 23, 2015

@alexcrichton
Added a reason.

@alexcrichton
Copy link
Member

@bors: r+ c2fca7c

@bors
Copy link
Collaborator

bors commented Jul 24, 2015

⌛ Testing commit c2fca7c with merge 948cfb9...

@bors
Copy link
Collaborator

bors commented Jul 24, 2015

💔 Test failed - auto-linux-32-nopt-t

@alexcrichton
Copy link
Member

@bors: retry

On Fri, Jul 24, 2015 at 7:17 AM, bors [email protected] wrote:

[image: 💔] Test failed - auto-linux-32-nopt-t
http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/5827


Reply to this email directly or view it on GitHub
#27233 (comment).

Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 24, 2015
@bors
Copy link
Collaborator

bors commented Jul 25, 2015

⌛ Testing commit c2fca7c with merge e4f0446...

bors added a commit that referenced this pull request Jul 25, 2015
@bors bors merged commit c2fca7c into rust-lang:master Jul 25, 2015
bors added a commit that referenced this pull request Aug 10, 2015
The replacements are functions that usually use a single `mem::transmute` in their body and restrict input and output via more concrete types than `T` and `U`. Worth noting are the `transmute` functions for slices and the `from_utf8*` family for mutable slices. Additionally, `mem::transmute` was often used for casting raw pointers, when you can already cast raw pointers just fine with `as`.

This builds upon #27233.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants