diff options
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0689.md')
-rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0689.md | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0689.md b/compiler/rustc_error_codes/src/error_codes/E0689.md new file mode 100644 index 000000000..a680a2042 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0689.md @@ -0,0 +1,29 @@ +A method was called on an ambiguous numeric type. + +Erroneous code example: + +```compile_fail,E0689 +2.0.neg(); // error! +``` + +This error indicates that the numeric value for the method being passed exists +but the type of the numeric value or binding could not be identified. + +The error happens on numeric literals and on numeric bindings without an +identified concrete type: + +```compile_fail,E0689 +let x = 2.0; +x.neg(); // same error as above +``` + +Because of this, you must give the numeric literal or binding a type: + +``` +use std::ops::Neg; + +let _ = 2.0_f32.neg(); // ok! +let x: f32 = 2.0; +let _ = x.neg(); // ok! +let _ = (2.0 as f32).neg(); // ok! +``` |