Gives a nicer error if the programmer uses the <=> operator.#89871
Closed
moonheart08 wants to merge 2 commits intorust-lang:masterfrom
moonheart08:13-10-21-spaceship-check
Closed
Gives a nicer error if the programmer uses the <=> operator.#89871moonheart08 wants to merge 2 commits intorust-lang:masterfrom moonheart08:13-10-21-spaceship-check
<=> operator.#89871moonheart08 wants to merge 2 commits intorust-lang:masterfrom
moonheart08:13-10-21-spaceship-check
Conversation
Contributor
|
(rust-highfive has picked a reviewer for you, use r? to override) |
notriddle
reviewed
Oct 14, 2021
| // Look for C++'s `<=>` | ||
| let sp = op.span.to(self.token.span); | ||
| self.struct_span_err(sp, &format!("invalid comparison operator `<=>`")) | ||
| .span_suggestion_short( |
Contributor
There was a problem hiding this comment.
It makes no sense to suggest that the spaceship operator be replaced with itself. Instead, use span_label.
Suggested change
| .span_suggestion_short( | |
| .span_label( |
Contributor
Author
|
Closing in favor of trying to generalize the problem. |
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Dec 14, 2021
…i-obk Recover on invalid operators `<>` and `<=>` Thanks to rust-lang#89871 for showing me how to do this. Next, I think it'd be nice to recover on `<=>` too, like rust-lang#89871 intended, if this even works.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Dec 14, 2021
…i-obk Recover on invalid operators `<>` and `<=>` Thanks to rust-lang#89871 for showing me how to do this. Next, I think it'd be nice to recover on `<=>` too, like rust-lang#89871 intended, if this even works.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Produces a better diagnostic than before, directs the user to use Ordering.
Open questions
How should the Ordering recommendation be done? Is doing it as-is fine, or is there some better way?
Should this suggestion be changed to be automatically appliable? How do I do that?