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

Add From<bool> for int types #50554

Merged
merged 3 commits into from
Jun 2, 2018
Merged

Add From<bool> for int types #50554

merged 3 commits into from
Jun 2, 2018

Conversation

clarfonthey
Copy link
Contributor

Fixes #46109.

@rust-highfive
Copy link
Collaborator

r? @TimNN

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 9, 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:11:39]    Compiling core v0.0.0 (file:///checkout/src/libcore)
[01:11:53] error[E0282]: type annotations needed
[01:11:53]    --> libcore/../libcore/tests/result.rs:223:19
[01:11:53]     |
[01:11:53] 223 |         let val = Ok(1)?;
[01:11:53]     |                   ^^^^^^ cannot infer type for `_`
[01:11:54] error: aborting due to previous error
[01:11:54] 
[01:11:54] For more information about this error, try `rustc --explain E0282`.
[01:11:54] error: Could not compile `core`.
[01:11:54] error: Could not compile `core`.
[01:11:54] 
[01:11:54] To learn more, run the command again with --verbose.
[01:11:54] 
[01:11:54] 
[01:11:54] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "core" "--" "--quiet"
[01:11:54] 
[01:11:54] 
[01:11:54] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:11:54] Build completed unsuccessfully in 0:28:38
[01:11:54] Build completed unsuccessfully in 0:28:38
[01:11:54] Makefile:58: recipe for target 'check' failed
[01:11:54] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0ebdfa38
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@clarfonthey
Copy link
Contributor Author

Actually, apparently this causes inference issues. That should probably be investigated before this is merged.

Copy link
Contributor

@KamilaBorowska KamilaBorowska left a comment

Choose a reason for hiding this comment

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

fn try_result_ok() -> Result<u8, u8> {
    let val = Ok(1)?;
    Ok(val)
}

Ok(x)? for Result<_, u8> (as well as variations like return Err(u8::from(unimplemented!()));) sound like an edge case for me - I don't think realistically anyone would write code like this. This can be written as x, and I think this inference failure is not a practical issue. The test here could be changed to use a type other than u8, for example fn try_result_ok() -> Result<u8, bool>.

Additionally, according to https://github.com/rust-lang/rfcs/blob/master/text/1105-api-evolution.md, this would be a minor change.

@TimNN
Copy link
Contributor

TimNN commented May 14, 2018

cc @rust-lang/libs: This has the potential to be inference-breaking. What do you think? Does this need a crater run?

@SimonSapin

This comment has been minimized.

@therealprof
Copy link
Contributor

@SimonSapin The motivation for this is automatically generated code by svd2rust. Ideally we would like to use From for all types but that doesn't work for bool so we have to use as instead which generates a lot of noise. There alternative would be to special case per type which is also not desirable.

@clarfonthey
Copy link
Contributor Author

Also, the main purpose of the lint is that in general, From should be used when the conversion is lossless, as as allows lossy conversions. This helps in macros and other places to ensure that only lossless conversions occur.

@alexcrichton
Copy link
Member

Yeah I think it wouldn't hurt to get a crater run for this.

cc @rust-lang/infra, mind scheduling a crater run here?

@alexcrichton alexcrichton added the S-waiting-on-crater Status: Waiting on a crater run to be completed. label May 14, 2018
@kennytm
Copy link
Member

kennytm commented May 14, 2018

@bors try

@bors
Copy link
Contributor

bors commented May 14, 2018

⌛ Trying commit a882197034b9b3eafb5e35c3f010d21fca0e0df4 with merge 4b647638d12b7679c1eee120c4c064bc749eb782...

@bors
Copy link
Contributor

bors commented May 14, 2018

☀️ Test successful - status-travis
State: approved= try=True

@TimNN TimNN removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 15, 2018
@Mark-Simulacrum
Copy link
Member

Check-only crater run started.

@pietroalbini
Copy link
Member

Hi @alexcrichton (crater requester), @TimNN (PR reviewer)! Crater results are at: http://cargobomb-reports.s3.amazonaws.com/pr-50554/index.html. 'Blacklisted' crates (spurious failures etc) can be found here. If you see any spurious failures not on the list, please make a PR against that file.

(interested observers: Crater is a tool for testing the impact of changes on the crates.io ecosystem. You can find out more at the repo if you're curious)

@pietroalbini
Copy link
Member

And both of the regressions are spurious \o/.

@pietroalbini pietroalbini added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels May 19, 2018
@TimNN
Copy link
Contributor

TimNN commented May 19, 2018

This looks good to go, @clarcharr can you fix the travis failure?

Also cc @rust-lang/libs, I will approve this unless you have any objections. I overlooked that since the impls are insta-stable this should go through an FCP.

@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 May 19, 2018
@kennytm kennytm added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label May 19, 2018
@scottmcm
Copy link
Member

Since adding impls is a stabilization, doesn't this need an FCP?

@clarfonthey
Copy link
Contributor Author

@TimNN Will do! Although I agree with @scottmcm that this needs an FCP.

@bors
Copy link
Contributor

bors commented May 30, 2018

🔒 Merge conflict

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 30, 2018
@rfcbot
Copy link

rfcbot commented May 31, 2018

The final comment period, with a disposition to merge, as per the review above, is now complete.

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels May 31, 2018
@clarfonthey
Copy link
Contributor Author

I rebased but there weren't actually any merge conflicts.

@TimNN
Copy link
Contributor

TimNN commented Jun 2, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Jun 2, 2018

📌 Commit b1797d5 has been approved by TimNN

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 2, 2018
@bors
Copy link
Contributor

bors commented Jun 2, 2018

⌛ Testing commit b1797d5 with merge 4a9bf7c...

bors added a commit that referenced this pull request Jun 2, 2018
Add From<bool> for int types

Fixes #46109.
@bors
Copy link
Contributor

bors commented Jun 2, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 2, 2018
@rust-highfive
Copy link
Collaborator

The job dist-x86_64-netbsd 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.
  0     0    0     0    0     0      0      0 --:--:--  0:00:15 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:16 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:17 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:18 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:19 --:--:--     0curl: (6) Could not resolve host: s3-us-west-1.amazonaws.com
[01:13:28] thread 'main' panicked at 'failed to download openssl source: exit code: 6', bootstrap/native.rs:575:17
[01:13:28] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap dist --host x86_64-unknown-netbsd --target x86_64-unknown-netbsd
[01:13:28] Build completed unsuccessfully in 1:09:53
travis_time:end:08518c12:start=1527916642471126256,finish=1527921051331467157,duration=4408860340901

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)

1 similar comment
@rust-highfive
Copy link
Collaborator

The job dist-x86_64-netbsd 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.
  0     0    0     0    0     0      0      0 --:--:--  0:00:15 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:16 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:17 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:18 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:19 --:--:--     0curl: (6) Could not resolve host: s3-us-west-1.amazonaws.com
[01:13:28] thread 'main' panicked at 'failed to download openssl source: exit code: 6', bootstrap/native.rs:575:17
[01:13:28] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap dist --host x86_64-unknown-netbsd --target x86_64-unknown-netbsd
[01:13:28] Build completed unsuccessfully in 1:09:53
travis_time:end:08518c12:start=1527916642471126256,finish=1527921051331467157,duration=4408860340901

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)

@kennytm
Copy link
Member

kennytm commented Jun 2, 2018

@bors retry #40474

@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 Jun 2, 2018
@bors
Copy link
Contributor

bors commented Jun 2, 2018

⌛ Testing commit b1797d5 with merge 2954cb5...

bors added a commit that referenced this pull request Jun 2, 2018
Add From<bool> for int types

Fixes #46109.
@bors
Copy link
Contributor

bors commented Jun 2, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: TimNN
Pushing 2954cb5 to master...

@bors bors merged commit b1797d5 into rust-lang:master Jun 2, 2018
@clarfonthey clarfonthey deleted the from_bool branch June 22, 2018 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.