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

@ -23,7 +23,7 @@ use ruff_text_size::Ranged;
use crate::directives;
use crate::fix::{fix_file, FixResult};
use crate::linter::{check_path, LinterResult};
use crate::linter::check_path;
use crate::message::{Emitter, EmitterContext, Message, TextEmitter};
use crate::packaging::detect_package_root;
use crate::registry::AsRule;
@ -119,10 +119,7 @@ pub(crate) fn test_contents<'a>(
&locator,
&indexer,
);
let LinterResult {
data: diagnostics,
error,
} = check_path(
let diagnostics = check_path(
path,
path.parent()
.and_then(|parent| detect_package_root(parent, &settings.namespace_packages)),
@ -137,7 +134,7 @@ pub(crate) fn test_contents<'a>(
&parsed,
);
let source_has_errors = error.is_some();
let source_has_errors = !parsed.is_valid();
// Detect fixes that don't converge after multiple iterations.
let mut iterations = 0;
@ -186,10 +183,7 @@ pub(crate) fn test_contents<'a>(
&indexer,
);
let LinterResult {
data: fixed_diagnostics,
..
} = check_path(
let fixed_diagnostics = check_path(
path,
None,
&locator,