Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up E0689 explanation #73472

Merged
merged 1 commit into from
Jun 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/librustc_error_codes/error_codes/E0689.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
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.
A method was called on an ambiguous numeric type.

The error happens on numeric literals:
Erroneous code example:

```compile_fail,E0689
2.0.neg();
2.0.neg(); // error!
```

and on numeric bindings without an identified concrete type:
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.
Comment on lines +9 to +10
Copy link
Contributor

@pickfire pickfire Jun 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe maybe it would be better to arrange above the example like the below description which this refers to. Or maybe it would be better if we use This error rather than The error for the text below to avoid confusion.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. Most of the error messages are of th esimilar fashion and I think it is fine for now.


The error happens on numeric literals and on numeric bindings without an
identified concrete type:

```compile_fail,E0689
let x = 2.0;
Expand All @@ -19,8 +22,8 @@ Because of this, you must give the numeric literal or binding a type:
```
use std::ops::Neg;

let _ = 2.0_f32.neg();
let _ = 2.0_f32.neg(); // ok!
let x: f32 = 2.0;
let _ = x.neg();
let _ = (2.0 as f32).neg();
let _ = x.neg(); // ok!
let _ = (2.0 as f32).neg(); // ok!
```