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

When needing type annotations in local bindings, account for impl Trait and closures #63507

Merged
merged 7 commits into from Aug 15, 2019

Conversation

@estebank
Copy link
Contributor

commented Aug 13, 2019

Fix #46680, fix #63504, fix #63506, fix #40014, cc #63502.

estebank added some commits Aug 12, 2019

When needing type annotations in local bindings, account for impl Tra…
…it and closures

Do not suggest nonsensical types when the type inference is failing on
`impl Trait` or anonymous closures.
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Aug 13, 2019

r? @eddyb

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

@estebank

This comment has been minimized.

Copy link
Contributor Author

commented Aug 13, 2019

@rust-highfive rust-highfive assigned Centril and unassigned eddyb Aug 13, 2019

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

commented Aug 13, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (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.
2019-08-13T01:16:12.1990779Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-08-13T01:16:12.2155721Z ##[command]git config gc.auto 0
2019-08-13T01:16:12.2220564Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-08-13T01:16:12.2264214Z ##[command]git config --get-all http.proxy
2019-08-13T01:16:12.2395281Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63507/merge:refs/remotes/pull/63507/merge
---
2019-08-13T01:16:47.0209373Z do so (now or later) by using -b with the checkout command again. Example:
2019-08-13T01:16:47.0209401Z 
2019-08-13T01:16:47.0209796Z   git checkout -b <new-branch-name>
2019-08-13T01:16:47.0209952Z 
2019-08-13T01:16:47.0210209Z HEAD is now at db97a1328 Merge 3b6d46c6404cbb076ac07c568c6c4eb6d370994e into 60960a260f7b5c695fd0717311d72ce62dd4eb43
2019-08-13T01:16:47.0369013Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-08-13T01:16:47.0371521Z ==============================================================================
2019-08-13T01:16:47.0371568Z Task         : Bash
2019-08-13T01:16:47.0371603Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-08-13T01:22:13.1281226Z    Compiling serde_json v1.0.40
2019-08-13T01:22:17.1660964Z    Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
2019-08-13T01:22:25.3706007Z     Finished release [optimized] target(s) in 1m 24s
2019-08-13T01:22:25.3771741Z tidy check
2019-08-13T01:22:25.9522438Z tidy error: /checkout/src/test/ui/inference/cannot-infer-async-enabled-impl-trait-bindings.rs:8: trailing whitespace
2019-08-13T01:22:25.9523089Z tidy error: /checkout/src/test/ui/inference/cannot-infer-async-enabled-impl-trait-bindings.rs:15: trailing whitespace
2019-08-13T01:22:25.9523443Z tidy error: /checkout/src/test/ui/inference/cannot-infer-async.rs:6: trailing whitespace
2019-08-13T01:22:25.9523680Z tidy error: /checkout/src/test/ui/inference/cannot-infer-async.rs:13: trailing whitespace
2019-08-13T01:22:27.1280016Z some tidy checks failed
2019-08-13T01:22:27.1288880Z 
2019-08-13T01:22:27.1288880Z 
2019-08-13T01:22:27.1289770Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor"
2019-08-13T01:22:27.1289943Z 
2019-08-13T01:22:27.1289971Z 
2019-08-13T01:22:27.1294108Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
2019-08-13T01:22:27.1294223Z Build completed unsuccessfully in 0:01:26
2019-08-13T01:22:27.1294223Z Build completed unsuccessfully in 0:01:26
2019-08-13T01:22:28.4830165Z ##[error]Bash exited with code '1'.
2019-08-13T01:22:28.4860352Z ##[section]Starting: Checkout
2019-08-13T01:22:28.4861970Z ==============================================================================
2019-08-13T01:22:28.4862014Z Task         : Get sources
2019-08-13T01:22:28.4862049Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

commented Aug 13, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (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.
2019-08-13T01:43:01.8221555Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-08-13T01:43:01.8406297Z ##[command]git config gc.auto 0
2019-08-13T01:43:01.8482912Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-08-13T01:43:01.8548186Z ##[command]git config --get-all http.proxy
2019-08-13T01:43:01.8693185Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63507/merge:refs/remotes/pull/63507/merge
---
2019-08-13T01:43:40.6829195Z do so (now or later) by using -b with the checkout command again. Example:
2019-08-13T01:43:40.6829264Z 
2019-08-13T01:43:40.6829802Z   git checkout -b <new-branch-name>
2019-08-13T01:43:40.6829953Z 
2019-08-13T01:43:40.6830284Z HEAD is now at 404f22e9c Merge c96135e642349e5ece7a550e8b80de320585cda0 into 60960a260f7b5c695fd0717311d72ce62dd4eb43
2019-08-13T01:43:40.6996123Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-08-13T01:43:40.6999076Z ==============================================================================
2019-08-13T01:43:40.6999127Z Task         : Bash
2019-08-13T01:43:40.6999188Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-08-13T02:18:17.7698711Z    Compiling syntax_pos v0.0.0 (/checkout/src/libsyntax_pos)
2019-08-13T02:18:23.0062950Z    Compiling rustc_errors v0.0.0 (/checkout/src/librustc_errors)
2019-08-13T02:18:42.4437244Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2019-08-13T02:20:17.5064612Z    Compiling syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
2019-08-13T02:21:05.5748567Z error: usage of `ty::TyKind::<kind>`
2019-08-13T02:21:05.5749002Z    --> src/librustc/infer/error_reporting/need_type_info.rs:178:33
2019-08-13T02:21:05.5749402Z     |
2019-08-13T02:21:05.5778752Z 178 |             Some(ty::TyS { sty: ty::TyKind::Closure(def_id, substs), .. }) => {
2019-08-13T02:21:05.5779215Z     |                                 ^^^^^^^^^^ help: try using ty::<kind> directly: `ty`
2019-08-13T02:21:05.5779516Z     |
2019-08-13T02:21:05.5779851Z     = note: `-D rustc::usage-of-ty-tykind` implied by `-D rustc::internal`
2019-08-13T02:21:06.6584023Z error: aborting due to previous error
2019-08-13T02:21:06.6584134Z 
2019-08-13T02:21:07.0971692Z error: Could not compile `rustc`.
2019-08-13T02:21:07.0972044Z warning: build failed, waiting for other jobs to finish...
2019-08-13T02:21:07.0972044Z warning: build failed, waiting for other jobs to finish...
2019-08-13T02:21:10.6068212Z error: build failed
2019-08-13T02:21:10.6096564Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "2" "--release" "--locked" "--color" "always" "--features" "" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
2019-08-13T02:21:10.6097006Z expected success, got: exit code: 101
2019-08-13T02:21:10.6109350Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-08-13T02:21:10.6109425Z Build completed unsuccessfully in 0:30:47
2019-08-13T02:21:11.3141856Z ##[error]Bash exited with code '1'.
2019-08-13T02:21:11.3195400Z ##[section]Starting: Checkout
2019-08-13T02:21:11.3197813Z ==============================================================================
2019-08-13T02:21:11.3197875Z Task         : Get sources
2019-08-13T02:21:11.3197927Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

estebank added some commits Aug 13, 2019

Suggest `Box::new` when appropriate
When encountering a boxed value as expected and a stack allocated value
that could be boxed to fulfill the expectation, like in the following
snippet, suggest `Box::new` wrapping.

@estebank estebank force-pushed the estebank:type-inference-error branch from c96135e to fb2511c Aug 13, 2019

Show resolved Hide resolved src/librustc/infer/error_reporting/need_type_info.rs Outdated
Show resolved Hide resolved src/librustc/infer/error_reporting/need_type_info.rs Outdated
Show resolved Hide resolved src/librustc/infer/error_reporting/need_type_info.rs Outdated
Show resolved Hide resolved src/librustc/infer/error_reporting/need_type_info.rs Outdated
Show resolved Hide resolved src/librustc/hir/map/mod.rs Outdated
Show resolved Hide resolved src/librustc_typeck/check/mod.rs Outdated
Show resolved Hide resolved src/librustc_typeck/check/mod.rs Outdated
Show resolved Hide resolved src/librustc_typeck/check/mod.rs Outdated
Show resolved Hide resolved src/test/ui/inference/cannot-infer-async-enabled-impl-trait-bindings.stderr
Show resolved Hide resolved src/librustc_typeck/check/mod.rs Outdated
@Centril

This comment has been minimized.

Copy link
Member

commented Aug 13, 2019

Thanks! r=me with ^--- addressed :)

@estebank

This comment has been minimized.

Copy link
Contributor Author

commented Aug 13, 2019

@bors r=Centril

@bors

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2019

📌 Commit 939c1cb has been approved by Centril

@estebank

This comment has been minimized.

Copy link
Contributor Author

commented Aug 13, 2019

@Centril I have an extra commit that could either go on this PR or a follow up, changing the suggestion for specific cases of closures, recommending setting a return type instead of a boxed closure. Should I include it in this PR and you do an extra round of reviews? It's to close #40014 too.

@Centril

This comment has been minimized.

Copy link
Member

commented Aug 13, 2019

@estebank I'm fine with either... ;)

@estebank

This comment has been minimized.

Copy link
Contributor Author

commented Aug 13, 2019

@bors r-

@Centril incoming.

@Centril

This comment has been minimized.

Copy link
Member

commented Aug 14, 2019

The code makes sense but could use a bit of refactoring so the method isn't too overwhelming to read. I've suggested some ways to fix that ^--- r=me with those addressed.

@Centril
Copy link
Member

left a comment

Thanks! r=me :)

@estebank

This comment has been minimized.

Copy link
Contributor Author

commented Aug 14, 2019

@bors r=Centril

@bors

This comment has been minimized.

Copy link
Contributor

commented Aug 14, 2019

📌 Commit 6c3a98e has been approved by Centril

Centril added a commit to Centril/rust that referenced this pull request Aug 14, 2019

Rollup merge of rust-lang#63507 - estebank:type-inference-error, r=Ce…
…ntril

When needing type annotations in local bindings, account for impl Trait and closures

Fix rust-lang#46680, fix rust-lang#63504, fix rust-lang#63506, fix rust-lang#40014, cc rust-lang#63502.

bors added a commit that referenced this pull request Aug 15, 2019

Auto merge of #63575 - Centril:rollup-anlv9g5, r=Centril
Rollup of 11 pull requests

Successful merges:

 - #62984 (Add lint for excess trailing semicolons)
 - #63075 (Miri: Check that a ptr is aligned and inbounds already when evaluating `*`)
 - #63490 (libsyntax: cleanup and refactor `pat.rs`)
 - #63507 (When needing type annotations in local bindings, account for impl Trait and closures)
 - #63509 (Point at the right enclosing scope when using `await` in non-async fn)
 - #63528 (syntax: Remove `DummyResult::expr_only`)
 - #63537 (expand: Unimplement `MutVisitor` on `MacroExpander`)
 - #63542 (Add NodeId for Arm, Field and FieldPat)
 - #63543 (Merge Variant and Variant_)
 - #63560 (move test that shouldn't be in test/run-pass/)
 - #63570 (Adjust tracking issues for `MaybeUninit<T>` gates)

Failed merges:

r? @ghost

@bors bors merged commit 6c3a98e into rust-lang:master Aug 15, 2019

4 checks passed

pr Build #20190814.50 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (LinuxTools) LinuxTools succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.