Skip to content

Commit a36b960

Browse files
committed
Auto merge of #57250 - codeworm96:tyerr_msg, r=varkor
Improve type mismatch error messages Closes #56115. Replace "integral variable" with "integer" and replace "floating-point variable" with "floating-point number" to make the message less confusing. TODO the book and clippy needs to be changed accordingly later. r? @varkor
2 parents d370493 + 710dcbd commit a36b960

File tree

54 files changed

+105
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+105
-105
lines changed

src/librustc/ty/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
200200
ty::GeneratorWitness(..) => "generator witness".into(),
201201
ty::Tuple(..) => "tuple".into(),
202202
ty::Infer(ty::TyVar(_)) => "inferred type".into(),
203-
ty::Infer(ty::IntVar(_)) => "integral variable".into(),
204-
ty::Infer(ty::FloatVar(_)) => "floating-point variable".into(),
203+
ty::Infer(ty::IntVar(_)) => "integer".into(),
204+
ty::Infer(ty::FloatVar(_)) => "floating-point number".into(),
205205
ty::Placeholder(..) => "placeholder type".into(),
206206
ty::Bound(..) => "bound type".into(),
207207
ty::Infer(ty::FreshTy(_)) => "fresh type".into(),

src/test/ui/bad/bad-const-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ static i: String = 10;
22
//~^ ERROR mismatched types
33
//~| expected type `std::string::String`
44
//~| found type `{integer}`
5-
//~| expected struct `std::string::String`, found integral variable
5+
//~| expected struct `std::string::String`, found integer
66
fn main() { println!("{}", i); }

src/test/ui/bad/bad-const-type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | static i: String = 10;
55
| ^^
66
| |
7-
| expected struct `std::string::String`, found integral variable
7+
| expected struct `std::string::String`, found integer
88
| help: try using a conversion method: `10.to_string()`
99
|
1010
= note: expected type `std::string::String`

src/test/ui/binop/binop-logic-int.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/binop-logic-int.rs:1:21
33
|
44
LL | fn main() { let x = 1 && 2; }
5-
| ^ expected bool, found integral variable
5+
| ^ expected bool, found integer
66
|
77
= note: expected type `bool`
88
found type `{integer}`
@@ -11,7 +11,7 @@ error[E0308]: mismatched types
1111
--> $DIR/binop-logic-int.rs:1:26
1212
|
1313
LL | fn main() { let x = 1 && 2; }
14-
| ^ expected bool, found integral variable
14+
| ^ expected bool, found integer
1515
|
1616
= note: expected type `bool`
1717
found type `{integer}`

src/test/ui/blind/blind-item-block-middle.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/blind-item-block-middle.rs:6:9
33
|
44
LL | let bar = 5;
5-
| ^^^ expected integral variable, found struct `foo::bar`
5+
| ^^^ expected integer, found struct `foo::bar`
66
|
77
= note: expected type `{integer}`
88
found type `foo::bar`

src/test/ui/chalkify/type_inference.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/type_inference.rs:21:14
33
|
44
LL | only_foo(x); //~ ERROR mismatched types
5-
| ^ expected i32, found floating-point variable
5+
| ^ expected i32, found floating-point number
66
|
77
= note: expected type `i32`
88
found type `{float}`

src/test/ui/coercion/coerce-to-bang.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/coerce-to-bang.rs:6:17
33
|
44
LL | foo(return, 22, 44);
5-
| ^^ expected !, found integral variable
5+
| ^^ expected !, found integer
66
|
77
= note: expected type `!`
88
found type `{integer}`
@@ -11,7 +11,7 @@ error[E0308]: mismatched types
1111
--> $DIR/coerce-to-bang.rs:18:13
1212
|
1313
LL | foo(22, 44, return); //~ ERROR mismatched types
14-
| ^^ expected !, found integral variable
14+
| ^^ expected !, found integer
1515
|
1616
= note: expected type `!`
1717
found type `{integer}`
@@ -20,7 +20,7 @@ error[E0308]: mismatched types
2020
--> $DIR/coerce-to-bang.rs:26:12
2121
|
2222
LL | foo(a, b, c); // ... and hence a reference to `a` is expected to diverge.
23-
| ^ expected !, found integral variable
23+
| ^ expected !, found integer
2424
|
2525
= note: expected type `!`
2626
found type `{integer}`
@@ -29,7 +29,7 @@ error[E0308]: mismatched types
2929
--> $DIR/coerce-to-bang.rs:36:12
3030
|
3131
LL | foo(a, b, c); //~ ERROR mismatched types
32-
| ^ expected !, found integral variable
32+
| ^ expected !, found integer
3333
|
3434
= note: expected type `!`
3535
found type `{integer}`
@@ -38,7 +38,7 @@ error[E0308]: mismatched types
3838
--> $DIR/coerce-to-bang.rs:45:12
3939
|
4040
LL | foo(a, b, c); //~ ERROR mismatched types
41-
| ^ expected !, found integral variable
41+
| ^ expected !, found integer
4242
|
4343
= note: expected type `!`
4444
found type `{integer}`
@@ -47,7 +47,7 @@ error[E0308]: mismatched types
4747
--> $DIR/coerce-to-bang.rs:50:21
4848
|
4949
LL | let x: [!; 2] = [return, 22]; //~ ERROR mismatched types
50-
| ^^^^^^^^^^^^ expected !, found integral variable
50+
| ^^^^^^^^^^^^ expected !, found integer
5151
|
5252
= note: expected type `[!; 2]`
5353
found type `[{integer}; 2]`
@@ -56,7 +56,7 @@ error[E0308]: mismatched types
5656
--> $DIR/coerce-to-bang.rs:55:22
5757
|
5858
LL | let x: [!; 2] = [22, return]; //~ ERROR mismatched types
59-
| ^^ expected !, found integral variable
59+
| ^^ expected !, found integer
6060
|
6161
= note: expected type `!`
6262
found type `{integer}`
@@ -65,7 +65,7 @@ error[E0308]: mismatched types
6565
--> $DIR/coerce-to-bang.rs:60:37
6666
|
6767
LL | let x: (usize, !, usize) = (22, 44, 66); //~ ERROR mismatched types
68-
| ^^ expected !, found integral variable
68+
| ^^ expected !, found integer
6969
|
7070
= note: expected type `!`
7171
found type `{integer}`
@@ -74,7 +74,7 @@ error[E0308]: mismatched types
7474
--> $DIR/coerce-to-bang.rs:65:41
7575
|
7676
LL | let x: (usize, !, usize) = (return, 44, 66);
77-
| ^^ expected !, found integral variable
77+
| ^^ expected !, found integer
7878
|
7979
= note: expected type `!`
8080
found type `{integer}`
@@ -83,7 +83,7 @@ error[E0308]: mismatched types
8383
--> $DIR/coerce-to-bang.rs:76:37
8484
|
8585
LL | let x: (usize, !, usize) = (22, 44, return); //~ ERROR mismatched types
86-
| ^^ expected !, found integral variable
86+
| ^^ expected !, found integer
8787
|
8888
= note: expected type `!`
8989
found type `{integer}`

src/test/ui/consts/const-integer-bool-ops.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
const X: usize = 42 && 39;
22
//~^ ERROR mismatched types
3-
//~| expected bool, found integral variable
3+
//~| expected bool, found integer
44
//~| ERROR mismatched types
5-
//~| expected bool, found integral variable
5+
//~| expected bool, found integer
66
//~| ERROR mismatched types
77
//~| expected usize, found bool
88
const ARR: [i32; X] = [99; 34];
99
//~^ ERROR evaluation of constant value failed
1010

1111
const X1: usize = 42 || 39;
1212
//~^ ERROR mismatched types
13-
//~| expected bool, found integral variable
13+
//~| expected bool, found integer
1414
//~| ERROR mismatched types
15-
//~| expected bool, found integral variable
15+
//~| expected bool, found integer
1616
//~| ERROR mismatched types
1717
//~| expected usize, found bool
1818
const ARR1: [i32; X1] = [99; 47];
1919
//~^ ERROR evaluation of constant value failed
2020

2121
const X2: usize = -42 || -39;
2222
//~^ ERROR mismatched types
23-
//~| expected bool, found integral variable
23+
//~| expected bool, found integer
2424
//~| ERROR mismatched types
25-
//~| expected bool, found integral variable
25+
//~| expected bool, found integer
2626
//~| ERROR mismatched types
2727
//~| expected usize, found bool
2828
const ARR2: [i32; X2] = [99; 18446744073709551607];
2929
//~^ ERROR evaluation of constant value failed
3030

3131
const X3: usize = -42 && -39;
3232
//~^ ERROR mismatched types
33-
//~| expected bool, found integral variable
33+
//~| expected bool, found integer
3434
//~| ERROR mismatched types
35-
//~| expected bool, found integral variable
35+
//~| expected bool, found integer
3636
//~| ERROR mismatched types
3737
//~| expected usize, found bool
3838
const ARR3: [i32; X3] = [99; 6];

src/test/ui/consts/const-integer-bool-ops.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/const-integer-bool-ops.rs:1:18
33
|
44
LL | const X: usize = 42 && 39;
5-
| ^^ expected bool, found integral variable
5+
| ^^ expected bool, found integer
66
|
77
= note: expected type `bool`
88
found type `{integer}`
@@ -11,7 +11,7 @@ error[E0308]: mismatched types
1111
--> $DIR/const-integer-bool-ops.rs:1:24
1212
|
1313
LL | const X: usize = 42 && 39;
14-
| ^^ expected bool, found integral variable
14+
| ^^ expected bool, found integer
1515
|
1616
= note: expected type `bool`
1717
found type `{integer}`
@@ -32,7 +32,7 @@ error[E0308]: mismatched types
3232
--> $DIR/const-integer-bool-ops.rs:11:19
3333
|
3434
LL | const X1: usize = 42 || 39;
35-
| ^^ expected bool, found integral variable
35+
| ^^ expected bool, found integer
3636
|
3737
= note: expected type `bool`
3838
found type `{integer}`
@@ -41,7 +41,7 @@ error[E0308]: mismatched types
4141
--> $DIR/const-integer-bool-ops.rs:11:25
4242
|
4343
LL | const X1: usize = 42 || 39;
44-
| ^^ expected bool, found integral variable
44+
| ^^ expected bool, found integer
4545
|
4646
= note: expected type `bool`
4747
found type `{integer}`
@@ -62,7 +62,7 @@ error[E0308]: mismatched types
6262
--> $DIR/const-integer-bool-ops.rs:21:19
6363
|
6464
LL | const X2: usize = -42 || -39;
65-
| ^^^ expected bool, found integral variable
65+
| ^^^ expected bool, found integer
6666
|
6767
= note: expected type `bool`
6868
found type `{integer}`
@@ -71,7 +71,7 @@ error[E0308]: mismatched types
7171
--> $DIR/const-integer-bool-ops.rs:21:26
7272
|
7373
LL | const X2: usize = -42 || -39;
74-
| ^^^ expected bool, found integral variable
74+
| ^^^ expected bool, found integer
7575
|
7676
= note: expected type `bool`
7777
found type `{integer}`
@@ -92,7 +92,7 @@ error[E0308]: mismatched types
9292
--> $DIR/const-integer-bool-ops.rs:31:19
9393
|
9494
LL | const X3: usize = -42 && -39;
95-
| ^^^ expected bool, found integral variable
95+
| ^^^ expected bool, found integer
9696
|
9797
= note: expected type `bool`
9898
found type `{integer}`
@@ -101,7 +101,7 @@ error[E0308]: mismatched types
101101
--> $DIR/const-integer-bool-ops.rs:31:26
102102
|
103103
LL | const X3: usize = -42 && -39;
104-
| ^^^ expected bool, found integral variable
104+
| ^^^ expected bool, found integer
105105
|
106106
= note: expected type `bool`
107107
found type `{integer}`

src/test/ui/conversion-methods.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ error[E0308]: mismatched types
2828
LL | let _but_should_the_play: String = 2; // Perhaps surprisingly, we suggest .to_string() here
2929
| ^
3030
| |
31-
| expected struct `std::string::String`, found integral variable
31+
| expected struct `std::string::String`, found integer
3232
| help: try using a conversion method: `2.to_string()`
3333
|
3434
= note: expected type `std::string::String`

src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | let sixteen: f32 = 16;
55
| ^^
66
| |
7-
| expected f32, found integral variable
7+
| expected f32, found integer
88
| help: use a float literal: `16.0`
99
|
1010
= note: expected type `f32`
@@ -16,7 +16,7 @@ error[E0308]: mismatched types
1616
LL | let a_million_and_seventy: f64 = 1_000_070;
1717
| ^^^^^^^^^
1818
| |
19-
| expected f64, found integral variable
19+
| expected f64, found integer
2020
| help: use a float literal: `1_000_070.0`
2121
|
2222
= note: expected type `f64`
@@ -28,7 +28,7 @@ error[E0308]: mismatched types
2828
LL | let negative_nine: f32 = -9;
2929
| ^^
3030
| |
31-
| expected f32, found integral variable
31+
| expected f32, found integer
3232
| help: use a float literal: `-9.0`
3333
|
3434
= note: expected type `f32`
@@ -38,7 +38,7 @@ error[E0308]: mismatched types
3838
--> $DIR/issue-53280-expected-float-found-integer-literal.rs:15:30
3939
|
4040
LL | let sixteen_again: f64 = 0x10;
41-
| ^^^^ expected f64, found integral variable
41+
| ^^^^ expected f64, found integer
4242
|
4343
= note: expected type `f64`
4444
found type `{integer}`
@@ -47,7 +47,7 @@ error[E0308]: mismatched types
4747
--> $DIR/issue-53280-expected-float-found-integer-literal.rs:17:30
4848
|
4949
LL | let and_once_more: f32 = 0o20;
50-
| ^^^^ expected f32, found integral variable
50+
| ^^^^ expected f32, found integer
5151
|
5252
= note: expected type `f32`
5353
found type `{integer}`

src/test/ui/error-codes/E0070.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ error[E0308]: mismatched types
1414
--> $DIR/E0070.rs:8:25
1515
|
1616
LL | some_other_func() = 4; //~ ERROR E0070
17-
| ^ expected (), found integral variable
17+
| ^ expected (), found integer
1818
|
1919
= note: expected type `()`
2020
found type `{integer}`

src/test/ui/float-literal-inference-restrictions.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | let x: f32 = 1; //~ ERROR mismatched types
55
| ^
66
| |
7-
| expected f32, found integral variable
7+
| expected f32, found integer
88
| help: use a float literal: `1.0`
99
|
1010
= note: expected type `f32`

src/test/ui/fully-qualified-type/fully-qualified-type-name1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ fn main() {
66
//~^ ERROR mismatched types
77
//~| expected type `std::option::Option<usize>`
88
//~| found type `{integer}`
9-
//~| expected enum `std::option::Option`, found integral variable
9+
//~| expected enum `std::option::Option`, found integer
1010
}

src/test/ui/fully-qualified-type/fully-qualified-type-name1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | x = 5;
55
| ^
66
| |
7-
| expected enum `std::option::Option`, found integral variable
7+
| expected enum `std::option::Option`, found integer
88
| help: try using a variant of the expected type: `Some(5)`
99
|
1010
= note: expected type `std::option::Option<usize>`

src/test/ui/generic/generic-arg-mismatch-recover.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0308]: mismatched types
88
--> $DIR/generic-arg-mismatch-recover.rs:6:33
99
|
1010
LL | Foo::<'static, 'static, ()>(&0); //~ ERROR wrong number of lifetime arguments
11-
| ^^ expected (), found integral variable
11+
| ^^ expected (), found integer
1212
|
1313
= note: expected type `&'static ()`
1414
found type `&{integer}`

src/test/ui/if/if-let-arm-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn main() {
22
if let Some(b) = None { //~ ERROR: `if let` arms have incompatible types
3-
//~^ expected (), found integral variable
3+
//~^ expected (), found integer
44
//~| expected type `()`
55
//~| found type `{integer}`
66
()

src/test/ui/if/if-let-arm-types.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0308]: `if let` arms have incompatible types
22
--> $DIR/if-let-arm-types.rs:2:5
33
|
44
LL | / if let Some(b) = None { //~ ERROR: `if let` arms have incompatible types
5-
LL | | //~^ expected (), found integral variable
5+
LL | | //~^ expected (), found integer
66
LL | | //~| expected type `()`
77
LL | | //~| found type `{integer}`
88
... |
99
LL | | 1
1010
LL | | };
11-
| |_____^ expected (), found integral variable
11+
| |_____^ expected (), found integer
1212
|
1313
= note: expected type `()`
1414
found type `{integer}`

src/test/ui/integral-variable-unification-error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ fn main() {
44
//~^ ERROR mismatched types
55
//~| expected type `{integer}`
66
//~| found type `{float}`
7-
//~| expected integral variable, found floating-point variable
7+
//~| expected integer, found floating-point number
88
}

0 commit comments

Comments
 (0)