This website requires JavaScript.
Explore
Help
Sign In
nordic-dev.net
/
rust
Watch
2
Star
0
Fork
0
You've already forked rust
mirror of
https://github.com/rust-lang/rust.git
synced
2025-06-22 20:47:48 +00:00
Code
Issues
Packages
Projects
Releases
Wiki
Activity
55b6f64902
rust
/
tests
/
ui
/
binop
/
binop-mul-bool.rs
4 lines
87 B
Rust
Raw
Normal View
History
Unescape
Escape
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-18 02:59:51 +00:00
// error-pattern:cannot multiply `bool` by `bool`
Fail typechecking for bad binop/type combinations Includes assignment operations. Add regression tests for lots of less useful, less used or unexpected combinations, as well as a selection of compile-fail tests. Closes #500 (again!)
2011-06-24 21:19:58 +00:00
Reformat This changes the indexing syntax from .() to [], the vector syntax from ~[] to [] and the extension syntax from #fmt() to #fmt[]
2011-08-19 22:16:48 +00:00
fn
main
(
)
{
let
x
=
true
*
false
;
}
Reference in New Issue
Copy Permalink