Skip to content

Improve suggestion for calling fn-like expr on type mismatch - #98280

Merged
bors merged 1 commit into
rust-lang:masterfrom
compiler-errors:better-call-closure-on-type-err
Jun 24, 2022
Merged

Improve suggestion for calling fn-like expr on type mismatch#98280
bors merged 1 commit into
rust-lang:masterfrom
compiler-errors:better-call-closure-on-type-err

Conversation

@compiler-errors

Copy link
Copy Markdown
Contributor

1.) Suggest calling values of with RPIT types (and probably TAIT) when we expect Ty and have impl Fn() -> Ty
2.) Suggest calling closures even when they're not assigned to a local variable first
3.) Drive-by fix of a pretty-printing bug (impl Fn()-> Ty => impl Fn() -> Ty)

r? @estebank

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 20, 2022
@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 20, 2022
Comment threadsrc/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr Outdated

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.

Suggested change
&& let ty::Tuple(args) = proj.projection_ty.substs.type_at(1).kind()// args tuple will always be substs[1]
// args tuple will always be substs[1]
&& let ty::Tuple(args) = proj.projection_ty.substs.type_at(1).kind()

@estebank

Copy link
Copy Markdown
Contributor

r=me after addressing the comment comment :)

@compiler-errors
compiler-errorsforce-pushed the better-call-closure-on-type-err branch from b85719a to d15fed7CompareJune 22, 2022 01:12
@compiler-errors

Copy link
Copy Markdown
ContributorAuthor

@bors r=estebank

@bors

bors commented Jun 22, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit d15fed7 has been approved by estebank

@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 Jun 22, 2022
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Jun 23, 2022
…-on-type-err, r=estebank
Improve suggestion for calling fn-like expr on type mismatch
1.) Suggest calling values of with RPIT types (and probably TAIT) when we expect `Ty` and have `impl Fn() -> Ty`
2.) Suggest calling closures even when they're not assigned to a local variable first
3.) Drive-by fix of a pretty-printing bug (`impl Fn()-> Ty` => `impl Fn() -> Ty`)
r? `@estebank`
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jun 24, 2022
…-on-type-err, r=estebank
Improve suggestion for calling fn-like expr on type mismatch
1.) Suggest calling values of with RPIT types (and probably TAIT) when we expect `Ty` and have `impl Fn() -> Ty`
2.) Suggest calling closures even when they're not assigned to a local variable first
3.) Drive-by fix of a pretty-printing bug (`impl Fn()-> Ty` => `impl Fn() -> Ty`)
r? ``@estebank``
@JohnTitorJohnTitor mentioned this pull request Jun 24, 2022
@JohnTitorJohnTitor mentioned this pull request Jun 24, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 24, 2022
Rollup of 9 pull requests
Successful merges:
- rust-lang#91264 (Add macro support in jump to definition feature)
- rust-lang#96955 (Remove (transitive) reliance on sorting by DefId in pretty-printer)
- rust-lang#97633 (Session object: Set OS/ABI)
- rust-lang#98039 (Fix `panic` message for `BTreeSet`'s `range` API and document `panic` cases)
- rust-lang#98214 (rustc_target: Remove some redundant target properties)
- rust-lang#98280 (Improve suggestion for calling fn-like expr on type mismatch)
- rust-lang#98394 (Fixup missing renames from `#[main]` to `#[rustc_main]`)
- rust-lang#98411 (Update tendril)
- rust-lang#98419 (Remove excess rib while resolving closures)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 964fc41 into rust-lang:masterJun 24, 2022
@rustbotrustbot added this to the 1.63.0 milestone Jun 24, 2022
@compiler-errors
compiler-errors deleted the better-call-closure-on-type-err branch August 11, 2023 19:55
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.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@compiler-errors@estebank@bors@lcnr@rust-highfive@rustbot