<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/src/test/ui/pattern/pattern-error-continue.stderr, branch auto</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=auto</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=auto'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2023-01-11T09:32:08+00:00</updated>
<entry>
<title>Move /src/test to /tests</title>
<updated>2023-01-11T09:32:08+00:00</updated>
<author>
<name>Albert Larsan</name>
<email>74931857+albertlarsan68@users.noreply.github.com</email>
</author>
<published>2023-01-05T08:13:28+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=cf2dff2b1e3fa55fa5415d524200070d0d7aacfe'/>
<id>urn:sha1:cf2dff2b1e3fa55fa5415d524200070d0d7aacfe</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Implementation for 65853</title>
<updated>2022-04-16T06:26:56+00:00</updated>
<author>
<name>Jack Huey</name>
<email>31162821+jackh726@users.noreply.github.com</email>
</author>
<published>2022-01-22T04:50:54+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b6c87c555f3b664f558d137d5f7696a07488157e'/>
<id>urn:sha1:b6c87c555f3b664f558d137d5f7696a07488157e</id>
<content type='text'>
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes.

The algorithm is inspired by Levenshtein distance and longest common sub-sequence.   In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other.

We then modify that algorithm to detect 4 cases:

 - A function input is missing
 - An extra argument was provided
 - The type of an argument is straight up invalid
 - Two arguments have been swapped
 - A subset of the arguments have been shuffled

(We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.)

It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site.

The basic sketch of the algorithm is as follows:

 - Construct a boolean grid, with a row for each argument, and a column for each input.  The cell [i, j] is true if the i'th argument could satisfy the j'th input.
 - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type".
 - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument.
 - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input
 - Swapped / Permuted arguments are identified with a cycle detection algorithm.

As each issue is found, we remove the relevant inputs / arguments and check for more issues.  If we find no issues, we match up any "valid" arguments, and start again.

Note that there's a lot of extra complexity:
 - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix.
 - Closure arguments are wrapped in a tuple and need to be unwrapped
 - We need to resolve closure types after the rest, to allow the most specific type constraints
 - We need to handle imported C functions that might be variadic in their inputs.

I tried to document a lot of this in comments in the code and keep the naming clear.
</content>
</entry>
<entry>
<title>Adjust spans</title>
<updated>2021-08-25T21:40:06+00:00</updated>
<author>
<name>Noah Lev</name>
<email>camelidcamel@gmail.com</email>
</author>
<published>2021-08-25T21:40:06+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=8a6501d28831d864a3af6adf2e0bd83a773062ed'/>
<id>urn:sha1:8a6501d28831d864a3af6adf2e0bd83a773062ed</id>
<content type='text'>
* Highlight the whole pattern if it has no fields
* Highlight the whole definition if it has no fields
* Only highlight the pattern name if the pattern is multi-line
* Determine whether a pattern is multi-line based on distance from name
  to last field, rather than first field
</content>
</entry>
<entry>
<title>Make E0023 spans even more precise</title>
<updated>2021-08-21T23:15:09+00:00</updated>
<author>
<name>Noah Lev</name>
<email>camelidcamel@gmail.com</email>
</author>
<published>2021-08-18T23:13:52+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=0fa3b4f940b4705dc5a1089e917f521b093fd0bc'/>
<id>urn:sha1:0fa3b4f940b4705dc5a1089e917f521b093fd0bc</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Make spans for tuple patterns in E0023 more precise</title>
<updated>2021-08-17T21:27:48+00:00</updated>
<author>
<name>Noah Lev</name>
<email>camelidcamel@gmail.com</email>
</author>
<published>2021-08-17T20:55:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=da25af2940f44f841f91ba038535e8e84c4893f3'/>
<id>urn:sha1:da25af2940f44f841f91ba038535e8e84c4893f3</id>
<content type='text'>
As suggested in #86307.
</content>
</entry>
<entry>
<title>Modify structured suggestion output</title>
<updated>2021-08-11T09:46:24+00:00</updated>
<author>
<name>Esteban Küber</name>
<email>esteban@kuber.com.ar</email>
</author>
<published>2021-06-22T02:07:19+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=99f2977031706dfef6730764d359b9e5d0f673b4'/>
<id>urn:sha1:99f2977031706dfef6730764d359b9e5d0f673b4</id>
<content type='text'>
* On suggestions that include deletions, use a diff inspired output format
* When suggesting addition, use `+` as underline
* Color highlight modified span
</content>
</entry>
<entry>
<title>add suggestion for unit enum variant when matched with a patern</title>
<updated>2021-05-02T11:58:38+00:00</updated>
<author>
<name>Aliénore Bouttefeux</name>
<email>alienore.bouttefeux@gmail.com</email>
</author>
<published>2021-05-02T09:46:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=5cc21d9051e421cab8ca271115b9a6d5ea927679'/>
<id>urn:sha1:5cc21d9051e421cab8ca271115b9a6d5ea927679</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Clarify message about unresolved use</title>
<updated>2020-09-01T17:38:14+00:00</updated>
<author>
<name>Kornel</name>
<email>kornel@geekhood.net</email>
</author>
<published>2020-08-27T12:27:14+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=7ec1de062a1aadef0293bb65e71fbcc7cc24ebfd'/>
<id>urn:sha1:7ec1de062a1aadef0293bb65e71fbcc7cc24ebfd</id>
<content type='text'>
</content>
</entry>
<entry>
<title>MatchExpressionArmPattern: Use more generic wording.</title>
<updated>2019-12-30T12:50:20+00:00</updated>
<author>
<name>Mazdak Farrokhzad</name>
<email>twingoow@gmail.com</email>
</author>
<published>2019-12-30T06:02:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ab050d6a83a9bdc5856a20402b6ea440d474638c'/>
<id>urn:sha1:ab050d6a83a9bdc5856a20402b6ea440d474638c</id>
<content type='text'>
The existing wording was inappropriate for e.g.
`if let Ok(_) = expr { .. }`. The diagnostic would
leak the fact that we desugar to a `match`.
</content>
</entry>
<entry>
<title>Surround types with backticks in type errors</title>
<updated>2019-11-18T19:03:04+00:00</updated>
<author>
<name>Esteban Küber</name>
<email>esteban@kuber.com.ar</email>
</author>
<published>2019-11-15T17:37:01+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=6f8f70624b99460481af25764b9e02d2c67b42c5'/>
<id>urn:sha1:6f8f70624b99460481af25764b9e02d2c67b42c5</id>
<content type='text'>
</content>
</entry>
</feed>
