-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Explain type mismatch cause pointing to return type when it is impl Trait
#57793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:5:5 | ||
| | ||
LL | fn foo() -> impl std::fmt::Display { | ||
| ---------------------- expected because this return type... | ||
LL | if false { | ||
LL | return 0i32; | ||
| ---- expected because of this statement | ||
| ---- ...is found to be `i32` here | ||
LL | } | ||
LL | 1u32 | ||
| ^^^^ expected i32, found u32 | ||
|
@@ -13,8 +16,11 @@ LL | 1u32 | |
error[E0308]: mismatched types | ||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:13:16 | ||
| | ||
LL | fn bar() -> impl std::fmt::Display { | ||
| ---------------------- expected because this return type... | ||
LL | if false { | ||
LL | return 0i32; | ||
| ---- expected because of this statement | ||
| ---- ...is found to be `i32` here | ||
LL | } else { | ||
LL | return 1u32; | ||
| ^^^^ expected i32, found u32 | ||
|
@@ -25,10 +31,12 @@ LL | return 1u32; | |
error[E0308]: mismatched types | ||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:19:5 | ||
| | ||
LL | fn baz() -> impl std::fmt::Display { | ||
| ---------------------- expected because this return type... | ||
LL | / if false { | ||
LL | | //~^ ERROR mismatched types | ||
LL | | return 0i32; | ||
| | ---- expected because of this statement | ||
| | ---- ...is found to be `i32` here | ||
LL | | } else { | ||
LL | | 1u32 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mostly unrelated to this PR, but shouldn't the type mismatch span point to this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've made a few changes recently to point at the tail expression in blocks instead of entire blocks, but haven't finished yet. This change is already in my plans :) |
||
LL | | } | ||
|
Uh oh!
There was an error while loading. Please reload this page.