Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings for 1.68 toolchain #178

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<'a> Iterator for NameSpliter<'a> {
let mut meet_lower = false;
for i in self.pos..self.name.len() {
let c = self.name[i];
if (b'A'..=b'Z').contains(&c) {
if c.is_ascii_uppercase() {
if meet_lower {
// So it should be AaA or aaA
pos = i;
Expand Down
9 changes: 2 additions & 7 deletions ttrpc-codegen/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@ use crate::str_lit::StrLit;
use protobuf_support::lexer::float;

/// Protobox syntax
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
Copy link
Member

@Tim-Zhang Tim-Zhang Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change could cause whole project not compatible with lower rust version(<1.66) anymore.
So I think I should limit the Clippy versions instead of this pr.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting. Should we add a skip statement?

What is the typical support for older versions of rust?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have file a PR to lock the rust/clippy version #179

pub enum Syntax {
/// Protobuf syntax [2](https://developers.google.com/protocol-buffers/docs/proto) (default)
#[default]
Proto2,
/// Protobuf syntax [3](https://developers.google.com/protocol-buffers/docs/proto3)
Proto3,
}

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

/// A field rule
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub enum Rule {
Expand Down
16 changes: 8 additions & 8 deletions ttrpc-codegen/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,11 @@ impl<'a> Lexer<'a> {

// capitalLetter = "A" … "Z"
fn _next_capital_letter_opt(&mut self) -> Option<char> {
self.next_char_if(|c| ('A'..='Z').contains(&c))
self.next_char_if(|c| c.is_ascii_uppercase())
}

fn is_ascii_alphanumeric(c: char) -> bool {
('a'..='z').contains(&c) || ('A'..='Z').contains(&c) || ('0'..='9').contains(&c)
c.is_ascii_lowercase() || c.is_ascii_uppercase() || c.is_ascii_digit()
}

fn next_ident_part(&mut self) -> Option<char> {
Expand All @@ -417,7 +417,7 @@ impl<'a> Lexer<'a> {
// Integer literals

fn is_ascii_hexdigit(c: char) -> bool {
('0'..='9').contains(&c) || ('a'..='f').contains(&c) || ('A'..='F').contains(&c)
c.is_ascii_digit() || ('a'..='f').contains(&c) || ('A'..='F').contains(&c)
}

// hexLit = "0" ( "x" | "X" ) hexDigit { hexDigit }
Expand All @@ -433,7 +433,7 @@ impl<'a> Lexer<'a> {
}

fn is_ascii_digit(c: char) -> bool {
('0'..='9').contains(&c)
c.is_ascii_digit()
}

// decimalLit = ( "1" … "9" ) { decimalDigit }
Expand All @@ -458,7 +458,7 @@ impl<'a> Lexer<'a> {
fn next_hex_digit(&mut self) -> ParserResult<u32> {
let mut clone = *self;
let r = match clone.next_char()? {
c if ('0'..='9').contains(&c) => c as u32 - b'0' as u32,
c if c.is_ascii_digit() => c as u32 - b'0' as u32,
c if ('A'..='F').contains(&c) => c as u32 - b'A' as u32 + 10,
c if ('a'..='f').contains(&c) => c as u32 - b'a' as u32 + 10,
_ => return Err(ParserError::ExpectHexDigit),
Expand All @@ -482,7 +482,7 @@ impl<'a> Lexer<'a> {
fn next_decimal_digit(&mut self) -> ParserResult<u32> {
let mut clone = *self;
let r = match clone.next_char()? {
c if ('0'..='9').contains(&c) => c as u32 - '0' as u32,
c if c.is_ascii_digit() => c as u32 - '0' as u32,
_ => return Err(ParserError::ExpectDecDigit),
};
*self = clone;
Expand All @@ -492,7 +492,7 @@ impl<'a> Lexer<'a> {
// decimals = decimalDigit { decimalDigit }
fn next_decimal_digits(&mut self) -> ParserResult<()> {
self.next_decimal_digit()?;
self.take_while(|c| ('0'..='9').contains(&c));
self.take_while(|c| c.is_ascii_digit());
Ok(())
}

Expand Down Expand Up @@ -1029,7 +1029,7 @@ impl<'a> Parser<'a> {
}

fn is_ascii_uppercase(c: char) -> bool {
('A'..='Z').contains(&c)
c.is_ascii_uppercase()
}

// groupName = capitalLetter { letter | decimalDigit | "_" }
Expand Down