Skip to content

Commit 9522518

Browse files
authored
Merge pull request #671 from rusterlium/clippy
Fix clippy lints
2 parents c2b0a77 + aa99ae1 commit 9522518

File tree

20 files changed

+48
-56
lines changed

20 files changed

+48
-56
lines changed

rustler/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn write_variadic_fn_type(out: &mut String, args: &str, ret: &str) {
4949
}
5050

5151
pub struct CallbacksApiBuilder<'a>(&'a mut String);
52-
impl<'a> ApiBuilder for CallbacksApiBuilder<'a> {
52+
impl ApiBuilder for CallbacksApiBuilder<'_> {
5353
fn init(&mut self) {
5454
writeln!(self.0, "#[allow(dead_code)]").unwrap();
5555
writeln!(self.0, "#[derive(Default, Copy, Clone)]").unwrap();
@@ -78,7 +78,7 @@ impl<'a> ApiBuilder for CallbacksApiBuilder<'a> {
7878
}
7979

8080
pub struct ForwardersApiBuilder<'a>(&'a mut String);
81-
impl<'a> ApiBuilder for ForwardersApiBuilder<'a> {
81+
impl ApiBuilder for ForwardersApiBuilder<'_> {
8282
fn func(&mut self, ret: &str, name: &str, args: &str) {
8383
// This regex takes a list of args with types and return only the name of the args.
8484
//
@@ -135,7 +135,7 @@ impl<'a> ApiBuilder for ForwardersApiBuilder<'a> {
135135

136136
pub struct WriterBuilder<'a>(&'a mut String);
137137

138-
impl<'a> ApiBuilder for WriterBuilder<'a> {
138+
impl ApiBuilder for WriterBuilder<'_> {
139139
fn init(&mut self) {
140140
write!(
141141
self.0,

rustler/src/dynamic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ macro_rules! impl_check {
8585
}
8686

8787
/// ## Type checks
88-
impl<'a> Term<'a> {
88+
impl Term<'_> {
8989
/// Returns an enum representing which type the term is.
9090
/// Note that using the individual `is_*` functions is more
9191
/// efficient for checking a single type.

rustler/src/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct Env<'a> {
3535
/// Two environments are equal if they're the same `NIF_ENV` value.
3636
///
3737
/// A `Env<'a>` is equal to a `Env<'b>` if and only if `'a` and `'b` are the same lifetime.
38-
impl<'a, 'b> PartialEq<Env<'b>> for Env<'a> {
38+
impl<'b> PartialEq<Env<'b>> for Env<'_> {
3939
fn eq(&self, other: &Env<'b>) -> bool {
4040
self.env == other.env
4141
}

rustler/src/resource/registration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ unsafe impl Sync for Registration {}
2424

2525
inventory::collect!(Registration);
2626

27-
impl<'a> Env<'a> {
27+
impl Env<'_> {
2828
/// Register a resource type, see `Registration::register`.
2929
pub fn register<T: Resource>(&self) -> Result<(), ResourceInitError> {
3030
Registration::new::<T>().register(*self)

rustler/src/resource/traits.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type NifResourcePtr = *const ErlNifResourceType;
1212
static mut RESOURCE_TYPES: OnceLock<HashMap<TypeId, usize>> = OnceLock::new();
1313

1414
/// Register an Erlang resource type handle for a particular type given by its `TypeId`
15+
#[allow(static_mut_refs)]
1516
pub(crate) unsafe fn register_resource_type(type_id: TypeId, resource_type: NifResourcePtr) {
1617
RESOURCE_TYPES.get_or_init(Default::default);
1718
RESOURCE_TYPES
@@ -64,6 +65,7 @@ pub trait Resource: Sized + Send + Sync + 'static {
6465
#[doc(hidden)]
6566
pub(crate) trait ResourceExt: 'static {
6667
/// Get the NIF resource type handle for this type if it had been registered before
68+
#[allow(static_mut_refs)]
6769
fn get_resource_type() -> Option<NifResourcePtr> {
6870
let map = unsafe { RESOURCE_TYPES.get()? };
6971
map.get(&TypeId::of::<Self>())

rustler/src/return.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub enum Return<'a> {
77
Error(Error),
88
}
99

10-
unsafe impl<'b> NifReturnable for Return<'b> {
10+
unsafe impl NifReturnable for Return<'_> {
1111
unsafe fn into_returned(self, env: Env) -> NifReturned {
1212
match self {
1313
Return::Term(inner) => NifReturned::Term(inner.as_c_arg()),

rustler/src/sys/functions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub unsafe fn internal_set_symbols(callbacks: DynNifCallbacks) {
1010
DYN_NIF_CALLBACKS = callbacks;
1111
}
1212

13+
#[allow(static_mut_refs)]
1314
pub unsafe fn internal_write_symbols() {
1415
let filler = nif_filler::new();
1516
DYN_NIF_CALLBACKS.write_symbols(filler);

rustler/src/term.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct Term<'a> {
1717
env: Env<'a>,
1818
}
1919

20-
impl<'a> Debug for Term<'a> {
20+
impl Debug for Term<'_> {
2121
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
2222
crate::wrapper::term::fmt(self.as_c_arg(), f)
2323
}
@@ -121,12 +121,12 @@ impl<'a> Term<'a> {
121121
}
122122
}
123123

124-
impl<'a> PartialEq for Term<'a> {
124+
impl PartialEq for Term<'_> {
125125
fn eq(&self, other: &Term) -> bool {
126126
unsafe { enif_is_identical(self.as_c_arg(), other.as_c_arg()) == 1 }
127127
}
128128
}
129-
impl<'a> Eq for Term<'a> {}
129+
impl Eq for Term<'_> {}
130130

131131
fn cmp(lhs: &Term, rhs: &Term) -> Ordering {
132132
let ord = unsafe { enif_compare(lhs.as_c_arg(), rhs.as_c_arg()) };
@@ -137,7 +137,7 @@ fn cmp(lhs: &Term, rhs: &Term) -> Ordering {
137137
}
138138
}
139139

140-
impl<'a> Ord for Term<'a> {
140+
impl Ord for Term<'_> {
141141
fn cmp(&self, other: &Term) -> Ordering {
142142
cmp(self, other)
143143
}
@@ -148,7 +148,7 @@ impl<'a> PartialOrd for Term<'a> {
148148
}
149149
}
150150

151-
impl<'a> Hash for Term<'a> {
151+
impl Hash for Term<'_> {
152152
fn hash<H: Hasher>(&self, state: &mut H) {
153153
// As far as I can see, there is really no way
154154
// to get a seed from the hasher. This is definitely
@@ -157,5 +157,5 @@ impl<'a> Hash for Term<'a> {
157157
}
158158
}
159159

160-
unsafe impl<'a> Sync for Term<'a> {}
161-
unsafe impl<'a> Send for Term<'a> {}
160+
unsafe impl Sync for Term<'_> {}
161+
unsafe impl Send for Term<'_> {}

rustler/src/types/atom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<'a> PartialEq<Term<'a>> for Atom {
106106
}
107107

108108
/// ## Atom terms
109-
impl<'a> Term<'a> {
109+
impl Term<'_> {
110110
/// When the term is an atom, this method will return the string
111111
/// representation of it.
112112
///

rustler/src/types/big_int.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
use crate::{Decoder, Encoder, Env, Error, NifResult, Term};
2-
3-
use num_bigint::{BigInt, Sign};
4-
5-
// From https://www.erlang.org/doc/apps/erts/erl_ext_dist.html
6-
const EXTERNAL_TERM_FORMAT_VERSION: u8 = 131;
7-
const SMALL_INTEGER: u8 = 97;
8-
const INTEGER: u8 = 98;
9-
const SMALL_BIG_EXT: u8 = 110;
10-
const LARGE_BIG_EXT: u8 = 111;
11-
12-
crate::atoms! {
13-
big_int_encoder_invalid_bytes
14-
}
15-
161
/// Implementation of [Decoder](rustler::Decoder) and [Encoder](rustler::Encoder) traits for
172
/// num-bigint.
183
///
@@ -48,6 +33,20 @@ crate::atoms! {
4833
/// }
4934
/// ```
5035
///
36+
use crate::{Decoder, Encoder, Env, Error, NifResult, Term};
37+
38+
use num_bigint::{BigInt, Sign};
39+
40+
// From https://www.erlang.org/doc/apps/erts/erl_ext_dist.html
41+
const EXTERNAL_TERM_FORMAT_VERSION: u8 = 131;
42+
const SMALL_INTEGER: u8 = 97;
43+
const INTEGER: u8 = 98;
44+
const SMALL_BIG_EXT: u8 = 110;
45+
const LARGE_BIG_EXT: u8 = 111;
46+
47+
crate::atoms! {
48+
big_int_encoder_invalid_bytes
49+
}
5150

5251
fn decode_big_integer(input: &[u8]) -> NifResult<BigInt> {
5352
if Some(&EXTERNAL_TERM_FORMAT_VERSION) != input.first() {

0 commit comments

Comments
 (0)