Skip to content

Commit

Permalink
Apply clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
R1tschY committed Aug 13, 2023
1 parent dfa47a2 commit 8bdc97b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions chassis-proc-macros/src/factory/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn parse_signature(sig: &syn::Signature) -> CompileResult<Request> {
ReturnType::Default => {
return Err(CompileError::IllegalInput(
"Return type is required".to_string(),
sig.span().into(),
sig.span(),
));
}
ReturnType::Type(_, ty) => ty.clone(),
Expand All @@ -19,7 +19,7 @@ fn parse_signature(sig: &syn::Signature) -> CompileResult<Request> {
// TODO: len(args) == 0
Ok(Request {
key: Key::new(*ty.clone())?,
ty: ty.into(),
ty,
name: sig.ident.clone(),
})
}
Expand All @@ -33,7 +33,7 @@ pub fn parse_factory(trait_block: &ItemTrait) -> CompileResult<FactoryTrait> {
if let Some(default) = &func.default {
return Err(CompileError::IllegalInput(
"Default implementation not allowed".to_string(),
default.span().into(),
default.span(),
));
}

Expand All @@ -43,7 +43,7 @@ pub fn parse_factory(trait_block: &ItemTrait) -> CompileResult<FactoryTrait> {
TraitItem::Type(type_item) => {
return Err(CompileError::IllegalInput(
"Associated type not allowed in component".to_string(),
type_item.span().into(),
type_item.span(),
))
}
_ => (),
Expand Down
5 changes: 2 additions & 3 deletions chassis-proc-macros/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl FmtPretty for syn::AngleBracketedGenericArguments {
}
f.write_str("<")?;
dump_punctuated(",", &self.args, f)?;
f.write_str(">").map_err(|err| err.into())
f.write_str(">")
}
}

Expand All @@ -138,7 +138,6 @@ impl FmtPretty for syn::AssocType {
impl FmtPretty for syn::Ident {
fn fmt_pretty(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!("{}", self))
.map_err(|err| err.into())
}
}

Expand Down Expand Up @@ -203,7 +202,7 @@ impl FmtPretty for syn::TypeTuple {
fn fmt_pretty(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("(")?;
dump_punctuated(",", &self.elems, f)?;
f.write_str(")").map_err(|err| err.into())
f.write_str(")")
}
}

Expand Down
10 changes: 5 additions & 5 deletions chassis-proc-macros/src/module/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ pub fn parse_module(

Ok(Module {
name: match *impl_block.self_ty.clone() {
Type::Path(path) if path.qself.is_none() => path.into(),
Type::Path(path) if path.qself.is_none() => path,
self_ty => {
return Err(CompileError::IllegalInput(
"Expected simple type in module impl type".to_string(),
self_ty.span().into(),
self_ty.span(),
))
}
},
Expand All @@ -45,15 +45,15 @@ fn parse_module_fn(module_id: Box<Type>, item: &mut ImplItem) -> CompileResult<B
module: module_id,
injection_point: InjectionPoint {
has_receiver: inject_fn.receiver.is_some(),
qualifier: (&inject_fn.name).to_string(),
qualifier: inject_fn.name.to_string(),
deps: inject_fn
.inputs
.into_iter()
.enumerate()
.map(|(i, input)| {
Ok(Dependency {
parameter_index: i as u8,
span: input.ty.outer_ty.span().into(),
span: input.ty.outer_ty.span(),
key: Key::new(input.ty.outer_ty.clone())?, // TODO: attr, inner type
})
})
Expand All @@ -67,7 +67,7 @@ fn parse_module_fn(module_id: Box<Type>, item: &mut ImplItem) -> CompileResult<B
}
_ => Err(CompileError::IllegalInput(
"Unexpected item in chassis module definition".to_string(),
item.span().into(),
item.span(),
)),
}
}
1 change: 1 addition & 0 deletions chassis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ pub mod __priv {
pub use crate::check::check_factory;

#[inline]
#[allow(clippy::mem_replace_option_with_none)]
pub fn safe_transmute<U: Any, T: Any>(x: U) -> T {
let mut tmp: Option<U> = Some(x);
std::mem::replace(
Expand Down
2 changes: 1 addition & 1 deletion dyn-chassis/src/config/injection_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl InjectionPoint {
}

pub fn member(&self) -> &'static str {
&self.member
self.member
}

pub fn declaring_type(&self) -> Option<TypeId> {
Expand Down
2 changes: 1 addition & 1 deletion dyn-chassis/src/inject/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Injector {
}

// TODO: check if T is in Injector before creating a Provider
impl<'a, T: ?Sized + 'static> Provider<T> for &Injector {
impl<T: ?Sized + 'static> Provider<T> for &Injector {
fn get(&self) -> Option<Arc<T>> {
self.resolve_type::<T>()
}
Expand Down

0 comments on commit 8bdc97b

Please sign in to comment.