Skip to content

Commit

Permalink
Fixed most clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuri6037 committed Aug 22, 2024
1 parent 63dcb1f commit 220b528
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 15 deletions.
6 changes: 6 additions & 0 deletions compiler/src/compiler/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ pub struct TypePathMap {
type_path_by_name: HashMap<String, String>,
}

impl Default for TypePathMap {
fn default() -> Self {
Self::new()
}
}

impl TypePathMap {
pub fn new() -> Self {
Self {
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/gen/base/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ use crate::gen::base::structure::Utilities;
use crate::gen::template::Template;
use itertools::Itertools;

pub fn generate<'fragment, 'variable, U: Utilities>(
mut template: Template<'fragment, 'variable>,
pub fn generate<'variable, U: Utilities>(
mut template: Template<'_, 'variable>,
e: &'variable Enum,
) -> String {
template
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/gen/base/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ pub fn gen_msg_field_decl<U: Utilities, T: TypeMapper>(
scope.var("type", msg_type).render("decl", &["field"]).unwrap()
}

pub fn generate<'fragment, 'variable, U: Utilities, T: TypeMapper>(
mut template: Template<'fragment, 'variable>,
pub fn generate<'variable, U: Utilities, T: TypeMapper>(
mut template: Template<'_, 'variable>,
msg: &'variable Message,
type_path_by_name: &TypePathMapper<T>,
) -> String {
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/gen/base/message_from_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ pub fn generate_from_slice_impl<U: Utilities, T: TypeMapper>(
.unwrap()
}

pub fn generate<'fragment, 'variable, U: Utilities, T: TypeMapper>(
mut template: Template<'fragment, 'variable>,
pub fn generate<'variable, U: Utilities, T: TypeMapper>(
mut template: Template<'_, 'variable>,
msg: &'variable Message,
type_path_by_name: &TypePathMapper<T>,
) -> String {
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/gen/base/message_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ fn gen_field_write_impl<U: Utilities, T: TypeMapper>(
}
}

pub fn generate<'fragment, 'variable, U: Utilities, T: TypeMapper>(
mut template: Template<'fragment, 'variable>,
pub fn generate<'variable, U: Utilities, T: TypeMapper>(
mut template: Template<'_, 'variable>,
msg: &'variable Message,
type_path_by_name: &TypePathMapper<T>,
) -> String {
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/gen/base/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ pub struct Templates<'fragment, 'variable> {
pub template: Template<'fragment, 'variable>,
}

pub fn generate<'fragment, 'variable, U: Utilities, T: TypeMapper>(
templates: Templates<'fragment, 'variable>,
pub fn generate<'variable, U: Utilities, T: TypeMapper>(
templates: Templates<'_, 'variable>,
s: &'variable Structure,
type_path_by_name: &TypePathMapper<T>,
) -> String {
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/gen/base/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ fn gen_union_as_getters<T: TypeMapper>(
template.scope().var("cases", cases).render("", &["getters"]).unwrap()
}

pub fn generate<'fragment, 'variable, U: Utilities, T: TypeMapper>(
mut template: Template<'fragment, 'variable>,
pub fn generate<'variable, U: Utilities, T: TypeMapper>(
mut template: Template<'_, 'variable>,
u: &'variable Union,
type_path_by_name: &'variable TypePathMapper<T>,
) -> String {
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/gen/swift/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn gen_initializer(template: &Template, msg: &Message, type_path_by_name: &TypeP
.fields
.iter()
.map(|field| gen_msg_field_decl::<SwiftUtils, _>(field, template, type_path_by_name))
.map(|v| format!("{}", &v[..v.len() - 1]))
.map(|v| v[..v.len() - 1].to_string())
.join(", ");
let initializers = msg
.fields
Expand Down
6 changes: 6 additions & 0 deletions compiler/src/gen/swift/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ pub struct SwiftImportSolver {
import_map: HashMap<String, (Option<String>, Protocol)>,
}

impl Default for SwiftImportSolver {
fn default() -> Self {
Self::new()
}
}

impl SwiftImportSolver {
pub fn new() -> Self {
Self {
Expand Down
1 change: 1 addition & 0 deletions compiler/src/gen/template/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use itertools::Itertools;
use regex::Regex;
use std::borrow::Cow;

#[allow(clippy::enum_variant_names)]
enum Convention {
PascalCase,
SnakeCase,
Expand Down
8 changes: 7 additions & 1 deletion compiler/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ pub struct Loader {
imported_models: Vec<(String, model::Protocol)>,
}

impl Default for Loader {
fn default() -> Self {
Self::new()
}
}

impl Loader {
pub fn new() -> Self {
Self {
Expand Down Expand Up @@ -151,7 +157,7 @@ impl<'a> Protoc<'a> {
) -> Result<Vec<Proto>, Error> {
let file_header = self
.file_header
.map(|v| std::fs::read_to_string(v))
.map(std::fs::read_to_string)
.transpose()
.map_err(Error::Io)?
.map(|v| T::generate_file_header(v.lines()));
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/codec/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl BitCodec for BitCodecBE {
value: T,
) {
let mask: usize = (1 << BIT_SIZE) - 1;
let reset_mask = !(mask << 8 - (BIT_SIZE % 8) - BIT_OFFSET);
let reset_mask = !(mask << (8 - (BIT_SIZE % 8) - BIT_OFFSET));
let original = T::read_bytes_be(buffer);
let clean = original & T::from_usize(reset_mask);
let value = (value & T::from_usize(mask)) << T::from_usize(8 - (BIT_SIZE % 8) - BIT_OFFSET);
Expand Down

0 comments on commit 220b528

Please sign in to comment.