Skip to content

Commit 2fb6585

Browse files
committed
add test for float/integer
1 parent 9d6c4f0 commit 2fb6585

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

src/test/ui/mismatched_types/numeric-literal-cast.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
// except according to those terms.
1010

1111
fn foo(_: u16) {}
12+
fn foo1(_: f64) {}
13+
fn foo2(_: i32) {}
14+
1215
fn main() {
13-
foo(8u8);
16+
foo(1u8);
17+
foo1(2f32);
18+
foo2(3i16);
1419
}
1520

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
error[E0308]: mismatched types
2-
--> $DIR/numeric-literal-cast.rs:13:9
2+
--> $DIR/numeric-literal-cast.rs:16:9
33
|
4-
LL | foo(8u8);
4+
LL | foo(1u8);
55
| ^^^ expected u16, found u8
66
help: change the type of the numeric literal from `u8` to `u16`
77
|
8-
LL | foo(8u16);
8+
LL | foo(1u16);
99
| ^^^^
1010

11-
error: aborting due to previous error
11+
error[E0308]: mismatched types
12+
--> $DIR/numeric-literal-cast.rs:17:10
13+
|
14+
LL | foo1(2f32);
15+
| ^^^^ expected f64, found f32
16+
help: change the type of the numeric literal from `f32` to `f64`
17+
|
18+
LL | foo1(2f64);
19+
| ^^^^
20+
21+
error[E0308]: mismatched types
22+
--> $DIR/numeric-literal-cast.rs:18:10
23+
|
24+
LL | foo2(3i16);
25+
| ^^^^ expected i32, found i16
26+
help: change the type of the numeric literal from `i16` to `i32`
27+
|
28+
LL | foo2(3i32);
29+
| ^^^^
30+
31+
error: aborting due to 3 previous errors
1232

1333
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)