Skip to content

Conversation

@estebank
Copy link
Contributor

@estebank estebank commented Nov 11, 2023

When encountering a fn call that has a path to another fn being passed in, where an Fn impl is expected, and the arguments differ, suggest wrapping the argument with a closure with the appropriate arguments.

The last help is new:

error[E0631]: type mismatch in function arguments
  --> $DIR/E0631.rs:9:9
   |
LL |     fn f(_: u64) {}
   |     ------------ found signature defined here
...
LL |     foo(f);
   |     --- ^ expected due to this
   |     |
   |     required by a bound introduced by this call
   |
   = note: expected function signature `fn(usize) -> _`
              found function signature `fn(u64) -> _`
note: required by a bound in `foo`
  --> $DIR/E0631.rs:3:11
   |
LL | fn foo<F: Fn(usize)>(_: F) {}
   |           ^^^^^^^^^ required by this bound in `foo`
help: consider wrapping the function in a closure
   |
LL |     foo(|arg0: usize| f(/* u64 */));
   |         +++++++++++++  +++++++++++

@rustbot
Copy link
Collaborator

rustbot commented Nov 11, 2023

r? @petrochenkov

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 11, 2023
@rust-log-analyzer

This comment has been minimized.

@estebank estebank force-pushed the arg-fn-mismatch branch 2 times, most recently from e5d6e11 to b61a78a Compare November 16, 2023 16:57
@petrochenkov petrochenkov 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 Nov 29, 2023
When encountering a fn call that has a path to another fn being passed
in, where an `Fn` impl is expected, and the arguments differ, suggest
wrapping the argument with a closure with the appropriate arguments.
@estebank estebank 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 Nov 29, 2023
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 30, 2023

📌 Commit 25c75bc has been approved by petrochenkov

It is now in the queue for this repository.

@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 Nov 30, 2023
@bors
Copy link
Collaborator

bors commented Nov 30, 2023

⌛ Testing commit 25c75bc with merge 87e1447...

@bors
Copy link
Collaborator

bors commented Nov 30, 2023

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing 87e1447 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 30, 2023
@bors bors merged commit 87e1447 into rust-lang:master Nov 30, 2023
@rustbot rustbot added this to the 1.76.0 milestone Nov 30, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (87e1447): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
17.7% [10.2%, 27.4%] 7
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 17.7% [10.2%, 27.4%] 7

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 673.226s -> 674.44s (0.18%)
Artifact size: 313.37 MiB -> 313.39 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant 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