Commit 82045ca
committed
auto merge of #18264 : jakub-/rust/var-ids-in-error-messages, r=nikomatsakis
This PR aims to improve the readability of diagnostic messages that involve unresolved type variables. Currently, messages like the following:
```rust
mismatched types: expected `core::result::Result<uint,()>`, found `core::option::Option<<generic #1>>`
<anon>:6 let a: Result<uint, ()> = None;
^~~~
mismatched types: expected `&mut <generic #2>`, found `uint`
<anon>:7 f(42u);
^~~
```
tend to appear unapproachable to new users. [0] While specific type var IDs are valuable in
diagnostics that deal with more than one such variable, in practice many messages
only mention one. In those cases, leaving out the specific number makes the messages
slightly less terrifying.
```rust
mismatched types: expected `core::result::Result<uint, ()>`, found `core::option::Option<_>`
<anon>:6 let a: Result<uint, ()> = None;
^~~~
mismatched types: expected `&mut _`, found `uint`
<anon>:7 f(42u);
^~~
```
As you can see, I also tweaked the aesthetics slightly by changing type variables to use the type hole syntax _. For integer variables, the syntax used is:
```rust
mismatched types: expected `core::result::Result<uint, ()>`, found `core::option::Option<_#1i>`
<anon>:6 let a: Result<uint, ()> = Some(1);
```
and float variables:
```rust
mismatched types: expected `core::result::Result<uint, ()>`, found `core::option::Option<_#1f>`
<anon>:6 let a: Result<uint, ()> = Some(0.5);
```
[0] https://twitter.com/coda/status/517713085465772032
Closes #2632.
Closes #3404.
Closes #18426.File tree
29 files changed
+240
-194
lines changed- src
- librustc
- middle
- typeck/infer
- util
- test/compile-fail
29 files changed
+240
-194
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1032 | 1032 | | |
1033 | 1033 | | |
1034 | 1034 | | |
| 1035 | + | |
1035 | 1036 | | |
1036 | | - | |
1037 | | - | |
1038 | | - | |
1039 | 1037 | | |
1040 | 1038 | | |
1041 | 1039 | | |
| |||
3790 | 3788 | | |
3791 | 3789 | | |
3792 | 3790 | | |
3793 | | - | |
3794 | | - | |
| 3791 | + | |
| 3792 | + | |
3795 | 3793 | | |
3796 | 3794 | | |
3797 | 3795 | | |
| |||
3874 | 3872 | | |
3875 | 3873 | | |
3876 | 3874 | | |
3877 | | - | |
3878 | | - | |
| 3875 | + | |
| 3876 | + | |
3879 | 3877 | | |
3880 | 3878 | | |
3881 | 3879 | | |
3882 | 3880 | | |
3883 | | - | |
3884 | | - | |
3885 | | - | |
| 3881 | + | |
| 3882 | + | |
| 3883 | + | |
3886 | 3884 | | |
3887 | 3885 | | |
3888 | 3886 | | |
3889 | | - | |
3890 | | - | |
3891 | | - | |
3892 | | - | |
3893 | | - | |
3894 | | - | |
3895 | | - | |
3896 | | - | |
3897 | | - | |
3898 | 3887 | | |
3899 | 3888 | | |
3900 | 3889 | | |
| |||
3923 | 3912 | | |
3924 | 3913 | | |
3925 | 3914 | | |
3926 | | - | |
3927 | | - | |
3928 | | - | |
| 3915 | + | |
| 3916 | + | |
| 3917 | + | |
| 3918 | + | |
| 3919 | + | |
| 3920 | + | |
| 3921 | + | |
| 3922 | + | |
| 3923 | + | |
3929 | 3924 | | |
3930 | 3925 | | |
3931 | 3926 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
518 | 528 | | |
519 | 529 | | |
520 | 530 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
| 399 | + | |
| 400 | + | |
405 | 401 | | |
406 | 402 | | |
407 | 403 | | |
408 | | - | |
| 404 | + | |
409 | 405 | | |
410 | 406 | | |
411 | 407 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
900 | 901 | | |
901 | 902 | | |
902 | 903 | | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | 904 | | |
907 | 905 | | |
908 | 906 | | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | | - | |
923 | | - | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
924 | 921 | | |
925 | 922 | | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | 923 | | |
930 | 924 | | |
931 | 925 | | |
| |||
945 | 939 | | |
946 | 940 | | |
947 | 941 | | |
948 | | - | |
949 | | - | |
950 | | - | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
951 | 945 | | |
952 | | - | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
959 | | - | |
960 | | - | |
961 | | - | |
962 | | - | |
963 | | - | |
964 | | - | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
965 | 952 | | |
966 | | - | |
| 953 | + | |
967 | 954 | | |
968 | 955 | | |
969 | 956 | | |
| |||
0 commit comments