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

box: Add documentation for From impls #55470

Merged
merged 4 commits into from
Dec 24, 2018
Merged

box: Add documentation for From impls #55470

merged 4 commits into from
Dec 24, 2018

Conversation

daniellimws
Copy link
Contributor

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 for Pin 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.

@rust-highfive
Copy link
Collaborator

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 29, 2018
@@ -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
Copy link
Contributor

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.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:02cd6382:start=1540813194435776745,finish=1540813249675946409,duration=55240169664
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
---
[00:51:40] .................................................................................................... 2200/4977
[00:51:44] .................................................................................................... 2300/4977
[00:51:48] .................................................................................................... 2400/4977
[00:51:52] .................................................................................................... 2500/4977
[00:51:55] .............................................................iiiiiiiii.............................. 2600/4977
[00:52:02] ............ii...................................................................................... 2800/4977
[00:52:05] .................................................................................................... 2900/4977
[00:52:09] .................................................................................................... 3000/4977
[00:52:11] .......i............................................................................................ 3100/4977
---
travis_time:start:test_codegen
Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:05:24] 
[01:05:24] running 112 tests
[01:05:27] i..ii...iii.......i...i.........i..iii...........i.....i.....ii...i..i.ii..............i...ii..ii.i. 100/112
[01:05:28] test result: ok. 82 passed; 0 failed; 30 ignored; 0 measured; 0 filtered out
[01:05:28] 
[01:05:28]  finished in 3.551
[01:05:28] travis_fold:end:test_codegen
---
[01:16:01] error: no global memory allocator found but one is required; link to std or add #[global_allocator] to a static item that implements the GlobalAlloc trait.
[01:16:01] 
[01:16:01] 
[01:16:01] running 407 tests
[01:16:22] .....................F.............................................................................. 100/407
[01:16:55] .................................................................................................... 300/407
[01:17:11] .................................................................................................... 400/407
rustlib
72800 ./obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu
---
39608 ./obj/build/x86_64-unknown-linux-gnu/doc/book
39016 ./obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps
38040 ./obj/build/x86_64-unknown-linux-gnu/test/ui/issues
37756 ./src/tools/lldb/www
37532 . travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1a242b7c
travis_time:start:1a242b7c
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:01ea6fe6
$ dmesg | grep -i kill

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 @TimNN. (Feature Requests)

@alexcrichton
Copy link
Member

Thanks! Looks like CI may be showing a typo remaining in a doc comment?

@TimNN TimNN added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 6, 2018
@TimNN
Copy link
Contributor

TimNN commented Nov 6, 2018

Ping from triage @daniellimws: It looks like some changes are necessary to this PR.

@daniellimws
Copy link
Contributor Author

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.

@alexcrichton
Copy link
Member

The documentation examples are tested and I think one of the examples adder here failed compilation (output in the full logs)

@Mark-Simulacrum
Copy link
Member

@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:

01:17:12] failures:
[01:17:12] 
[01:17:12] ---- boxed.rs - boxed::Box<[T]>::from (line 479) stdout ----
[01:17:12] error: expected expression, found `:`
[01:17:12]  --> boxed.rs:484:11
[01:17:12]   |
[01:17:12] 8 | println!({:?}, boxed_slice);
[01:17:12]   |           ^ expected expression
[01:17:12] 
[01:17:12] error: format argument must be a string literal
[01:17:12]  --> boxed.rs:484:10
[01:17:12]   |
[01:17:12] 8 | println!({:?}, boxed_slice);
[01:17:12]   |          ^^^^
[01:17:12] help: you might be missing a string literal to format with
[01:17:12]   |
[01:17:12] 8 | println!("{} {}", {:?}, boxed_slice);
[01:17:12]   |          ^^^^^^^^
[01:17:12] 
[01:17:12] thread 'boxed.rs - boxed::Box<[T]>::from (line 479)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13
[01:17:12] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:17:12] 
[01:17:12] 
[01:17:12] failures:
[01:17:12]     boxed.rs - boxed::Box<[T]>::from (line 479)
[01:17:12] 

@daniellimws
Copy link
Contributor Author

Really sorry about the hold up.

@Dylan-DPC-zz
Copy link

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'

@TimNN
Copy link
Contributor

TimNN commented Nov 27, 2018

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).

@TimNN
Copy link
Contributor

TimNN commented Dec 4, 2018

Ping from triage @daniellimws: Do you think you'll be able to update your PR?

@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 5, 2018
@Centril
Copy link
Contributor

Centril commented Dec 24, 2018

Tests passed so I think we can land this for now.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 24, 2018

📌 Commit 5e2bfda has been approved by Centril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 24, 2018
Centril added a commit to Centril/rust that referenced this pull request Dec 24, 2018
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.
bors added a commit that referenced this pull request Dec 24, 2018
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
@bors bors merged commit 5e2bfda into rust-lang:master Dec 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants