Skip to content

Commit 11f653f

Browse files
authored
Merge pull request #36 from alecmocatta/bump
Bump rust
2 parents 01a4d44 + b72f4ac commit 11f653f

File tree

7 files changed

+58
-35
lines changed

7 files changed

+58
-35
lines changed

Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[package]
44
name = "serde_closure"
5-
version = "0.3.2"
5+
version = "0.3.3"
66
license = "MIT OR Apache-2.0"
77
authors = ["Alec Mocatta <[email protected]>"]
88
categories = ["development-tools","encoding","rust-patterns","network-programming"]
@@ -23,7 +23,8 @@ azure-devops = { project = "alecmocatta/serde_closure", pipeline = "tests", buil
2323
maintenance = { status = "actively-developed" }
2424

2525
[dependencies]
26-
serde_closure_derive = { version = "=0.3.2", path = "serde_closure_derive" }
26+
serde_closure_derive = { version = "=0.3.3", path = "serde_closure_derive" }
27+
2728
serde = { version = "1.0", features = ["derive"] }
2829

2930
[build-dependencies]

azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
endpoint: alecmocatta
1515
default:
1616
rust_toolchain: stable nightly
17-
rust_lint_toolchain: nightly-2020-07-27
17+
rust_lint_toolchain: nightly-2022-11-23
1818
rust_flags: ''
1919
rust_features_clippy: ''
2020
rust_features: ''

serde_closure_derive/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "serde_closure_derive"
3-
version = "0.3.2"
3+
version = "0.3.3"
44
license = "MIT OR Apache-2.0"
55
authors = ["Alec Mocatta <[email protected]>"]
66
categories = ["development-tools","encoding","rust-patterns","network-programming"]

serde_closure_derive/src/lib.rs

+30-19
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@
1010
//! See [`serde_closure`](https://docs.rs/serde_closure) for
1111
//! documentation.
1212
13-
#![doc(html_root_url = "https://docs.rs/serde_closure_derive/0.3.2")]
13+
#![doc(html_root_url = "https://docs.rs/serde_closure_derive/0.3.3")]
14+
#![allow(
15+
unknown_lints,
16+
clippy::default_trait_access,
17+
clippy::unused_self,
18+
clippy::if_not_else,
19+
clippy::manual_let_else
20+
)]
1421

1522
use proc_macro2::{Span, TokenStream};
1623
use quote::{quote, ToTokens};
17-
use std::{collections::HashSet, iter, iter::successors, mem::take, str};
24+
use std::{collections::HashSet, convert::TryInto, iter, iter::successors, mem::take, str};
1825
use syn::{
1926
parse2, parse_macro_input, visit_mut::{self, VisitMut}, Arm, AttributeArgs, Block, Error, Expr, ExprArray, ExprAssign, ExprAssignOp, ExprAsync, ExprAwait, ExprBinary, ExprBlock, ExprBox, ExprBreak, ExprCall, ExprCast, ExprClosure, ExprField, ExprForLoop, ExprGroup, ExprIf, ExprIndex, ExprLet, ExprLoop, ExprMacro, ExprMatch, ExprMethodCall, ExprParen, ExprPath, ExprRange, ExprReference, ExprRepeat, ExprReturn, ExprStruct, ExprTry, ExprTryBlock, ExprTuple, ExprType, ExprUnary, ExprUnsafe, ExprWhile, ExprYield, FieldValue, GenericParam, Ident, ImplItem, Item, ItemImpl, Lifetime, LifetimeDef, Local, Member, Pat, PatBox, PatIdent, PatReference, PatSlice, PatTuple, PatTupleStruct, PatType, Path, PathArguments, PathSegment, ReturnType, Stmt, TraitBound, Type, TypeInfer, TypeReference, TypeTuple, UnOp
2027
};
@@ -87,16 +94,16 @@ impl Desugar {
8794
inputs.push_punct(Default::default());
8895
}
8996
let output = match &args.output {
90-
ReturnType::Type(_, type_) => (&**type_).clone(),
97+
ReturnType::Type(_, type_) => (**type_).clone(),
9198
ReturnType::Default => Type::Tuple(TypeTuple {
9299
paren_token: Default::default(),
93100
elems: Default::default(),
94101
}),
95102
};
96103
*arg = PathArguments::AngleBracketed(if !return_output {
97-
syn::parse2(quote! { <(#inputs), Output = #output> }).unwrap()
104+
parse2(quote! { <(#inputs), Output = #output> }).unwrap()
98105
} else {
99-
syn::parse2(quote! { <(#inputs)> }).unwrap()
106+
parse2(quote! { <(#inputs)> }).unwrap()
100107
});
101108
(lifetimes, if return_output { Some(output) } else { None })
102109
} else {
@@ -112,7 +119,7 @@ impl VisitMut for Desugar {
112119
.0;
113120
if lifetimes > 0 {
114121
let span = Span::call_site();
115-
let empty = syn::parse2(quote! {for <>}).unwrap();
122+
let empty = parse2(quote! {for <>}).unwrap();
116123
i.lifetimes = Some(i.lifetimes.clone().unwrap_or(empty));
117124
i.lifetimes
118125
.as_mut()
@@ -125,7 +132,7 @@ impl VisitMut for Desugar {
125132
))
126133
}));
127134
}
128-
visit_mut::visit_trait_bound_mut(self, i)
135+
visit_mut::visit_trait_bound_mut(self, i);
129136
}
130137
fn visit_item_impl_mut(&mut self, i: &mut ItemImpl) {
131138
if let Some((_, path, _)) = &mut i.trait_ {
@@ -146,12 +153,12 @@ impl VisitMut for Desugar {
146153
if path.segments.last().unwrap().ident == "FnOnce" {
147154
if let Some(output) = output {
148155
i.items.push(ImplItem::Type(
149-
syn::parse2(quote! { type Output = #output; }).unwrap(),
156+
parse2(quote! { type Output = #output; }).unwrap(),
150157
));
151158
}
152159
}
153160
}
154-
visit_mut::visit_item_impl_mut(self, i)
161+
visit_mut::visit_item_impl_mut(self, i);
155162
}
156163
}
157164

@@ -171,7 +178,11 @@ impl Kind {
171178
}
172179
}
173180

174-
#[allow(clippy::cognitive_complexity)]
181+
#[allow(
182+
clippy::cognitive_complexity,
183+
clippy::unnecessary_wraps,
184+
clippy::too_many_lines
185+
)]
175186
fn impl_closure(mut closure: ExprClosure, kind: Kind) -> Result<TokenStream, Error> {
176187
let span = Span::call_site(); // TODO: def_site() https://github.com/rust-lang/rust/issues/54724
177188
let name_string = kind.name();
@@ -214,7 +225,7 @@ fn impl_closure(mut closure: ExprClosure, kind: Kind) -> Result<TokenStream, Err
214225
let env_variables = &env_variables;
215226
let env_variable_names = &env_variables
216227
.iter()
217-
.map(|ident| ident.to_string())
228+
.map(ToString::to_string)
218229
.collect::<Vec<_>>();
219230
let closure = if let Expr::Closure(closure) = closure {
220231
closure
@@ -261,8 +272,7 @@ fn impl_closure(mut closure: ExprClosure, kind: Kind) -> Result<TokenStream, Err
261272
})
262273
.unwrap();
263274
let env_deref: Expr = parse2(match kind {
264-
Kind::Fn => quote! { *#env_name },
265-
Kind::FnMut => quote! { *#env_name },
275+
Kind::Fn | Kind::FnMut => quote! { *#env_name },
266276
Kind::FnOnce => quote! { #env_name },
267277
})
268278
.unwrap();
@@ -582,7 +592,7 @@ fn pat_to_type(pat: &Pat) -> Type {
582592
match pat {
583593
Pat::Type(pat_type) => {
584594
if let Type::Infer(_) = *pat_type.ty {
585-
pat_to_type(&*pat_type.pat)
595+
pat_to_type(&pat_type.pat)
586596
} else {
587597
(*pat_type.ty).clone()
588598
}
@@ -651,7 +661,7 @@ impl<'a> State<'a> {
651661
| Pat::Type(PatType { pat, .. }) => self.pat(&mut *pat),
652662
Pat::Or(pat_or) => {
653663
for case in &mut pat_or.cases {
654-
self.pat(case)
664+
self.pat(case);
655665
}
656666
}
657667
Pat::Slice(PatSlice { elems, .. })
@@ -661,7 +671,7 @@ impl<'a> State<'a> {
661671
..
662672
}) => {
663673
for elem in elems {
664-
self.pat(elem)
674+
self.pat(elem);
665675
}
666676
}
667677
Pat::Range(pat_range) => {
@@ -670,7 +680,7 @@ impl<'a> State<'a> {
670680
}
671681
Pat::Struct(pat_struct) => {
672682
for field in &mut pat_struct.fields {
673-
self.pat(&mut *field.pat)
683+
self.pat(&mut field.pat);
674684
}
675685
}
676686
_ => (),
@@ -707,6 +717,7 @@ impl<'a> State<'a> {
707717
.collect();
708718
}
709719

720+
#[allow(clippy::too_many_lines)]
710721
fn expr(&mut self, expr: &mut Expr, is_func: bool) {
711722
match expr {
712723
Expr::Array(ExprArray { elems, .. }) | Expr::Tuple(ExprTuple { elems, .. }) => {
@@ -763,7 +774,7 @@ impl<'a> State<'a> {
763774
Expr::Path(ExprPath { path, .. })
764775
if path.leading_colon.is_none() && path.segments.len() == 1 =>
765776
{
766-
self.expr(func, true)
777+
self.expr(func, true);
767778
}
768779
_ => self.expr(func, false),
769780
}
@@ -944,7 +955,7 @@ fn bijective_base(n: u64, base: u64, digits: impl Fn(u8) -> u8) -> String {
944955
.iter_mut()
945956
.rev()
946957
.zip(divided)
947-
.map(|(c, n)| *c = digits((n % base) as u8))
958+
.map(|(c, n)| *c = digits((n % base).try_into().unwrap()))
948959
.count();
949960
let index = BUF_SIZE - written;
950961

src/lib.rs

+15-11
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@
165165
//! automatically serializable and deserializable with
166166
//! [`serde`](https://github.com/serde-rs/serde).
167167
168-
#![doc(html_root_url = "https://docs.rs/serde_closure/0.3.2")]
169-
#![cfg_attr(nightly, feature(unboxed_closures, fn_traits))]
168+
#![doc(html_root_url = "https://docs.rs/serde_closure/0.3.3")]
169+
#![cfg_attr(nightly, feature(unboxed_closures, fn_traits, tuple_trait))]
170170
#![warn(
171171
missing_copy_implementations,
172172
missing_debug_implementations,
@@ -482,6 +482,8 @@ pub mod traits {
482482
483483
#![allow(non_snake_case)]
484484

485+
#[cfg(nightly)]
486+
use std::marker::Tuple;
485487
use std::ops;
486488

487489
/// Supertrait of [`std::ops::FnOnce`] that is usable on stable Rust. It is
@@ -567,7 +569,7 @@ pub mod traits {
567569
#[cfg(not(nightly))]
568570
fn_once!(A B C D E F G H I J K L);
569571
#[cfg(nightly)]
570-
impl<T, Args> FnOnce<Args> for T
572+
impl<T, Args: Tuple> FnOnce<Args> for T
571573
where
572574
T: ops::FnOnce<Args>,
573575
{
@@ -601,7 +603,7 @@ pub mod traits {
601603
#[cfg(not(nightly))]
602604
fn_mut!(A B C D E F G H I J K L);
603605
#[cfg(nightly)]
604-
impl<T, Args> FnMut<Args> for T
606+
impl<T, Args: Tuple> FnMut<Args> for T
605607
where
606608
T: ops::FnMut<Args>,
607609
{
@@ -633,7 +635,7 @@ pub mod traits {
633635
#[cfg(not(nightly))]
634636
fn_ref!(A B C D E F G H I J K L);
635637
#[cfg(nightly)]
636-
impl<T, Args> Fn<Args> for T
638+
impl<T, Args: Tuple> Fn<Args> for T
637639
where
638640
T: ops::Fn<Args>,
639641
{
@@ -657,6 +659,8 @@ pub mod structs {
657659
658660
use serde::{Deserialize, Serialize};
659661
use std::fmt::{self, Debug};
662+
#[cfg(nightly)]
663+
use std::marker::Tuple;
660664

661665
use super::internal;
662666

@@ -697,7 +701,7 @@ pub mod structs {
697701
}
698702
}
699703
#[cfg(nightly)]
700-
impl<F, I> std::ops::FnOnce<I> for FnOnce<F>
704+
impl<F, I: Tuple> std::ops::FnOnce<I> for FnOnce<F>
701705
where
702706
F: internal::FnOnce<I>,
703707
{
@@ -755,7 +759,7 @@ pub mod structs {
755759
}
756760
}
757761
#[cfg(nightly)]
758-
impl<F, I> std::ops::FnOnce<I> for FnMut<F>
762+
impl<F, I: Tuple> std::ops::FnOnce<I> for FnMut<F>
759763
where
760764
F: internal::FnOnce<I>,
761765
{
@@ -778,7 +782,7 @@ pub mod structs {
778782
}
779783
}
780784
#[cfg(nightly)]
781-
impl<F, I> std::ops::FnMut<I> for FnMut<F>
785+
impl<F, I: Tuple> std::ops::FnMut<I> for FnMut<F>
782786
where
783787
F: internal::FnMut<I>,
784788
{
@@ -833,7 +837,7 @@ pub mod structs {
833837
}
834838
}
835839
#[cfg(nightly)]
836-
impl<F, I> std::ops::FnOnce<I> for Fn<F>
840+
impl<F, I: Tuple> std::ops::FnOnce<I> for Fn<F>
837841
where
838842
F: internal::FnOnce<I>,
839843
{
@@ -856,7 +860,7 @@ pub mod structs {
856860
}
857861
}
858862
#[cfg(nightly)]
859-
impl<F, I> std::ops::FnMut<I> for Fn<F>
863+
impl<F, I: Tuple> std::ops::FnMut<I> for Fn<F>
860864
where
861865
F: internal::FnMut<I>,
862866
{
@@ -877,7 +881,7 @@ pub mod structs {
877881
}
878882
}
879883
#[cfg(nightly)]
880-
impl<F, I> std::ops::Fn<I> for Fn<F>
884+
impl<F, I: Tuple> std::ops::Fn<I> for Fn<F>
881885
where
882886
F: internal::Fn<I>,
883887
{

tests/smoke.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
unreachable_pub,
88
clippy::pedantic
99
)]
10-
#![allow(clippy::too_many_lines, clippy::many_single_char_names, unused_imports)]
10+
#![allow(
11+
clippy::too_many_lines,
12+
clippy::many_single_char_names,
13+
clippy::self_assignment,
14+
clippy::uninlined_format_args,
15+
unused_imports
16+
)]
1117

1218
use serde::{de::DeserializeOwned, Serialize};
1319
use std::{fmt::Debug, mem::size_of};

tests/test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
unreachable_pub,
88
clippy::pedantic
99
)]
10+
#![allow(clippy::no_effect_underscore_binding, clippy::unnecessary_wraps)]
1011

1112
use serde::{de::DeserializeOwned, Serialize};
1213
use std::{fmt::Debug, hash::Hash};

0 commit comments

Comments
 (0)