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

std: Remove the as_utf16_p functions #14611

Closed
wants to merge 1 commit into from

Conversation

alexcrichton
Copy link
Member

These functions are all much better expressed via RAII using the to_utf16()
method on strings. This refactoring also takes this opportunity to properly
handle when filenames aren't valid unicode when passed through to the windows
I/O layer by properly returning I/O errors.

All previous users of the as_utf16_p or as_utf16_mut_p functions will need
to convert their code to using foo.to_utf16().append_one(0) to get a
null-terminated utf16 string.

[breaking-change]

@huonw
Copy link
Member

huonw commented Jun 2, 2014

FWIW, to_utf16 is likely to disappear (becoming an iterator) soon: #14358.

(@schmee showed me a good implementation on IRC... just waiting for the PR. :) )

@alexcrichton
Copy link
Member Author

Hm, that would definitely influence this design, but not by a huge amount though. I think that I'd replace as_utf16_* in os::win32 with to_utf16 which would be a wrapper around that (and push the 0 on the end which is easy to forget).

If to_utf16 is going away then this may want to wait for that PR to go through first (it's probably more important than this)

@schmee schmee mentioned this pull request Jun 2, 2014
@schmee
Copy link
Contributor

schmee commented Jun 2, 2014

@huonw It's not 100% done yet, but I went ahead and submitted a PR :)

@alexcrichton
Copy link
Member Author

ping r? I think that this change can be done independently of adding a utf16 iterator (it would just change a few spots).

These functions are all much better expressed via RAII using the to_utf16()
method on strings. This refactoring also takes this opportunity to properly
handle when filenames aren't valid unicode when passed through to the windows
I/O layer by properly returning I/O errors.

All previous users of the `as_utf16_p` or `as_utf16_mut_p` functions will need
to convert their code to using `foo.to_utf16().append_one(0)` to get a
null-terminated utf16 string.

[breaking-change]
bors added a commit that referenced this pull request Jun 10, 2014
Closes #14611 (std: Remove the as_utf16_p functions)
Closes #14694 (Num cleanup)
Closes #14760 (Add --color to test binary options)
Closes #14763 (std: Move dynamic_lib from std::unstable to std)
Closes #14766 (Add test for issue #13446)
Closes #14769 (collections: Add missing Default impls)
Closes #14773 (General nits)
Closes #14776 (rustdoc: Correctly classify enums/typedefs)
@bors bors closed this in #14783 Jun 10, 2014
@alexcrichton alexcrichton deleted the no-more-utf16 branch June 10, 2014 06:40
bors added a commit that referenced this pull request Jun 17, 2014
Closes #14358.

The tests are not yet moved to `utf16_iter`, so this probably won't compile. I'm submitting this PR anyway so it can be reviewed and since it was mentioned in #14611.

This deprecates `.to_utf16`. `x.to_utf16()` should be replaced by either `x.utf16_iter().collect::<Vec<u16>>()` (the type annotation may be optional), or just `x.utf16_iter()` directly, if it can be used in an iterator context.

[breaking-change]

cc @huonw
bors added a commit that referenced this pull request Jun 30, 2014
Closes #14358.

~~The tests are not yet moved to `utf16_iter`, so this probably won't compile. I'm submitting this PR anyway so it can be reviewed and since it was mentioned in #14611.~~ EDIT: Tests now use `utf16_iter`.

This deprecates `.to_utf16`. `x.to_utf16()` should be replaced by either `x.utf16_iter().collect::<Vec<u16>>()` (the type annotation may be optional), or just `x.utf16_iter()` directly, if it can be used in an iterator context.

[breaking-change]

cc @huonw
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 5, 2023
…ments, r=Veykril

mbe: fix token conversion for doc comments

fixes rust-lang#14611

when creating token trees for the converted doc comment, we should use the correct span in all places, rather than allowing some to remain unspecified. otherwise, things behave incorrectly.
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.

4 participants