Skip to content

Commit

Permalink
chore: fix cargo clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Integral-Tech committed Dec 16, 2024
1 parent e1235d1 commit bb55ef1
Show file tree
Hide file tree
Showing 160 changed files with 208 additions and 217 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/post_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

env:
CARGO_TERM_COLOR: always
FRB_MAIN_RUST_VERSION: 1.79.0
FRB_MAIN_RUST_VERSION: 1.82.0
FRB_MAIN_DART_VERSION: 3.4.0
FRB_MAIN_FLUTTER_VERSION: 3.22.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::library::codegen::generator::api_dart::spec_generator::base::*;
use crate::library::codegen::generator::api_dart::spec_generator::info::ApiDartGeneratorInfoTrait;
use crate::utils::basic_code::dart_header_code::DartHeaderCode;

impl<'a> ApiDartGeneratorClassTrait for DelegateApiDartGenerator<'a> {
impl ApiDartGeneratorClassTrait for DelegateApiDartGenerator<'_> {
fn generate_class(&self) -> Option<ApiDartGeneratedClass> {
match &self.mir {
MirTypeDelegate::PrimitiveEnum(MirTypeDelegatePrimitiveEnum { mir, .. }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::codegen::ir::mir::ty::enumeration::MirEnumMode;
use crate::codegen::ir::mir::ty::MirType;
use crate::library::codegen::generator::api_dart::spec_generator::base::*;

impl<'a> ApiDartGeneratorClassTrait for EnumRefApiDartGenerator<'a> {
impl ApiDartGeneratorClassTrait for EnumRefApiDartGenerator<'_> {
fn generate_class(&self) -> Option<ApiDartGeneratedClass> {
let src = self.mir.get(self.context.mir_pack);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use itertools::Itertools;

const BACKTRACE_IDENT: &str = "backtrace";

impl<'a> EnumRefApiDartGenerator<'a> {
impl EnumRefApiDartGenerator<'_> {
pub(crate) fn generate_mode_complex(
&self,
src: &MirEnum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::utils::basic_code::dart_header_code::DartHeaderCode;
use crate::utils::dart_keywords;
use itertools::Itertools;

impl<'a> EnumRefApiDartGenerator<'a> {
impl EnumRefApiDartGenerator<'_> {
pub(crate) fn generate_mode_simple(
&self,
src: &MirEnum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ pub(crate) trait ApiDartGeneratorClassTrait {
}

// the following have empty implementation
impl<'a> ApiDartGeneratorClassTrait for BoxedApiDartGenerator<'a> {}
impl<'a> ApiDartGeneratorClassTrait for DartFnApiDartGenerator<'a> {}
impl<'a> ApiDartGeneratorClassTrait for DartOpaqueApiDartGenerator<'a> {}
impl<'a> ApiDartGeneratorClassTrait for DynamicApiDartGenerator<'a> {}
impl<'a> ApiDartGeneratorClassTrait for GeneralListApiDartGenerator<'a> {}
impl<'a> ApiDartGeneratorClassTrait for OptionalApiDartGenerator<'a> {}
impl<'a> ApiDartGeneratorClassTrait for PrimitiveApiDartGenerator<'a> {}
impl<'a> ApiDartGeneratorClassTrait for PrimitiveListApiDartGenerator<'a> {}
impl<'a> ApiDartGeneratorClassTrait for RecordApiDartGenerator<'a> {}
impl<'a> ApiDartGeneratorClassTrait for RustAutoOpaqueImplicitApiDartGenerator<'a> {}
impl ApiDartGeneratorClassTrait for BoxedApiDartGenerator<'_> {}
impl ApiDartGeneratorClassTrait for DartFnApiDartGenerator<'_> {}
impl ApiDartGeneratorClassTrait for DartOpaqueApiDartGenerator<'_> {}
impl ApiDartGeneratorClassTrait for DynamicApiDartGenerator<'_> {}
impl ApiDartGeneratorClassTrait for GeneralListApiDartGenerator<'_> {}
impl ApiDartGeneratorClassTrait for OptionalApiDartGenerator<'_> {}
impl ApiDartGeneratorClassTrait for PrimitiveApiDartGenerator<'_> {}
impl ApiDartGeneratorClassTrait for PrimitiveListApiDartGenerator<'_> {}
impl ApiDartGeneratorClassTrait for RecordApiDartGenerator<'_> {}
impl ApiDartGeneratorClassTrait for RustAutoOpaqueImplicitApiDartGenerator<'_> {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::library::codegen::ir::mir::ty::MirTypeTrait;
use crate::utils::basic_code::dart_header_code::DartHeaderCode;
use itertools::{concat, Itertools};

impl<'a> ApiDartGeneratorClassTrait for RustOpaqueApiDartGenerator<'a> {
impl ApiDartGeneratorClassTrait for RustOpaqueApiDartGenerator<'_> {
fn generate_class(&self) -> Option<ApiDartGeneratedClass> {
let Info {
dart_api_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::codegen::generator::api_dart::spec_generator::misc::{
use crate::codegen::ir::mir::ty::MirType;
use crate::library::codegen::generator::api_dart::spec_generator::base::*;

impl<'a> ApiDartGeneratorClassTrait for StructRefApiDartGenerator<'a> {
impl ApiDartGeneratorClassTrait for StructRefApiDartGenerator<'_> {
fn generate_class(&self) -> Option<ApiDartGeneratedClass> {
let src = self.mir.get(self.context.mir_pack);
let comments = generate_dart_comments(&src.comments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::library::codegen::generator::api_dart::spec_generator::base::*;
use crate::library::codegen::generator::api_dart::spec_generator::info::ApiDartGeneratorInfoTrait;
use itertools::Itertools;

impl<'a> StructRefApiDartGenerator<'a> {
impl StructRefApiDartGenerator<'_> {
#[allow(clippy::too_many_arguments)]
pub(crate) fn generate_mode_freezed(
&self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::library::codegen::generator::api_dart::spec_generator::base::*;
use crate::library::codegen::generator::api_dart::spec_generator::info::ApiDartGeneratorInfoTrait;
use itertools::Itertools;

impl<'a> StructRefApiDartGenerator<'a> {
impl StructRefApiDartGenerator<'_> {
#[allow(clippy::too_many_arguments)]
pub(crate) fn generate_mode_non_freezed(
&self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::codegen::generator::api_dart::spec_generator::class::ApiDartGenerated
use crate::codegen::ir::mir::ty::MirType;
use crate::library::codegen::generator::api_dart::spec_generator::base::*;

impl<'a> ApiDartGeneratorClassTrait for TraitDefApiDartGenerator<'a> {
impl ApiDartGeneratorClassTrait for TraitDefApiDartGenerator<'_> {
fn generate_class(&self) -> Option<ApiDartGeneratedClass> {
let dart_api_type = &self.mir.name.name;
let methods = generate_api_methods(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ pub(crate) trait ApiDartGeneratorInfoTrait {
}
}

impl<'a> ApiDartGeneratorInfoTrait for BoxedApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for BoxedApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
let inner = ApiDartGenerator::new(self.mir.inner.clone(), self.context);
inner.dart_api_type()
}
}

impl<'a> ApiDartGeneratorInfoTrait for DartFnApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for DartFnApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
format!(
"FutureOr<{}> Function({})",
Expand All @@ -39,13 +39,13 @@ impl<'a> ApiDartGeneratorInfoTrait for DartFnApiDartGenerator<'a> {
}
}

impl<'a> ApiDartGeneratorInfoTrait for DartOpaqueApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for DartOpaqueApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
"Object".to_owned()
}
}

impl<'a> ApiDartGeneratorInfoTrait for DelegateApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for DelegateApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
match &self.mir {
MirTypeDelegate::Array(array) => array.dart_api_type(self.context),
Expand Down Expand Up @@ -142,33 +142,33 @@ impl MirTypeDelegateArray {
}
}

impl<'a> ApiDartGeneratorInfoTrait for DynamicApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for DynamicApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
"dynamic".to_owned()
}
}

impl<'a> ApiDartGeneratorInfoTrait for EnumRefApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for EnumRefApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
self.mir.ident.0.name.to_string()
}
}

impl<'a> ApiDartGeneratorInfoTrait for GeneralListApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for GeneralListApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
let inner = ApiDartGenerator::new(self.mir.inner.clone(), self.context);
format!("List<{}>", inner.dart_api_type())
}
}

impl<'a> ApiDartGeneratorInfoTrait for OptionalApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for OptionalApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
let inner = ApiDartGenerator::new(self.mir.inner.clone(), self.context);
format!("{}?", inner.dart_api_type())
}
}

impl<'a> ApiDartGeneratorInfoTrait for PrimitiveApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for PrimitiveApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
match &self.mir {
MirTypePrimitive::U8
Expand All @@ -187,7 +187,7 @@ impl<'a> ApiDartGeneratorInfoTrait for PrimitiveApiDartGenerator<'a> {
}
}

impl<'a> ApiDartGeneratorInfoTrait for PrimitiveListApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for PrimitiveListApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
if self.mir.strict_dart_type {
match &self.mir.primitive {
Expand Down Expand Up @@ -218,7 +218,7 @@ impl<'a> ApiDartGeneratorInfoTrait for PrimitiveListApiDartGenerator<'a> {
}
}

impl<'a> ApiDartGeneratorInfoTrait for RecordApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for RecordApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
let values = (self.mir.values.iter())
.map(|ty| ApiDartGenerator::new(ty.clone(), self.context).dart_api_type())
Expand All @@ -229,14 +229,14 @@ impl<'a> ApiDartGeneratorInfoTrait for RecordApiDartGenerator<'a> {
}
}

impl<'a> ApiDartGeneratorInfoTrait for RustAutoOpaqueImplicitApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for RustAutoOpaqueImplicitApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
let inner = ApiDartGenerator::new(self.mir.inner.clone(), self.context);
inner.dart_api_type()
}
}

impl<'a> ApiDartGeneratorInfoTrait for RustOpaqueApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for RustOpaqueApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
(self.context.config.dart_type_rename)
.get(&canonicalize_rust_type(&self.mir.inner.0.with_static_lifetime()).unwrap())
Expand All @@ -247,7 +247,7 @@ impl<'a> ApiDartGeneratorInfoTrait for RustOpaqueApiDartGenerator<'a> {
}
}

impl<'a> ApiDartGeneratorInfoTrait for StructRefApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for StructRefApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
self.mir.ident.0.name.to_string()
}
Expand All @@ -264,7 +264,7 @@ impl<'a> ApiDartGeneratorInfoTrait for StructRefApiDartGenerator<'a> {
}
}

impl<'a> ApiDartGeneratorInfoTrait for TraitDefApiDartGenerator<'a> {
impl ApiDartGeneratorInfoTrait for TraitDefApiDartGenerator<'_> {
fn dart_api_type(&self) -> String {
self.mir.name.name.to_string()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::codegen::generator::codec::sse::ty::*;
use crate::library::codegen::generator::codec::sse::lang::LangTrait;

impl<'a> CodecSseTyTrait for BoxedCodecSseTy<'a> {
impl CodecSseTyTrait for BoxedCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
let wrapper = match lang {
Lang::DartLang(_) => "",
Expand All @@ -25,7 +25,7 @@ impl<'a> CodecSseTyTrait for BoxedCodecSseTy<'a> {
}
}

impl<'a> BoxedCodecSseTy<'a> {
impl BoxedCodecSseTy<'_> {
fn should_generate(&self, lang: &Lang) -> bool {
// The fake Box is only needed for CST codec, thus here we mostly ignore it.
self.mir.exist_in_real_api || matches!(lang, Lang::DartLang(_))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::codegen::generator::codec::sse::ty::delegate::simple_delegate_encode;
use crate::codegen::generator::codec::sse::ty::*;

impl<'a> CodecSseTyTrait for DartFnCodecSseTy<'a> {
impl CodecSseTyTrait for DartFnCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
self.should_generate(lang).then(|| {
simple_delegate_encode(
Expand All @@ -17,7 +17,7 @@ impl<'a> CodecSseTyTrait for DartFnCodecSseTy<'a> {
}
}

impl<'a> DartFnCodecSseTy<'a> {
impl DartFnCodecSseTy<'_> {
fn should_generate(&self, lang: &Lang) -> bool {
!matches!(lang, Lang::RustLang(_))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::codegen::generator::codec::sse::ty::delegate::{
};
use crate::codegen::generator::codec::sse::ty::*;

impl<'a> CodecSseTyTrait for DartOpaqueCodecSseTy<'a> {
impl CodecSseTyTrait for DartOpaqueCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
Some(match lang {
Lang::DartLang(_) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::library::codegen::generator::api_dart::spec_generator::info::ApiDartG
use convert_case::{Case, Casing};
use itertools::Itertools;

impl<'a> CodecSseTyTrait for DelegateCodecSseTy<'a> {
impl CodecSseTyTrait for DelegateCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
let inner_expr = match lang {
Lang::DartLang(_) => match &self.mir {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::codegen::generator::codec::sse::ty::delegate::generate_unimplemented_
use crate::codegen::generator::codec::sse::ty::*;
use crate::library::codegen::generator::codec::sse::lang::LangTrait;

impl<'a> CodecSseTyTrait for DynamicCodecSseTy<'a> {
impl CodecSseTyTrait for DynamicCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
Some(format!(
"{};",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::library::codegen::generator::codec::sse::lang::LangTrait;
use crate::utils::namespace::NamespacedName;
use itertools::Itertools;

impl<'a> CodecSseTyTrait for EnumRefCodecSseTy<'a> {
impl CodecSseTyTrait for EnumRefCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
let src = self.mir.get(self.context.mir_pack);
Some(generate_enum_encode_rust_general(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::codegen::generator::codec::sse::ty::*;
use crate::library::codegen::generator::api_dart::spec_generator::info::ApiDartGeneratorInfoTrait;
use crate::library::codegen::generator::codec::sse::lang::LangTrait;

impl<'a> CodecSseTyTrait for GeneralListCodecSseTy<'a> {
impl CodecSseTyTrait for GeneralListCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
Some(general_list_generate_encode(lang, &self.mir.inner))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::codegen::generator::codec::sse::ty::*;
use crate::library::codegen::generator::codec::sse::lang::LangTrait;

impl<'a> CodecSseTyTrait for OptionalCodecSseTy<'a> {
impl CodecSseTyTrait for OptionalCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
let self_is_not_null = match lang {
Lang::DartLang(_) => "self != null",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::codegen::generator::codec::sse::ty::*;

impl<'a> CodecSseTyTrait for PrimitiveCodecSseTy<'a> {
impl CodecSseTyTrait for PrimitiveCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
let dart_cast = match self.mir {
MirTypePrimitive::Bool => " ? 1 : 0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::codegen::generator::codec::sse::ty::primitive::get_serializer_dart_po
use crate::codegen::generator::codec::sse::ty::*;
use crate::library::codegen::generator::codec::sse::lang::LangTrait;

impl<'a> CodecSseTyTrait for PrimitiveListCodecSseTy<'a> {
impl CodecSseTyTrait for PrimitiveListCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
match lang {
Lang::DartLang(_) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::codegen::generator::codec::sse::ty::structure::GeneralizedStructGener
use crate::codegen::generator::codec::sse::ty::*;
use crate::codegen::generator::misc::struct_or_record::StructOrRecord;

impl<'a> CodecSseTyTrait for RecordCodecSseTy<'a> {
impl CodecSseTyTrait for RecordCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
Some(self.new_generalized_generator().generate_encode(lang))
}
Expand All @@ -15,7 +15,7 @@ impl<'a> CodecSseTyTrait for RecordCodecSseTy<'a> {
}
}

impl<'a> RecordCodecSseTy<'a> {
impl RecordCodecSseTy<'_> {
fn new_generalized_generator(&self) -> GeneralizedStructGenerator {
GeneralizedStructGenerator::new(
self.mir.inner.get(self.context.mir_pack).clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::codegen::generator::codec::sse::ty::*;
use crate::codegen::ir::mir::func::OwnershipMode;
use convert_case::{Case, Casing};

impl<'a> CodecSseTyTrait for RustAutoOpaqueImplicitCodecSseTy<'a> {
impl CodecSseTyTrait for RustAutoOpaqueImplicitCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
match lang {
Lang::DartLang(_) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::library::codegen::generator::api_dart::spec_generator::info::ApiDartG
use crate::library::codegen::generator::codec::sse::lang::LangTrait;
use convert_case::{Case, Casing};

impl<'a> CodecSseTyTrait for RustOpaqueCodecSseTy<'a> {
impl CodecSseTyTrait for RustOpaqueCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
Some(generate_generalized_rust_opaque_encode(
lang,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::codegen::ir::mir::ty::structure::MirStruct;
use crate::library::codegen::generator::codec::sse::lang::LangTrait;
use itertools::Itertools;

impl<'a> CodecSseTyTrait for StructRefCodecSseTy<'a> {
impl CodecSseTyTrait for StructRefCodecSseTy<'_> {
fn generate_encode(&self, lang: &Lang) -> Option<String> {
Some(self.new_generalized_generator().generate_encode(lang))
}
Expand All @@ -19,7 +19,7 @@ impl<'a> CodecSseTyTrait for StructRefCodecSseTy<'a> {
}
}

impl<'a> StructRefCodecSseTy<'a> {
impl StructRefCodecSseTy<'_> {
fn new_generalized_generator(&self) -> GeneralizedStructGenerator {
GeneralizedStructGenerator::new(
self.mir.get(self.context.mir_pack).clone(),
Expand Down
Loading

0 comments on commit bb55ef1

Please sign in to comment.