mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Remove lexing and parsing from the linter benchmark (#9264)
## Summary This PR adds some helper structs to the linter paths to enable passing in the pre-computed tokens and parsed source code during benchmarking, to remove lexing and parsing from the overall linter benchmark measurement. We already remove parsing for the formatter, and we have separate benchmarks for the lexer and the parser, so this should make it much easier to measure linter performance changes.
This commit is contained in:
parent
6d0c9c4e95
commit
9d6444138b
8 changed files with 144 additions and 30 deletions
|
@ -1293,7 +1293,7 @@ impl FusedIterator for Lexer<'_> {}
|
|||
/// [lexer] implementation.
|
||||
///
|
||||
/// [lexer]: crate::lexer
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct LexicalError {
|
||||
/// The type of error that occurred.
|
||||
pub error: LexicalErrorType,
|
||||
|
@ -1309,7 +1309,7 @@ impl LexicalError {
|
|||
}
|
||||
|
||||
/// Represents the different types of errors that can occur during lexing.
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum LexicalErrorType {
|
||||
// TODO: Can probably be removed, the places it is used seem to be able
|
||||
// to use the `UnicodeError` variant instead.
|
||||
|
|
|
@ -409,7 +409,7 @@ pub(crate) fn concatenated_strings(
|
|||
|
||||
// TODO: consolidate these with ParseError
|
||||
/// An error that occurred during parsing of an f-string.
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
struct FStringError {
|
||||
/// The type of error that occurred.
|
||||
pub(crate) error: FStringErrorType,
|
||||
|
@ -427,7 +427,7 @@ impl From<FStringError> for LexicalError {
|
|||
}
|
||||
|
||||
/// Represents the different types of errors that can occur during parsing of an f-string.
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum FStringErrorType {
|
||||
/// Expected a right brace after an opened left brace.
|
||||
UnclosedLbrace,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue