rust/library/core/src/ops
Yuki Okushi 89c98cd6b4
Rollup merge of #78063 - camelid:improve-cannot-multiply-error, r=estebank
Improve wording of "cannot multiply" type error

For example, if you had this code:

    fn foo(x: i32, y: f32) -> f32 {
        x * y
    }

You would get this error:

    error[E0277]: cannot multiply `f32` to `i32`
     --> src/lib.rs:2:7
      |
    2 |     x * y
      |       ^ no implementation for `i32 * f32`
      |
      = help: the trait `Mul<f32>` is not implemented for `i32`

However, that's not usually how people describe multiplication. People
usually describe multiplication like how the division error words it:

    error[E0277]: cannot divide `i32` by `f32`
     --> src/lib.rs:2:7
      |
    2 |     x / y
      |       ^ no implementation for `i32 / f32`
      |
      = help: the trait `Div<f32>` is not implemented for `i32`

So that's what this change does. It changes this:

    error[E0277]: cannot multiply `f32` to `i32`
     --> src/lib.rs:2:7
      |
    2 |     x * y
      |       ^ no implementation for `i32 * f32`
      |
      = help: the trait `Mul<f32>` is not implemented for `i32`

To this:

    error[E0277]: cannot multiply `i32` by `f32`
     --> src/lib.rs:2:7
      |
    2 |     x * y
      |       ^ no implementation for `i32 * f32`
      |
      = help: the trait `Mul<f32>` is not implemented for `i32`
2020-10-21 13:59:39 +09:00
..
arith.rs Improve wording of "cannot multiply" type error 2020-10-17 22:19:25 -07:00
bit.rs Use Self more in core in doc when possible 2020-09-23 00:16:16 +02:00
control_flow.rs Add BREAK too, and improve the comments 2020-09-04 16:28:23 -07:00
deref.rs Note when a a move/borrow error is caused by a deref coercion 2020-09-10 20:56:20 -04:00
drop.rs Remove links that get imported from the prelude 2020-08-21 23:27:23 +02:00
function.rs Use intra-doc-links in core::ops::* 2020-08-21 23:19:10 +02:00
generator.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
index.rs Remove links that get imported from the prelude 2020-08-21 23:27:23 +02:00
mod.rs Use Self more in core in doc when possible 2020-09-23 00:16:16 +02:00
range.rs Auto merge of #77874 - camelid:range-docs-readability, r=scottmcm 2020-10-19 00:11:08 +00:00
try.rs apply bootstrap cfgs 2020-08-26 10:17:31 +02:00
unsize.rs Use intra-doc-links in core::ops::* 2020-08-21 23:19:10 +02:00