Skip to content

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

Merged
bors merged 7 commits into
rust-lang:masterfrom
estebank:type-inference-error
Aug 15, 2019
Merged

When needing type annotations in local bindings, account for impl Trait and closures#63507
bors merged 7 commits into
rust-lang:masterfrom
estebank:type-inference-error

Conversation

@estebank

@estebankestebank commented Aug 13, 2019

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown
Contributor

r? @eddyb

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

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 13, 2019
@estebank

Copy link
Copy Markdown
ContributorAuthor

r? @Centril

@rust-highfiverust-highfive assigned Centril and unassigned eddybAug 13, 2019
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

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
estebankforce-pushed the type-inference-error branch from c96135e to fb2511cCompareAugust 13, 2019 03:24
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs Outdated
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs Outdated
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs Outdated
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs Outdated
Comment threadsrc/librustc/hir/map/mod.rs Outdated
Comment threadsrc/librustc_typeck/check/mod.rs Outdated
Comment threadsrc/librustc_typeck/check/mod.rs Outdated
Comment threadsrc/librustc_typeck/check/mod.rs Outdated
Comment threadsrc/librustc_typeck/check/mod.rs Outdated
@Centril

Copy link
Copy Markdown
Contributor

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

@estebank

Copy link
Copy Markdown
ContributorAuthor

@bors r=Centril

@bors

bors commented Aug 13, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 939c1cb has been approved by Centril

@borsbors 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 Aug 13, 2019
@estebank

estebank commented Aug 13, 2019

Copy link
Copy Markdown
ContributorAuthor

@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

Copy link
Copy Markdown
Contributor

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

@estebank

Copy link
Copy Markdown
ContributorAuthor

@bors r-

@Centril incoming.

@borsbors 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 Aug 13, 2019
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs
@estebankestebank 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 Aug 14, 2019
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs Outdated
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs Outdated
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs Outdated
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs Outdated
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs Outdated
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs Outdated
Comment threadsrc/librustc/infer/error_reporting/need_type_info.rs Outdated
@Centril

Copy link
Copy Markdown
Contributor

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.

@CentrilCentril left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! r=me :)

@estebank

Copy link
Copy Markdown
ContributorAuthor

@bors r=Centril

@bors

bors commented Aug 14, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 6c3a98e has been approved by Centril

@borsbors 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 Aug 14, 2019
Centril added a commit to Centril/rust that referenced this pull request Aug 14, 2019
…ntril
When needing type annotations in local bindings, account for impl Trait and closures
Fixrust-lang#46680, fixrust-lang#63504, fixrust-lang#63506, fixrust-lang#40014, cc rust-lang#63502.
@CentrilCentril mentioned this pull request Aug 14, 2019
bors added a commit that referenced this pull request Aug 15, 2019
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:masterAug 15, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

5 participants

@estebank@rust-highfive@Centril@bors@eddyb