Simplify LinterResult, avoid cloning ParseError (#11903)

## Summary

Follow-up to #11902

This PR simplifies the `LinterResult` struct by avoiding the generic and
not store the `ParseError`.

This is possible because the callers already have access to the
`ParseError` via the `Parsed` output. This also means that we can
simplify the return type of `check_path` and avoid the generic `T` on
`LinterResult`.

## Test Plan

`cargo insta test`
This commit is contained in:
Dhruv Manilawala 2024-06-27 07:56:08 +05:30 committed by Micha Reiser
parent 73851e73ab
commit 72b6c26101
10 changed files with 96 additions and 99 deletions

View file

@ -68,7 +68,10 @@ pub(crate) fn fix_all(
// which is inconsistent with how `ruff check --fix` works.
let FixerResult {
transformed,
result: LinterResult { error, .. },
result: LinterResult {
has_syntax_error: has_error,
..
},
..
} = ruff_linter::linter::lint_fix(
&query.virtual_file_path(),
@ -80,11 +83,9 @@ pub(crate) fn fix_all(
source_type,
)?;
if let Some(error) = error {
if has_error {
// abort early if a parsing error occurred
return Err(anyhow::anyhow!(
"A parsing error occurred during `fix_all`: {error}"
));
return Err(anyhow::anyhow!("A parsing error occurred during `fix_all`"));
}
// fast path: if `transformed` is still borrowed, no changes were made and we can return early