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

Implement Ord for Severity #335

Closed
bjchambers opened this issue Aug 17, 2021 · 3 comments
Closed

Implement Ord for Severity #335

bjchambers opened this issue Aug 17, 2021 · 3 comments

Comments

@bjchambers
Copy link

This would allow determining the max severity as diagnostics.iter().map(|d| d.severity).max(). As is, there is no way (except manually matching) to determine whether there were diagnostics over a certain severity (eg., to fail if an error is reported but proceed if there are only warnings).

@Johann150
Copy link
Collaborator

Johann150 commented Aug 17, 2021

I'm not sure this is even necessary, there is already a doc-test for this that passes:

/// ```rust
/// use codespan_reporting::diagnostic::Severity;
///
/// assert!(Severity::Bug > Severity::Error);
/// assert!(Severity::Error > Severity::Warning);
/// assert!(Severity::Warning > Severity::Note);
/// assert!(Severity::Note > Severity::Help);
/// ```

https://github.com/brendanzab/codespan/runs/3300809770#step:4:247

But sure, if that doesnt work, it can be added, since its already intended anyway.

@bjchambers
Copy link
Author

I believe that Severity::Bug > Severity::Error works via the PartialOrd, where a return of None would correspond to false. But max requires Ord to indicate that all values are comparable.

@Johann150
Copy link
Collaborator

resolved with 5909730

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants