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

Gives a nicer error if the programmer uses the <=> operator. #89871

Closed
wants to merge 2 commits into from
Closed

Gives a nicer error if the programmer uses the <=> operator. #89871

wants to merge 2 commits into from

Conversation

moonheart08
Copy link
Contributor

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?

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label 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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(

@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 14, 2021
@moonheart08
Copy link
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants