]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #73195 - ayazhafiz:i/73145, r=estebank
authorDylan DPC <dylan.dpc@gmail.com>
Thu, 11 Jun 2020 22:05:33 +0000 (00:05 +0200)
committerGitHub <noreply@github.com>
Thu, 11 Jun 2020 22:05:33 +0000 (00:05 +0200)
commit7bdf7d09b03f8664e02cd1d80972ea7b1c96a4d5
treec0b775c88d0eed84610bb103971e9fe10bbf7eed
parent838d25b5e3cfabce609d9b9cb22653c4961d94b7
parent0c02f8aea9d8b26ad0e02a8ba1333a794844e146
Rollup merge of #73195 - ayazhafiz:i/73145, r=estebank

Provide suggestion to convert numeric op LHS rather than unwrapping RHS

Given a code

```rust
fn foo(x: u8, y: u32) -> bool {
    x > y
}
fn main() {}
```

it could be more helpful to provide a suggestion to do "u32::from(x)"
rather than "y.try_into().unwrap()", since the latter may panic.

We do this by passing the LHS of a binary expression up the stack into
the coercion checker.

Closes #73145
src/librustc_typeck/check/demand.rs
src/librustc_typeck/check/expr.rs
src/librustc_typeck/check/mod.rs