Skip to content

Commit

Permalink
Merge pull request #499 from evnu/fix-clippy
Browse files Browse the repository at this point in the history
Fix some clippy lints
  • Loading branch information
evnu authored Nov 9, 2022
2 parents b19ff41 + 3e7918c commit 41a85bc
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 13 deletions.
10 changes: 1 addition & 9 deletions rustler/src/codegen_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,7 @@ pub unsafe fn handle_nif_init_call(
let env = Env::new(&(), r_env);
let term = Term::new(env, load_info);

if let Some(inner) = function {
if inner(env, term) {
0
} else {
1
}
} else {
0
}
function.map_or(0, |inner| i32::from(!inner(env, term)))
}

pub fn handle_nif_result<T>(
Expand Down
2 changes: 1 addition & 1 deletion rustler/src/types/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ macro_rules! atoms {
};
{ @internal_make_atom($env:ident, $name:ident = $str:expr) } => {
$crate::types::atom::Atom::from_str($env, $str)
.ok().expect("rustler::atoms!: bad atom string")
.expect("rustler::atoms!: bad atom string")
};
}

Expand Down
2 changes: 1 addition & 1 deletion rustler/src/wrapper/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub unsafe fn make_map_from_arrays(
env,
keys.as_ptr(),
values.as_ptr(),
keys.len() as usize,
keys.len(),
map.as_mut_ptr(),
) == 0
{
Expand Down
2 changes: 1 addition & 1 deletion rustler_bigint/src/big_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn encode_big_integer(big_int: &num_bigint::BigInt) -> Vec<u8> {
out
} else {
let (sign, data) = big_int.to_bytes_le();
let sign = if sign == Sign::Minus { 1 } else { 0 };
let sign = u8::from(sign == Sign::Minus);

let mut out = vec![EXTERNAL_TERM_FORMAT_VERSION];
if data.len() < 256 {
Expand Down
2 changes: 2 additions & 0 deletions rustler_codegen/src/encode_decode_templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub(crate) fn decoder(ctx: &Context, inner: TokenStream) -> TokenStream {

quote! {
impl #impl_generics ::rustler::Decoder<'__rustler_decode_lifetime> for #ident #ty_generics #where_clause {
#[allow(clippy::needless_borrow)]
fn decode(term: ::rustler::Term<'__rustler_decode_lifetime>) -> ::rustler::NifResult<Self> {
#inner
}
Expand All @@ -73,6 +74,7 @@ pub(crate) fn encoder(ctx: &Context, inner: TokenStream) -> TokenStream {

quote! {
impl #impl_generics ::rustler::Encoder for #ident #ty_generics #where_clause {
#[allow(clippy::needless_borrow)]
fn encode<'__rustler__encode_lifetime>(&self, env: ::rustler::Env<'__rustler__encode_lifetime>) -> ::rustler::Term<'__rustler__encode_lifetime> {
#inner
}
Expand Down
2 changes: 1 addition & 1 deletion rustler_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ fn main() {

let dest_path = Path::new(&out_dir).join(SNIPPET_NAME);

fs::write(&dest_path, &api).unwrap();
fs::write(dest_path, api).unwrap();

// The following lines are important to tell Cargo to recompile if something changes.
println!("cargo:rerun-if-changed=build.rs");
Expand Down

0 comments on commit 41a85bc

Please sign in to comment.