Skip to content

Commit d9934dd

Browse files
authored
Merge pull request #26 from alecmocatta/fix-warnings
Fix warnings on latest rust
2 parents a0682a0 + 93f4c6a commit d9934dd

File tree

7 files changed

+32
-30
lines changed

7 files changed

+32
-30
lines changed

Cargo.toml

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

33
[package]
44
name = "serde_closure"
5-
version = "0.2.10"
5+
version = "0.2.11"
66
license = "MIT OR Apache-2.0"
77
authors = ["Alec Mocatta <[email protected]>"]
88
categories = ["development-tools","encoding","rust-patterns","network-programming"]
@@ -14,7 +14,7 @@ This library provides macros that wrap closures to make them serializable and de
1414
"""
1515
repository = "https://github.com/alecmocatta/serde_closure"
1616
homepage = "https://github.com/alecmocatta/serde_closure"
17-
documentation = "https://docs.rs/serde_closure/0.2.10"
17+
documentation = "https://docs.rs/serde_closure/0.2.11"
1818
readme = "README.md"
1919
edition = "2018"
2020

@@ -23,7 +23,7 @@ azure-devops = { project = "alecmocatta/serde_closure", pipeline = "tests" }
2323
maintenance = { status = "actively-developed" }
2424

2525
[dependencies]
26-
serde_closure_derive = { version = "=0.2.10", path = "serde_closure_derive" }
26+
serde_closure_derive = { version = "=0.2.11", path = "serde_closure_derive" }
2727
serde = { version = "1.0", features = ["derive"] }
2828
proc-macro-hack = "0.5"
2929

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
[![Crates.io](https://img.shields.io/crates/v/serde_closure.svg?maxAge=86400)](https://crates.io/crates/serde_closure)
44
[![MIT / Apache 2.0 licensed](https://img.shields.io/crates/l/serde_closure.svg?maxAge=2592000)](#License)
5-
[![Build Status](https://dev.azure.com/alecmocatta/serde_closure/_apis/build/status/tests?branchName=master)](https://dev.azure.com/alecmocatta/serde_closure/_build/latest?branchName=master)
5+
[![Build Status](https://dev.azure.com/alecmocatta/serde_closure/_apis/build/status/tests?branchName=master)](https://dev.azure.com/alecmocatta/serde_closure/_build/latest?definitionId=10&branchName=master)
66

7-
[Docs](https://docs.rs/serde_closure/0.2.10)
7+
[Docs](https://docs.rs/serde_closure/0.2.11)
88

99
Serializable and debuggable closures.
1010

@@ -30,9 +30,9 @@ requires nightly Rust for the `unboxed_closures` and `fn_traits` features (rust
3030
issue [#29625](https://github.com/rust-lang/rust/issues/29625)).
3131

3232
* There are three macros,
33-
[`FnOnce`](https://docs.rs/serde_closure/0.2.10/serde_closure/macro.FnOnce.html),
34-
[`FnMut`](https://docs.rs/serde_closure/0.2.10/serde_closure/macro.FnMut.html)
35-
and [`Fn`](https://docs.rs/serde_closure/0.2.10/serde_closure/macro.Fn.html),
33+
[`FnOnce`](https://docs.rs/serde_closure/0.2.11/serde_closure/macro.FnOnce.html),
34+
[`FnMut`](https://docs.rs/serde_closure/0.2.11/serde_closure/macro.FnMut.html)
35+
and [`Fn`](https://docs.rs/serde_closure/0.2.11/serde_closure/macro.Fn.html),
3636
corresponding to the three types of Rust closure.
3737
* Wrap your closure with one of the macros and it will now implement `Copy`,
3838
`Clone`, `PartialEq`, `Eq`, `Hash`, `PartialOrd`, `Ord`, `Serialize`,

azure-pipelines.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ jobs:
1414
endpoint: alecmocatta
1515
default:
1616
rust_toolchain: nightly
17-
rust_lint_toolchain: nightly-2019-10-14
17+
rust_lint_toolchain: nightly-2020-04-23
1818
rust_flags: ''
1919
rust_features: ''
2020
rust_target_check: ''
2121
rust_target_build: ''
2222
rust_target_run: ''
2323
matrix:
2424
windows:
25-
imageName: 'vs2017-win2016'
25+
imageName: 'windows-latest'
2626
rust_target_run: 'x86_64-pc-windows-msvc i686-pc-windows-msvc' # currently broken building crate-type=lib: x86_64-pc-windows-gnu i686-pc-windows-gnu
2727
mac:
28-
imageName: 'macos-10.13'
28+
imageName: 'macos-latest'
2929
rust_target_run: 'x86_64-apple-darwin'
3030
linux:
31-
imageName: 'ubuntu-16.04'
31+
imageName: 'ubuntu-latest'
3232
rust_target_run: 'x86_64-unknown-linux-gnu i686-unknown-linux-gnu x86_64-unknown-linux-musl i686-unknown-linux-musl'

serde_closure_derive/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "serde_closure_derive"
3-
version = "0.2.10"
3+
version = "0.2.11"
44
license = "MIT OR Apache-2.0"
55
authors = ["Alec Mocatta <[email protected]>"]
66
categories = ["development-tools","encoding","rust-patterns","network-programming"]
@@ -14,7 +14,7 @@ See https://crates.io/crates/serde_closure for documentation.
1414
"""
1515
repository = "https://github.com/alecmocatta/serde_closure"
1616
homepage = "https://github.com/alecmocatta/serde_closure"
17-
documentation = "https://docs.rs/serde_closure/0.2.10"
17+
documentation = "https://docs.rs/serde_closure/0.2.11"
1818
edition = "2018"
1919

2020
[badges]

serde_closure_derive/src/lib.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! See [`serde_closure`](https://docs.rs/serde_closure/) for
1010
//! documentation.
1111
12-
#![doc(html_root_url = "https://docs.rs/serde_closure_derive/0.2.10")]
12+
#![doc(html_root_url = "https://docs.rs/serde_closure_derive/0.2.11")]
1313
#![feature(proc_macro_diagnostic)]
1414
#![allow(non_snake_case)] // due to proc-macro-hack can't apply this directly
1515

@@ -181,7 +181,7 @@ fn impl_fn_once(closure: Closure, kind: Kind) -> Result<TokenStream, Error> {
181181
let env_deconstruct = if kind == Kind::FnOnce {
182182
Some(
183183
parse2::<Stmt>(
184-
quote! { let #impls_name::#name{#(mut #env_variables ,)*..} = #env_name; },
184+
quote! { #[allow(unused_mut)] let #impls_name::#name{#(mut #env_variables ,)*..} = #env_name; },
185185
)
186186
.unwrap(),
187187
)
@@ -261,7 +261,7 @@ fn impl_fn_once(closure: Closure, kind: Kind) -> Result<TokenStream, Error> {
261261
Ok(quote! {
262262
{
263263
mod #impls_name {
264-
#![allow(warnings)]
264+
#![allow(warnings, unsafe_code)]
265265
use ::serde_closure::{
266266
internal::{self, is_phantom, to_phantom},
267267
structs,
@@ -427,10 +427,8 @@ fn impl_fn_once(closure: Closure, kind: Kind) -> Result<TokenStream, Error> {
427427
}
428428
// This asserts that inferred env variables aren't types with >=1 type parameters.
429429
#[allow(warnings)]
430-
{
431-
if false {
432-
#(&#env_variables::<>;)*
433-
}
430+
if false {
431+
#(&#env_variables::<>;)*
434432
}
435433
// TODO: Work out how to assert env variables aren't unnameable types with 0 type parameters.
436434
// This might work in the future, but today it causes borrowck issues:
@@ -442,22 +440,21 @@ fn impl_fn_once(closure: Closure, kind: Kind) -> Result<TokenStream, Error> {
442440
// }
443441
// }
444442

443+
#[allow(unused_mut)]
445444
let mut #ret_name = #impls_name::#name::new(#env_capture);
446445
let #env_types_name = ::serde_closure::internal::to_phantom(&#ret_name);
447446

448447
let closure =
449-
#(#attrs)* #asyncness move |mut #env_name: #env_type, (#(#input_pats,)*): (#(#input_types,)*)| #output {
448+
#(#attrs)* #asyncness move |#env_name: #env_type, (#(#input_pats,)*): (#(#input_types,)*)| #output {
450449
#[allow(warnings)]
451-
{
452-
if false {
453-
::serde_closure::internal::is_phantom(& #env_deref, #env_types_name);
454-
}
450+
if false {
451+
::serde_closure::internal::is_phantom(& #env_deref, #env_types_name);
455452
}
456453
#env_deconstruct
457454
#body
458455
};
459456

460-
#[allow(warnings)]
457+
#[allow(warnings, unsafe_code)]
461458
{
462459
if false {
463460
let _ = closure(#ret_ref, loop {});

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
//! automatically serializable and deserializable with
165165
//! [`serde`](https://github.com/serde-rs/serde).
166166
167-
#![doc(html_root_url = "https://docs.rs/serde_closure/0.2.10")]
167+
#![doc(html_root_url = "https://docs.rs/serde_closure/0.2.11")]
168168
#![feature(unboxed_closures, fn_traits)]
169169
#![warn(
170170
missing_copy_implementations,

tests/test.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(unsafe_code)] // TODO: make this forbid when unsafe in a macro doesn't trigger it (def_site?)
2+
13
use serde::{de::DeserializeOwned, Serialize};
24
use std::{fmt::Debug, mem::size_of};
35

@@ -99,6 +101,7 @@ fn fnonce() {
99101
let tasks2 = tasks.clone();
100102
let c = FnOnce!(move || -> String {
101103
for task in tasks {
104+
#[allow(clippy::redundant_closure_call)]
102105
(|| reduce.push(task))();
103106
}
104107
reduce
@@ -373,7 +376,7 @@ fn source() {
373376

374377
#[test]
375378
fn upcast() {
376-
let closure = FnOnce!(|x: &str| "test");
379+
let closure = FnOnce!(|_x: &str| "test");
377380
let closure: Box<dyn FnOnce(&str) -> &'static str + Send + Sync> = Box::new(closure);
378381
closure("test");
379382
}
@@ -385,6 +388,7 @@ fn capturing() {
385388
let c = 0u8;
386389
#[rustfmt::skip]
387390
let closure = FnOnce!(move || {
391+
#![allow(path_statements)]
388392
(b)();
389393
// b();
390394
// (b::<>)();
@@ -415,6 +419,7 @@ fn capturing() {
415419
// let FooVar = Foo;
416420
#[rustfmt::skip]
417421
let closure = FnOnce!(move || {
422+
#![allow(path_statements)]
418423
// (b)();
419424
// b();
420425
// (b::<>)();
@@ -464,7 +469,7 @@ fn static_var() {
464469
static STATIC: String = String::new();
465470

466471
FnMut!(move || {
467-
let a = &STATIC;
472+
let _a = &STATIC;
468473
});
469474
}
470475

0 commit comments

Comments
 (0)