Skip to content

Commit

Permalink
Fix some clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhickman committed Sep 1, 2023
1 parent f7097f4 commit d550220
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
9 changes: 2 additions & 7 deletions protox-parse/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use prost_types::field_descriptor_proto;

use crate::{join_span, Span};

#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Default, Copy, Clone, Debug, PartialEq)]
pub(crate) enum Syntax {
#[default]
Proto2,
Proto3,
}
Expand Down Expand Up @@ -309,12 +310,6 @@ pub(crate) struct Method {
pub span: Span,
}

impl Default for Syntax {
fn default() -> Self {
Syntax::Proto2
}
}

impl Int {
pub fn as_i32(&self) -> std::option::Option<i32> {
if self.negative {
Expand Down
4 changes: 2 additions & 2 deletions protox-parse/src/lex/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn merge_string_errors3() {

#[test]
fn string_unicode_escape() {
let source = r#"'\u0068\u0065\u006c\u006c\u006f\u0020\U0001f600'"#;
let source = r"'\u0068\u0065\u006c\u006c\u006f\u0020\U0001f600'";
let mut lexer = Token::lexer(source);

assert_eq!(
Expand All @@ -298,7 +298,7 @@ fn string_unicode_escape() {

#[test]
fn string_invalid_unicode_escape() {
let mut lexer = Token::lexer(r#"'\Uffffffff'"#);
let mut lexer = Token::lexer(r"'\Uffffffff'");
lexer.by_ref().for_each(drop);
assert_eq!(
lexer.extras.errors,
Expand Down
4 changes: 2 additions & 2 deletions protox-parse/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,10 @@ fn field_default_invalid_type() {
);
assert_eq!(
parse(
r#"
r"
message Message {
optional string foo = 1 [default = '\xFF'];
}"#
}"
),
Err(vec![InvalidUtf8String { span: 82..88 }]),
);
Expand Down
5 changes: 4 additions & 1 deletion protox/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ impl Error {

/// Returns true if this is an instance of [`Error::file_not_found()`]
pub fn is_file_not_found(&self) -> bool {
matches!(&*self.kind, ErrorKind::ImportNotFound { .. } | ErrorKind::FileNotIncluded { .. })
matches!(
&*self.kind,
ErrorKind::ImportNotFound { .. } | ErrorKind::FileNotIncluded { .. }
)
}

/// Returns true if this error is caused by an invalid protobuf source file.
Expand Down

0 comments on commit d550220

Please sign in to comment.