Skip to content

Commit f95ebce

Browse files
committed
Fix clippy
1 parent 567f20b commit f95ebce

14 files changed

+27
-18
lines changed

src/data.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub struct Data<'a> {
2727
pub path: Path,
2828
/// [Type](DataType) of this struct, union or variant.
2929
pub type_: DataType<'a>,
30+
#[cfg_attr(feature = "nightly", allow(unused))]
3031
/// Discriminant of this variant.
3132
pub discriminant: Option<&'a Expr>,
3233
}
@@ -69,7 +70,7 @@ pub enum SimpleType<'a> {
6970
/// Tuple struct or tuple variant.
7071
Tuple(&'a Fields<'a>),
7172
/// Union.
72-
Union(&'a Fields<'a>),
73+
Union(#[allow(unused)] &'a Fields<'a>),
7374
/// Unit variant.
7475
Unit(&'a Pat),
7576
}
@@ -332,10 +333,7 @@ impl<'a> Data<'a> {
332333
}
333334

334335
/// Returns an [`Iterator`] over [`Field`]s.
335-
pub fn iter_fields(
336-
&self,
337-
trait_: Trait,
338-
) -> impl '_ + Iterator<Item = &'_ Field> + DoubleEndedIterator {
336+
pub fn iter_fields(&self, trait_: Trait) -> impl '_ + DoubleEndedIterator<Item = &'_ Field> {
339337
if self.skip(trait_) {
340338
[].iter()
341339
} else {
@@ -354,19 +352,13 @@ impl<'a> Data<'a> {
354352

355353
/// Returns an [`Iterator`] over [`struct@Ident`]s used as temporary
356354
/// variables for destructuring `self`.
357-
pub fn iter_self_ident(
358-
&self,
359-
trait_: Trait,
360-
) -> impl Iterator<Item = &'_ Ident> + DoubleEndedIterator {
355+
pub fn iter_self_ident(&self, trait_: Trait) -> impl DoubleEndedIterator<Item = &'_ Ident> {
361356
self.iter_fields(trait_).map(|field| &field.self_ident)
362357
}
363358

364359
/// Returns an [`Iterator`] over [`struct@Ident`]s used as temporary
365360
/// variables for destructuring `other`.
366-
pub fn iter_other_ident(
367-
&self,
368-
trait_: Trait,
369-
) -> impl Iterator<Item = &'_ Ident> + DoubleEndedIterator {
361+
pub fn iter_other_ident(&self, trait_: Trait) -> impl DoubleEndedIterator<Item = &'_ Ident> {
370362
self.iter_fields(trait_).map(|field| &field.other_ident)
371363
}
372364
}

src/item.rs

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::{Data, Error, Incomparable, Trait};
1212
pub enum Item<'a> {
1313
/// Enum.
1414
Enum {
15+
#[cfg_attr(feature = "nightly", allow(unused))]
1516
/// Type of discriminant used.
1617
discriminant: Discriminant,
1718
/// [`struct@Ident`] of this enum.
@@ -96,6 +97,7 @@ impl Item<'_> {
9697
/// Type of discriminant used.
9798
#[derive(Clone, Copy)]
9899
#[cfg_attr(test, derive(Debug))]
100+
#[cfg_attr(feature = "nightly", allow(unused))]
99101
pub enum Discriminant {
100102
/// The enum has only a single variant.
101103
Single,

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ pub fn derive_where_actual(input: proc_macro::TokenStream) -> proc_macro::TokenS
588588
clean_item.span()
589589
};
590590

591-
match { Input::from_input(span, &item) } {
591+
match Input::from_input(span, &item) {
592592
Ok(Input {
593593
derive_wheres,
594594
generics,

tests/bound.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unused)]
12
mod util;
23

34
use std::marker::PhantomData;

tests/cfg.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unexpected_cfgs, unused)]
12
use std::marker::PhantomData;
23

34
use derive_where::derive_where;

tests/hygiene.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(clippy::clone_on_copy)]
1+
#![allow(clippy::clone_on_copy, unused)]
22

33
mod util;
44

tests/incomparable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unused)]
12
use derive_where::derive_where;
23

34
macro_rules! incomparable {

tests/misc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unused)]
12
use std::marker::PhantomData;
23

34
use derive_where::derive_where;

tests/raw.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unused)]
12
mod util;
23

34
use derive_where::derive_where;

tests/safety.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ fn discriminant() {
1010

1111
assert_eq!(size_of::<isize>(), size_of_val(&discriminant(&Test::A)));
1212

13-
assert_eq!(0_isize, unsafe { transmute(discriminant(&Test::A)) });
14-
assert_eq!(1_isize, unsafe { transmute(discriminant(&Test::B)) });
15-
assert_eq!(2_isize, unsafe { transmute(discriminant(&Test::C)) });
13+
assert_eq!(0_isize, unsafe {
14+
transmute::<std::mem::Discriminant<Test>, isize>(discriminant(&Test::A))
15+
});
16+
assert_eq!(1_isize, unsafe {
17+
transmute::<std::mem::Discriminant<Test>, isize>(discriminant(&Test::B))
18+
});
19+
assert_eq!(2_isize, unsafe {
20+
transmute::<std::mem::Discriminant<Test>, isize>(discriminant(&Test::C))
21+
});
1622
}

tests/skip/field_trait.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unused)]
12
use std::cmp::Ordering;
23

34
use derive_where::derive_where;

tests/skip/struct_trait.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unused)]
12
use std::cmp::Ordering;
23

34
use derive_where::derive_where;

tests/skip/variant_trait.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unused)]
12
use std::cmp::Ordering;
23

34
use derive_where::derive_where;

tests/zeroize.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![cfg(feature = "zeroize")]
2+
#![allow(unused)]
23

34
extern crate zeroize_ as zeroize;
45

0 commit comments

Comments
 (0)