-
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
box: Add documentation for From
impls
#55470
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
src/liballoc/boxed.rs
Outdated
@@ -455,6 +470,19 @@ impl<T> From<Box<T>> for Pin<Box<T>> { | |||
|
|||
#[stable(feature = "box_from_slice", since = "1.17.0")] | |||
impl<'a, T: Copy> From<&'a [T]> for Box<[T]> { | |||
/// Converts a `&[T]` into a `Box<[T]>` | |||
/// | |||
/// This conversion does not allocate on the heap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one (and therefore From<&str>
) allocates a RawVec
.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Thanks! Looks like CI may be showing a typo remaining in a doc comment? |
Ping from triage @daniellimws: It looks like some changes are necessary to this PR. |
I'm not really sure what went wrong. CI says there's an error with llvm but all that happens in this PR is documentation. |
The documentation examples are tested and I think one of the examples adder here failed compilation (output in the full logs) |
@daniellimws Do you think you'll have a chance to look at the failure on CI soon? I've pulled it out from the logs:
|
Really sorry about the hold up. |
Errors from IMAGE=x86_64-gnu-llvm-5.0 job: failures:
---- boxed.rs - boxed::Box<[T]>::from (line 480) stdout ----
error[E0283]: type annotations required: cannot resolve `std::boxed::Box<_>: std::convert::From<&[u8]>`
--> boxed.rs:483:19
|
6 | let boxed_slice = Box::from(slice);
| ^^^^^^^^^
|
= note: required by `std::convert::From::from`
thread 'boxed.rs - boxed::Box<[T]>::from (line 480)' panicked at 'couldn't compile the test', librustdoc/test.rs:323:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failures:
boxed.rs - boxed::Box<[T]>::from (line 480)
test result: FAILED. 408 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out
error: test failed, to rerun pass '--doc' |
Ping from triage @daniellimws: It looks like your PR failed on travis because one of the added examples fails to compile. (If you don't want to rely on travis / run the tests locally, you should be able to test the individual examples on play.rust-lang.org). |
Ping from triage @daniellimws: Do you think you'll be able to update your PR? |
Tests passed so I think we can land this for now. @bors r+ rollup |
📌 Commit 5e2bfda has been approved by |
box: Add documentation for `From` impls This is a part of rust-lang#51430. A brief description of the behaviour and examples are added to the documentation. I am not sure what sort of examples to put for the `From` for `Pin` as my [code](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=97c908f44e41c9faeffec5b61d72a03e) doesn't even manage to compile using the nightly build. Somehow I feel that I missed out something so do let me know if more information is needed in the documentation or any of the examples require change.
Rollup of 10 pull requests Successful merges: - #55470 (box: Add documentation for `From` impls) - #56242 (Add missing link in docs) - #56944 (bootstrap: Link LLVM as a dylib with ThinLTO) - #56978 (Add `std::os::fortanix_sgx` module) - #56985 (Allow testing pointers for inboundedness while forbidding dangling pointers) - #56986 (rustc: Move jemalloc from rustc_driver to rustc) - #57010 (Actually run compiletest tests on CI) - #57021 (Enable emission of alignment attrs for pointer params) - #57074 (Fix recursion limits) - #57085 (librustc_codegen_llvm: Don't eliminate empty structs in C ABI on linux-sparc64) Failed merges: r? @ghost
This is a part of #51430. A brief description of the behaviour and examples are added to the documentation.
I am not sure what sort of examples to put for the
From
forPin
as my code doesn't even manage to compile using the nightly build.Somehow I feel that I missed out something so do let me know if more information is needed in the documentation or any of the examples require change.