From 14d6b1c3dea59b8a8c3836f4d270f1d5c33c57db Mon Sep 17 00:00:00 2001 From: AsukaMinato Date: Sun, 5 Mar 2023 12:09:11 +0900 Subject: [PATCH] Simplify `Default` impl for `ParseError` By implementing `Default` for `ParseErrorCode`, `ParseError` can just `#[derive(Default)]` instead. Closes #9637. --- fish-rust/src/parse_constants.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/fish-rust/src/parse_constants.rs b/fish-rust/src/parse_constants.rs index 9490f8cdf..f65fec561 100644 --- a/fish-rust/src/parse_constants.rs +++ b/fish-rust/src/parse_constants.rs @@ -359,7 +359,13 @@ fn keyword_from_string<'a>(s: impl Into<&'a wstr>) -> ParseKeyword { ParseKeyword::from(s) } -#[derive(Clone)] +impl Default for ParseErrorCode { + fn default() -> Self { + ParseErrorCode::none + } +} + +#[derive(Clone, Default)] pub struct ParseError { /// Text of the error. pub text: WString, @@ -370,17 +376,6 @@ pub struct ParseError { pub source_length: usize, } -impl Default for ParseError { - fn default() -> ParseError { - ParseError { - text: L!("").to_owned(), - code: ParseErrorCode::none, - source_start: 0, - source_length: 0, - } - } -} - impl ParseError { /// Return a string describing the error, suitable for presentation to the user. If /// is_interactive is true, the offending line with a caret is printed as well.