Make DisplayParseError an error type (#9325)

## Summary

This is a non-behavior-changing refactor to follow-up
https://github.com/astral-sh/ruff/pull/9321 by modifying
`DisplayParseError` to use owned data and make it useable as a
standalone error type (rather than using references and implementing
`Display`). I don't feel very strongly either way. I thought it was
awkward that the `FormatCommandError` had two branches in the display
path, and wanted to represent the `Parse` vs. other cases as a separate
enum, so here we are.
This commit is contained in:
Charlie Marsh 2023-12-31 11:46:29 -04:00 committed by GitHub
parent b3789cd9e9
commit da8a3af524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 132 additions and 91 deletions

View file

@ -339,7 +339,12 @@ pub fn add_noqa_to_path(
if let Some(error) = error {
error!(
"{}",
DisplayParseError::new(&error, &locator.to_source_code(), source_kind, Some(path))
DisplayParseError::from_source_code(
error,
Some(path.to_path_buf()),
&locator.to_source_code(),
source_kind,
)
);
}