]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0689.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0689.md
1 A method was called on an ambiguous numeric type.
2
3 Erroneous code example:
4
5 ```compile_fail,E0689
6 2.0.neg(); // error!
7 ```
8
9 This error indicates that the numeric value for the method being passed exists
10 but the type of the numeric value or binding could not be identified.
11
12 The error happens on numeric literals and on numeric bindings without an
13 identified concrete type:
14
15 ```compile_fail,E0689
16 let x = 2.0;
17 x.neg();  // same error as above
18 ```
19
20 Because of this, you must give the numeric literal or binding a type:
21
22 ```
23 use std::ops::Neg;
24
25 let _ = 2.0_f32.neg(); // ok!
26 let x: f32 = 2.0;
27 let _ = x.neg(); // ok!
28 let _ = (2.0 as f32).neg(); // ok!
29 ```