-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #78235 - Aaron1011:closure-ret-infer, r=varkor
Explain where the closure return type was inferred Fixes #78193
- Loading branch information
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
fn main() { | ||
|| { | ||
if false { | ||
return "test"; | ||
} | ||
let a = true; | ||
a //~ ERROR mismatched types | ||
}; | ||
|
||
|| -> bool { | ||
if false { | ||
return "hello" //~ ERROR mismatched types | ||
}; | ||
let b = true; | ||
b | ||
}; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/closure-return-type-mismatch.rs:7:9 | ||
| | ||
LL | a | ||
| ^ expected `&str`, found `bool` | ||
| | ||
note: return type inferred to be `&str` here | ||
--> $DIR/closure-return-type-mismatch.rs:4:20 | ||
| | ||
LL | return "test"; | ||
| ^^^^^^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/closure-return-type-mismatch.rs:12:20 | ||
| | ||
LL | return "hello" | ||
| ^^^^^^^ expected `bool`, found `&str` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
This file contains 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