Skip to content

Improved pattern for which NetDocErrorKinds are suspicious when?

At !3070 (comment 3217702), @wesleyac looks at this code:

impl HsDescError {
    /// Return true if this error is one that we should report as a suspicious event.
    pub fn should_report_as_suspicious(&self) -> bool {
        use crate::NetdocErrorKind as EK;
        use HsDescError as E;
        #[allow(clippy::match_like_matches_macro)]
        match self {
            E::OuterParsing(e) => match e.netdoc_error_kind() {
                EK::ExtraneousSpace => true,
                _ => false,

and asks:

Seems perhaps unwise to use a wildcard match here, are we sure future errors will all be non-suspicious?

I think that an exhaustive match here would probably not be a great idea, since there are dozens of error types in NetdocErrorKind. Instead we should probably have some intermediary function to use in these cases. I have some design ideas.