]> git.lizzy.rs Git - rust.git/commit
Account for type error on method arg caused by earlier inference
authorEsteban Küber <esteban@kuber.com.ar>
Thu, 5 Jan 2023 00:18:57 +0000 (00:18 +0000)
committerEsteban Küber <esteban@kuber.com.ar>
Thu, 5 Jan 2023 16:51:17 +0000 (16:51 +0000)
commitc905f5e1b0315f9637b2f7e52c807e46b2e24ee6
tree80bb3b0828e3283eb956188e22ba1e03055fa654
parentad82eedfa190b3cd39a535a6e858d79f69c89ff2
Account for type error on method arg caused by earlier inference

```rust
fn main() {
    let v = Vec::new();
    v.push(0);
    v.push(0);
    v.push("");
}
```

now produces

```
error[E0308]: mismatched types
  --> $DIR/point-at-inference-3.rs:6:12
   |
LL |     v.push(0);
   |            - this is of type `{integer}`, which makes `v` to be inferred as `Vec<{integer}>`
...
LL |     v.push("");
   |       ---- ^^ expected integer, found `&str`
   |       |
   |       arguments to this function are incorrect
   |
note: associated function defined here
  --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
```
compiler/rustc_hir_typeck/src/demand.rs
compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
src/test/ui/type/type-check/point-at-inference-3.rs [new file with mode: 0644]
src/test/ui/type/type-check/point-at-inference-3.stderr [new file with mode: 0644]