-
Notifications
You must be signed in to change notification settings - Fork 32
/
not-suggest-float-literal.rs
86 lines (73 loc) · 1.95 KB
/
not-suggest-float-literal.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
fn add_float_to_integer(x: u8) -> f32 {
x + 100.0 //~ ERROR cannot add `{float}` to `u8`
}
fn add_str_to_float(x: f64) -> f64 {
x + "foo" //~ ERROR cannot add `&str` to `f64`
}
fn add_lvar_to_float(x: f64) -> f64 {
let y = 3;
x + y //~ ERROR cannot add `{integer}` to `f64`
}
fn subtract_float_from_integer(x: u8) -> f32 {
x - 100.0 //~ ERROR cannot subtract `{float}` from `u8`
}
fn subtract_str_from_f64(x: f64) -> f64 {
x - "foo" //~ ERROR cannot subtract `&str` from `f64`
}
fn subtract_lvar_from_f64(x: f64) -> f64 {
let y = 3;
x - y //~ ERROR cannot subtract `{integer}` from `f64`
}
fn multiply_integer_by_float(x: u8) -> f32 {
x * 100.0 //~ ERROR cannot multiply `u8` by `{float}`
}
fn multiply_f64_by_str(x: f64) -> f64 {
x * "foo" //~ ERROR cannot multiply `f64` by `&str`
}
fn multiply_f64_by_lvar(x: f64) -> f64 {
let y = 3;
x * y //~ ERROR cannot multiply `f64` by `{integer}`
}
fn divide_integer_by_float(x: u8) -> u8 {
x / 100.0 //~ ERROR cannot divide `u8` by `{float}`
}
fn divide_f64_by_str(x: f64) -> f64 {
x / "foo" //~ ERROR cannot divide `f64` by `&str`
}
fn divide_f64_by_lvar(x: f64) -> f64 {
let y = 3;
x / y //~ ERROR cannot divide `f64` by `{integer}`
}
fn main() {}
// ferrocene-annotations: fls_1k9mkv7rbezi
// Arithmetic Expressions
//
// ferrocene-annotations: fls_29tlg1vyqay2
// Float Literals
//
// ferrocene-annotations: fls_2ed4axpsy9u0
// Integer Literals
//
// ferrocene-annotations: fls_hucd52suu6it
// Simple String Literals
//
// ferrocene-annotations: fls_boyhlu5srp6u
// String Literals
//
// ferrocene-annotations: fls_lv7w7aalpwm5
// Type Inference
//
// ferrocene-annotations: fls_exe4zodlwfez
// Type Unification
//
// ferrocene-annotations: fls_h0dvogc64tfh
// Literal Expressions
//
// ferrocene-annotations: fls_94a8v54bufn8
// Values
//
// ferrocene-annotations: fls_e7zgqroy2qxn
// Value Expressions
//
// ferrocene-annotations: fls_zfibijmf8qe1
// Arithmetic Overflow