]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #48047 - etaoins:fix-ice-for-mismatched-args-on-target-without-span...
authorkennytm <kennytm@gmail.com>
Sat, 10 Feb 2018 06:23:58 +0000 (14:23 +0800)
committerGitHub <noreply@github.com>
Sat, 10 Feb 2018 06:23:58 +0000 (14:23 +0800)
Fix ICE for mismatched args on target without span

Commit 7ed00caacc improved our error reporting by including the target function in our error messages when there is an argument count mismatch. A simple example from the UI tests is:

```
error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 0 arguments
  --> $DIR/closure-arg-count.rs:32:53
   |
32 |     let _it = vec![1, 2, 3].into_iter().enumerate().map(foo);
   |                                                     ^^^ expected function that takes a single 2-tuple as argument
...
44 | fn foo() {}
   | -------- takes 0 arguments
```

However, this assumed the target span was always available. This does not hold true if the target function is in `std` or another crate. A simple example from #48046 is assigning `str::split` to a function type with a different number of arguments.

Fix by omitting all of the labels and suggestions related to the target span when it's not found.

Fixes #48046

r? @estebank

1  2 
src/librustc/traits/error_reporting.rs