Tweak mismatched types error#63337
Merged
bors merged 14 commits intorust-lang:masterfrom Aug 10, 2019
Merged
Conversation
Contributor
|
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
Contributor
Author
Centril
reviewed
Aug 8, 2019
estebank
commented
Aug 8, 2019
Centril
reviewed
Aug 8, 2019
Centril
reviewed
Aug 8, 2019
Contributor
Centril
left a comment
There was a problem hiding this comment.
A bit shorter + return is an expr. :)
Contributor
Author
|
r? @Centril |
Centril
approved these changes
Aug 8, 2019
Contributor
Centril
left a comment
There was a problem hiding this comment.
r=me when-green with or without the change below depending on whether you feel that is an improvement :)
varkor
reviewed
Aug 8, 2019
Contributor
|
Looks great! |
Contributor
Author
|
@bors r=Centril |
Collaborator
|
📌 Commit 68aff3f has been approved by |
Centril
added a commit
to Centril/rust
that referenced
this pull request
Aug 9, 2019
Tweak mismatched types error - Change expected/found for type mismatches in `break` - Be more accurate when talking about diverging match arms - Tweak wording of function without a return value - Suggest calling bare functions when their return value can be coerced to the expected type - Give more parsing errors when encountering `foo(_, _, _)` Fix rust-lang#51767, fix rust-lang#62677, fix rust-lang#63136, cc rust-lang#37384, cc rust-lang#35241.
Contributor
|
Failed in #63401 (comment), @bors r- |
Contributor
Author
|
@bors r=Centril rebased |
Collaborator
|
📌 Commit 45a5bc7 has been approved by |
Centril
added a commit
to Centril/rust
that referenced
this pull request
Aug 9, 2019
Tweak mismatched types error - Change expected/found for type mismatches in `break` - Be more accurate when talking about diverging match arms - Tweak wording of function without a return value - Suggest calling bare functions when their return value can be coerced to the expected type - Give more parsing errors when encountering `foo(_, _, _)` Fix rust-lang#51767, fix rust-lang#62677, fix rust-lang#63136, cc rust-lang#37384, cc rust-lang#35241.
Centril
added a commit
to Centril/rust
that referenced
this pull request
Aug 9, 2019
Tweak mismatched types error - Change expected/found for type mismatches in `break` - Be more accurate when talking about diverging match arms - Tweak wording of function without a return value - Suggest calling bare functions when their return value can be coerced to the expected type - Give more parsing errors when encountering `foo(_, _, _)` Fix rust-lang#51767, fix rust-lang#62677, fix rust-lang#63136, cc rust-lang#37384, cc rust-lang#35241, cc rust-lang#51669.
Centril
added a commit
to Centril/rust
that referenced
this pull request
Aug 10, 2019
Tweak mismatched types error - Change expected/found for type mismatches in `break` - Be more accurate when talking about diverging match arms - Tweak wording of function without a return value - Suggest calling bare functions when their return value can be coerced to the expected type - Give more parsing errors when encountering `foo(_, _, _)` Fix rust-lang#51767, fix rust-lang#62677, fix rust-lang#63136, cc rust-lang#37384, cc rust-lang#35241, cc rust-lang#51669.
Centril
added a commit
to Centril/rust
that referenced
this pull request
Aug 10, 2019
Tweak mismatched types error - Change expected/found for type mismatches in `break` - Be more accurate when talking about diverging match arms - Tweak wording of function without a return value - Suggest calling bare functions when their return value can be coerced to the expected type - Give more parsing errors when encountering `foo(_, _, _)` Fix rust-lang#51767, fix rust-lang#62677, fix rust-lang#63136, cc rust-lang#37384, cc rust-lang#35241, cc rust-lang#51669.
bors
added a commit
that referenced
this pull request
Aug 10, 2019
Rollup of 7 pull requests Successful merges: - #63056 (Give built-in macros stable addresses in the standard library) - #63337 (Tweak mismatched types error) - #63350 (Use associated_type_bounds where applicable - closes #61738) - #63394 (Add test for issue 36804) - #63399 (More explicit diagnostic when using a `vec![]` in a pattern) - #63419 (check against more collisions for TypeId of fn pointer) - #63423 (Mention that tuple structs are private if any of their fields are) Failed merges: r? @ghost
Collaborator
This was referenced Aug 23, 2019
Centril
added a commit
to Centril/rust
that referenced
this pull request
Aug 25, 2019
…trochenkov Suggest calling closure with resolved return type when appropriate Follow up to rust-lang#63337. CC rust-lang#63100. ``` error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:46:20 | LL | let closure = || 42; | -- closure defined here LL | let _: usize = closure; | ^^^^^^^ | | | expected usize, found closure | help: use parentheses to call this closure: `closure()` | = note: expected type `usize` found type `[closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:24]` ```
bors
added a commit
that referenced
this pull request
Sep 1, 2019
Suggest call fn ctor passed as arg to fn with type param bounds
_Reviewer note: the relevant changes are in the second commit, the first is simple and mechanical, but verbose._
When forgetting to call a fn in an argument position to an fn that has a generic bound:
```rust
async fn foo() {}
fn bar(f: impl Future<Output=()>) {}
fn main() {
bar(foo); // <- should be `bar(foo());`
}
```
suggest calling it:
```
error[E0277]: the trait bound `fn() -> impl std::future::Future {foo}: std::future::Future` is not satisfied
--> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:9:5
|
LL | fn bar(f: impl Future<Output=()>) {}
| --------------------------------- required by `bar`
...
LL | bar(foo);
| ^^^ the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}`
|
= help: it looks like you forgot to use parentheses to call the function: `foo()`
```
Fix #63100. Follow up to #63833 and #63337.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
breakfoo(_, _, _)Fix #51767, fix #62677, fix #63136, cc #37384, cc #35241, cc #51669.