added try_find_description to distinguish no desc from invalid code

This commit is contained in:
Jake Vossen
2020-02-28 15:32:09 -07:00
parent e9bca510fe
commit 5f3ffee6b7
5 changed files with 42 additions and 17 deletions

View File

@@ -419,10 +419,10 @@ impl DiagnosticCode {
DiagnosticId::Error(s) => s,
DiagnosticId::Lint(s) => s,
};
let explanation =
je.registry.as_ref().and_then(|registry| registry.find_description(&s));
let je_result =
je.registry.as_ref().map(|registry| registry.try_find_description(&s)).unwrap();
DiagnosticCode { code: s, explanation }
DiagnosticCode { code: s, explanation: je_result.unwrap_or(None) }
})
}
}