From 34a80343dbdbe2042f281ad9d1649ef13f5eeebc Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Mon, 20 Nov 2023 17:12:08 +0100 Subject: [PATCH] Prefer `cursor_with_offset(TextIndex::ZERO)` ...than `Default::default()`, which doesn't say much at the call-site. --- crates/codegen/parser/runtime/src/parse_output.rs | 4 ++-- .../codegen/parser/runtime/src/support/parser_function.rs | 7 +++++-- .../outputs/cargo/crate/src/generated/parse_output.rs | 4 ++-- .../cargo/crate/src/generated/support/parser_function.rs | 7 +++++-- .../outputs/npm/crate/src/generated/parse_output.rs | 4 ++-- .../npm/crate/src/generated/support/parser_function.rs | 7 +++++-- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/crates/codegen/parser/runtime/src/parse_output.rs b/crates/codegen/parser/runtime/src/parse_output.rs index d100586fe7..34571bb4a0 100644 --- a/crates/codegen/parser/runtime/src/parse_output.rs +++ b/crates/codegen/parser/runtime/src/parse_output.rs @@ -1,4 +1,4 @@ -use crate::{cst, cursor::Cursor, parse_error::ParseError}; +use crate::{cst, cursor::Cursor, parse_error::ParseError, text_index::TextIndex}; #[derive(Debug, PartialEq)] pub struct ParseOutput { @@ -21,6 +21,6 @@ impl ParseOutput { /// Creates a cursor that starts at the root of the parse tree. pub fn create_tree_cursor(&self) -> Cursor { - return self.parse_tree.cursor_with_offset(Default::default()); + return self.parse_tree.cursor_with_offset(TextIndex::ZERO); } } diff --git a/crates/codegen/parser/runtime/src/support/parser_function.rs b/crates/codegen/parser/runtime/src/support/parser_function.rs index 8313ee41a4..01ceecf515 100644 --- a/crates/codegen/parser/runtime/src/support/parser_function.rs +++ b/crates/codegen/parser/runtime/src/support/parser_function.rs @@ -1,7 +1,10 @@ use std::rc::Rc; use super::{ - super::{cst, kinds::TokenKind, parse_error::ParseError, parse_output::ParseOutput}, + super::{ + cst, kinds::TokenKind, parse_error::ParseError, parse_output::ParseOutput, + text_index::TextIndex, + }, context::ParserContext, parser_result::*, }; @@ -95,7 +98,7 @@ where debug_assert_eq!( errors.len() > 0, parse_tree - .cursor_with_offset(Default::default()) + .cursor_with_offset(TextIndex::ZERO) .any(|x| x.as_token_with_kind(&[TokenKind::SKIPPED]).is_some()) ); diff --git a/crates/solidity/outputs/cargo/crate/src/generated/parse_output.rs b/crates/solidity/outputs/cargo/crate/src/generated/parse_output.rs index ef56793fd5..74b55b5eb5 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/parse_output.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/parse_output.rs @@ -1,6 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::{cst, cursor::Cursor, parse_error::ParseError}; +use crate::{cst, cursor::Cursor, parse_error::ParseError, text_index::TextIndex}; #[derive(Debug, PartialEq)] pub struct ParseOutput { @@ -23,6 +23,6 @@ impl ParseOutput { /// Creates a cursor that starts at the root of the parse tree. pub fn create_tree_cursor(&self) -> Cursor { - return self.parse_tree.cursor_with_offset(Default::default()); + return self.parse_tree.cursor_with_offset(TextIndex::ZERO); } } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/parser_function.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/parser_function.rs index 5674e78d03..1e9e40a2b5 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/parser_function.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/parser_function.rs @@ -3,7 +3,10 @@ use std::rc::Rc; use super::{ - super::{cst, kinds::TokenKind, parse_error::ParseError, parse_output::ParseOutput}, + super::{ + cst, kinds::TokenKind, parse_error::ParseError, parse_output::ParseOutput, + text_index::TextIndex, + }, context::ParserContext, parser_result::*, }; @@ -97,7 +100,7 @@ where debug_assert_eq!( errors.len() > 0, parse_tree - .cursor_with_offset(Default::default()) + .cursor_with_offset(TextIndex::ZERO) .any(|x| x.as_token_with_kind(&[TokenKind::SKIPPED]).is_some()) ); diff --git a/crates/solidity/outputs/npm/crate/src/generated/parse_output.rs b/crates/solidity/outputs/npm/crate/src/generated/parse_output.rs index ef56793fd5..74b55b5eb5 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/parse_output.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/parse_output.rs @@ -1,6 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::{cst, cursor::Cursor, parse_error::ParseError}; +use crate::{cst, cursor::Cursor, parse_error::ParseError, text_index::TextIndex}; #[derive(Debug, PartialEq)] pub struct ParseOutput { @@ -23,6 +23,6 @@ impl ParseOutput { /// Creates a cursor that starts at the root of the parse tree. pub fn create_tree_cursor(&self) -> Cursor { - return self.parse_tree.cursor_with_offset(Default::default()); + return self.parse_tree.cursor_with_offset(TextIndex::ZERO); } } diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/parser_function.rs b/crates/solidity/outputs/npm/crate/src/generated/support/parser_function.rs index 5674e78d03..1e9e40a2b5 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/parser_function.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/parser_function.rs @@ -3,7 +3,10 @@ use std::rc::Rc; use super::{ - super::{cst, kinds::TokenKind, parse_error::ParseError, parse_output::ParseOutput}, + super::{ + cst, kinds::TokenKind, parse_error::ParseError, parse_output::ParseOutput, + text_index::TextIndex, + }, context::ParserContext, parser_result::*, }; @@ -97,7 +100,7 @@ where debug_assert_eq!( errors.len() > 0, parse_tree - .cursor_with_offset(Default::default()) + .cursor_with_offset(TextIndex::ZERO) .any(|x| x.as_token_with_kind(&[TokenKind::SKIPPED]).is_some()) );