Skip to content

Suggest returning closure as impl Fn - #101019

Merged
bors merged 2 commits into
rust-lang:masterfrom
compiler-errors:return-closure-suggestion
Aug 30, 2022
Merged

Suggest returning closure as impl Fn#101019
bors merged 2 commits into
rust-lang:masterfrom
compiler-errors:return-closure-suggestion

Conversation

@compiler-errors

Copy link
Copy Markdown
Contributor

Fixes#100936

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 26, 2022
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @cjgillot

(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 26, 2022
p!(")");

if !sig.output().is_unit() {
p!(" -> ", print(sig.output()));

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.

What happens if one of the printed types is an APIT?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I don't think APITs are is_suggestable. I can try tho

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Confirmed that this falls back to the old suggestion and doesn't suggest something like -> Fn() -> impl Fn() or anything like that. Added test for it.

@cjgillot

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Aug 29, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 93b7d8d has been approved by cjgillot

It is now in the queue for this repository.

@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 29, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 30, 2022
…gestion, r=cjgillot
Suggest returning closure as `impl Fn`
Fixesrust-lang#100936
@Dylan-DPCDylan-DPC mentioned this pull request Aug 30, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 30, 2022
Rollup of 9 pull requests
Successful merges:
- rust-lang#95376 (Add `vec::Drain{,Filter}::keep_rest`)
- rust-lang#100092 (Fall back when relating two opaques by substs in MIR typeck)
- rust-lang#101019 (Suggest returning closure as `impl Fn`)
- rust-lang#101022 (Erase late bound regions before comparing types in `suggest_dereferences`)
- rust-lang#101101 (interpret: make read-pointer-as-bytes a CTFE-only error with extra information)
- rust-lang#101123 (Remove `register_attr` feature)
- rust-lang#101175 (Don't --bless in pre-push hook)
- rust-lang#101176 (rustdoc: remove unused CSS selectors for `.table-display`)
- rust-lang#101180 (Add another MaybeUninit array test with const)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit aa9bfde into rust-lang:masterAug 30, 2022
@rustbotrustbot added this to the 1.65.0 milestone Aug 30, 2022
@compiler-errors
compiler-errors deleted the return-closure-suggestion branch November 2, 2022 03:00
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.

For function returning simple closure, suggest possible way to specify the return type

5 participants

@compiler-errors@rust-highfive@cjgillot@bors@rustbot