Commit c97ff09
authored
Rollup merge of rust-lang#88911 - FabianWolff:issue-88653, r=petrochenkov
Improve error message for type mismatch in generator arguments
Fixes rust-lang#88653. The code example given there is invalid because the `Generator` trait (unlike the `Fn` traits) does not take the generator arguments in tupled-up form (because there can only be one argument, from my understanding). Hence, the type error in the example in rust-lang#88653 is correct, because the given generator takes a `bool` argument, whereas the function's return type talks about a generator with a `(bool,)` argument.
The error message is both confusing and wrong, though: It is wrong because it displays the wrong "expected signature", and it is confusing because both the "expected" and "found" notes point at the same span. With my changes, I get the following, more helpful output:
```
error[E0631]: type mismatch in generator arguments
--> test.rs:5:22
|
5 | fn foo(bar: bool) -> impl Generator<(bool,)> {
| ^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `fn((bool,)) -> _`
6 | |bar| {
| ----- found signature of `fn(bool) -> _`
```File tree
4 files changed
+55
-14
lines changed- compiler/rustc_trait_selection/src/traits/error_reporting
- src/test/ui/generator
4 files changed
+55
-14
lines changedLines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
722 | 722 | | |
723 | 723 | | |
724 | 724 | | |
725 | | - | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
726 | 729 | | |
727 | 730 | | |
728 | 731 | | |
| |||
Lines changed: 20 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1256 | 1256 | | |
1257 | 1257 | | |
1258 | 1258 | | |
1259 | | - | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
1263 | | - | |
1264 | | - | |
1265 | | - | |
1266 | | - | |
1267 | | - | |
1268 | | - | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
1269 | 1272 | | |
1270 | 1273 | | |
1271 | 1274 | | |
1272 | 1275 | | |
1273 | 1276 | | |
1274 | | - | |
| 1277 | + | |
1275 | 1278 | | |
1276 | 1279 | | |
1277 | 1280 | | |
1278 | 1281 | | |
1279 | | - | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
1280 | 1287 | | |
1281 | 1288 | | |
1282 | 1289 | | |
1283 | 1290 | | |
1284 | 1291 | | |
1285 | | - | |
| 1292 | + | |
1286 | 1293 | | |
1287 | 1294 | | |
1288 | 1295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments