Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not suggest using | in let assignments #61643

Closed
wants to merge 2 commits into from

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Jun 7, 2019

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 7, 2019
@petrochenkov
Copy link
Contributor

petrochenkov commented Jun 8, 2019

I'd prefer not to do this, but rather address the "a | b won't type-check in any case" / a | b would still not be a legal pattern using a simple heuristic.

If we have a comma separated list PAT, PAT, PAT, parse it until the end, then decide how to interpret it.

  • Collect a set of lower-case identifiers for each PAT (with a small visitor implementing only visit_ident).
  • If those sets are identical, recommend only PAT | PAT | PAT.
  • If none of those sets intersect with each other, recommend only (PAT, PAT, PAT).
  • Otherwise recommend both and let the user disambiguate.

This work is done only in the error case, so it's not a performance issue, and the heuristic would be useful for all positions, not only let.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 8, 2019
@estebank
Copy link
Contributor Author

@petrochenkov I like the idea, but it'll take me a while making the time to implement it.

@estebank estebank closed this Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid suggestion to use a vertical bar in let a, b = x;
4 participants