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

Implement Option::replace in the core library #52003

Merged
merged 3 commits into from
Jul 13, 2018
Merged

Implement Option::replace in the core library #52003

merged 3 commits into from
Jul 13, 2018

Conversation

Kerollmops
Copy link
Contributor

Here is the implementation of the Option::replace method. The first step of the tracking issue #51998.

@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 @Kimundi (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 Jul 2, 2018
@Kerollmops Kerollmops changed the title Add a replace method to Option Implement Option::replace in the core library Jul 2, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 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.
[01:08:37] ....................................................................................................
[01:08:49] ....................................................................................................
[01:09:02] ....................................................................................................
[01:09:17] ....................................................................................................
[01:09:32] ......................................................................................F.............
[01:10:04] ....................................................................................................
[01:10:21] .......................i...............................................i.......................
[01:10:21] failures:
[01:10:21] 
[01:10:21] 
[01:10:21] ---- option.rs - option::Option<T>::replace (line 857) stdout ----
[01:10:21] error[E0658]: use of unstable library feature 'option_replace' (see issue #51998)
[01:10:21]  --> option.rs:859:13
[01:10:21]   |
[01:10:21] 5 | let old = x.replace(5);
[01:10:21]   |
[01:10:21]   |
[01:10:21]   = help: add #![feature(option_replace)] to the crate attributes to enable
[01:10:21] error[E0658]: use of unstable library feature 'option_replace' (see issue #51998)
[01:10:21]   --> option.rs:864:13
[01:10:21]    |
[01:10:21]    |
[01:10:21] 10 | let old = x.replace(3);
[01:10:21]    |
[01:10:21]    |
[01:10:21]    = help: add #![feature(option_replace)] to the crate attributes to enable
[01:10:21] thread 'option.rs - option::Option<T>::replace (line 857)' panicked at 'couldn't compile the test', librustdoc/test.rs:327:17
[01:10:21] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:10:21] 
[01:10:21] 
---
[01:10:21] 
[01:10:21] error: test failed, to rerun pass '--doc'
[01:10:21] 
[01:10:21] 
[01:10:21] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "core" "--" "--quiet"
[01:10:21] 
[01:10:21] 
[01:10:21] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:10:21] Build completed unsuccessfully in 0:30:49
[01:10:21] Build completed unsuccessfully in 0:30:49
[01:10:21] make: *** [check] Error 1
[01:10:21] Makefile:58: recipe for target 'check' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:003ca5cf
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:1069ff86:start=1530569463395771721,finish=1530569463403315532,duration=7543811
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:1da2b9fa
$ head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
head: cannot open ‘./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers’ for reading: No such file or directory
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0593cc28
$ 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)

@@ -122,6 +122,7 @@
#![feature(const_slice_len)]
#![feature(const_str_as_bytes)]
#![feature(const_str_len)]
#![feature(option_replace)]
Copy link
Contributor Author

@Kerollmops Kerollmops Jul 3, 2018

Choose a reason for hiding this comment

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

Is this mandatory ?

@bors
Copy link
Contributor

bors commented Jul 4, 2018

☔ The latest upstream changes (presumably #51395) made this pull request unmergeable. Please resolve the merge conflicts.

@Kerollmops
Copy link
Contributor Author

Kerollmops commented Jul 4, 2018

@Kimundi could you please give me feedback ? 😃

@pietroalbini
Copy link
Member

Ping from triage @Kimundi! This PR needs your review.

@Kimundi
Copy link
Member

Kimundi commented Jul 9, 2018

Alright, looks good so far! Could you add some basic unit tests for the method as well? Basically just something that replicates the doc example.


/// Replaces the actual value in the option by the value given in parameter,
/// returning the old value if present,
/// leaving a `Some` in its place without deinitializing either one.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooops.. And I forgot to add [] around Some.

@Kimundi
Copy link
Member

Kimundi commented Jul 12, 2018

@bors: r+

@bors
Copy link
Contributor

bors commented Jul 12, 2018

📌 Commit c8f0e6f has been approved by Kimundi

@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 Jul 12, 2018
@kennytm
Copy link
Member

kennytm commented Jul 12, 2018

@bors rollup

kennytm added a commit to kennytm/rust that referenced this pull request Jul 12, 2018
Implement `Option::replace` in the core library

Here is the implementation of the `Option::replace` method. The first step of [the tracking issue rust-lang#51998](rust-lang#51998).
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jul 13, 2018
Implement `Option::replace` in the core library

Here is the implementation of the `Option::replace` method. The first step of [the tracking issue rust-lang#51998](rust-lang#51998).
bors added a commit that referenced this pull request Jul 13, 2018
Rollup of 16 pull requests

Successful merges:

 - #51962 (Provide llvm-strip in llvm-tools component)
 - #52003 (Implement `Option::replace` in the core library)
 - #52156 (Update std::ascii::ASCIIExt deprecation notes)
 - #52242 (NLL: Suggest `ref mut` and `&mut self`)
 - #52244 (Don't display default generic parameters in diagnostics that compare types)
 - #52290 (Deny bare trait objects in src/librustc_save_analysis)
 - #52293 (Deny bare trait objects in librustc_typeck)
 - #52299 (Deny bare trait objects in src/libserialize)
 - #52300 (Deny bare trait objects in librustc_target and libtest)
 - #52302 (Deny bare trait objects in the rest of rust)
 - #52310 (Backport 1.27.1 release notes to master)
 - #52314 (Fix ICE when using a pointer cast as array size)
 - #52315 (Resolve FIXME(#27942))
 - #52316 (task: remove wrong comments about non-existent LocalWake trait)
 - #52322 (Update llvm-rebuild-trigger in light of LLVM 7 upgrade)
 - #52332 (dead-code lint: say "constructed", "called" for structs, functions)

Failed merges:

r? @ghost
kennytm added a commit to kennytm/rust that referenced this pull request Jul 13, 2018
Implement `Option::replace` in the core library

Here is the implementation of the `Option::replace` method. The first step of [the tracking issue rust-lang#51998](rust-lang#51998).
bors added a commit that referenced this pull request Jul 13, 2018
Rollup of 17 pull requests

Successful merges:

 - #51962 (Provide llvm-strip in llvm-tools component)
 - #52003 (Implement `Option::replace` in the core library)
 - #52156 (Update std::ascii::ASCIIExt deprecation notes)
 - #52280 (llvm-tools-preview: fix build-manifest)
 - #52290 (Deny bare trait objects in src/librustc_save_analysis)
 - #52293 (Deny bare trait objects in librustc_typeck)
 - #52299 (Deny bare trait objects in src/libserialize)
 - #52300 (Deny bare trait objects in librustc_target and libtest)
 - #52302 (Deny bare trait objects in the rest of rust)
 - #52310 (Backport 1.27.1 release notes to master)
 - #52315 (Resolve FIXME(#27942))
 - #52316 (task: remove wrong comments about non-existent LocalWake trait)
 - #52322 (Update llvm-rebuild-trigger in light of LLVM 7 upgrade)
 - #52330 (Don't silently ignore invalid data in target spec)
 - #52333 (CI: Enable core dump on Linux, and print their stack trace on segfault. )
 - #52346 (Fix typo in improper_ctypes suggestion)
 - #52350 (Bump bootstrap compiler to 1.28.0-beta.10)

Failed merges:

r? @ghost
@bors bors merged commit c8f0e6f into rust-lang:master Jul 13, 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.

6 participants