Commit 5bc4980
authored
Rollup merge of rust-lang#107175 - compiler-errors:bad-types-in-vec-push, r=estebank
Fix escaping inference var ICE in `point_at_expr_source_of_inferred_type`
Fixes rust-lang#107158
`point_at_expr_source_of_inferred_type` uses `lookup_probe` to adjust the self type of a method receiver -- but that method returns inference variables from inside a probe. That means that the ty vars are no longer valid, so we can't use any infcx methods on them.
Also, pass some extra span info to hack a quick solution to bad labels, resulting in this diagnostic improvement:
```rust
fn example2() {
let mut x = vec![1];
x.push("");
}
```
```diff
error[E0308]: mismatched types
--> src/main.rs:5:12
|
5 | x.push("");
| ---- ^^
| | |
| | expected integer, found `&str`
- | | this is of type `&'static str`, which causes `x` to be inferred as `Vec<{integer}>`
| arguments to this method are incorrect
```
(since that "which causes `x` to be inferred as `Vec<{integer}>` part is wrong)
r? `@estebank`
(we really should make this code better in general, cc rust-lang#106590, but that's a bit bigger issue that needs some more thinking about)File tree
4 files changed
+79
-18
lines changed- compiler/rustc_hir_typeck/src
- fn_ctxt
- tests/ui/typeck
4 files changed
+79
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
225 | 226 | | |
226 | 227 | | |
227 | 228 | | |
| |||
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
273 | | - | |
| 274 | + | |
274 | 275 | | |
275 | 276 | | |
276 | 277 | | |
| |||
281 | 282 | | |
282 | 283 | | |
283 | 284 | | |
284 | | - | |
| 285 | + | |
285 | 286 | | |
286 | 287 | | |
287 | 288 | | |
| |||
333 | 334 | | |
334 | 335 | | |
335 | 336 | | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
343 | 346 | | |
344 | 347 | | |
345 | 348 | | |
| |||
382 | 385 | | |
383 | 386 | | |
384 | 387 | | |
| 388 | + | |
385 | 389 | | |
386 | 390 | | |
387 | 391 | | |
388 | 392 | | |
389 | 393 | | |
390 | | - | |
| 394 | + | |
391 | 395 | | |
392 | 396 | | |
393 | 397 | | |
| |||
406 | 410 | | |
407 | 411 | | |
408 | 412 | | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
415 | 421 | | |
416 | 422 | | |
417 | 423 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
808 | 808 | | |
809 | 809 | | |
810 | 810 | | |
811 | | - | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
812 | 818 | | |
813 | 819 | | |
814 | 820 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
0 commit comments