]> git.lizzy.rs Git - rust.git/commitdiff
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)
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

1  2 
src/librustc_typeck/check/demand.rs
src/librustc_typeck/check/expr.rs
src/librustc_typeck/check/mod.rs

Simple merge
Simple merge
Simple merge