Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use #![warn(single_use_lifetimes)] #1680

Merged
merged 6 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ matrix:

# This is the minimum Rust version supported by `async-await` feature.
# When updating this, the reminder to update the minimum required version of `async-await` feature in README.md.
- name: cargo +nightly test (minimum required version)
- name: cargo +nightly build (minimum required version)
rust: nightly-2019-05-09
script:
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
- cargo build --all --all-features

- name: cargo test
rust: nightly
Expand All @@ -30,18 +33,19 @@ matrix:
rust: nightly
os: linux

- name: cargo test (with minimal versions)
- name: cargo build (with minimal versions)
rust: nightly
script:
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
- cargo update -Zminimal-versions
- cargo test --all --all-features
- cargo build --all --all-features

- name: cargo clippy
rust: nightly
script:
- if rustup component add clippy-preview;
then
cargo clippy --all -- -Dwarnings -Drust-2018-idioms;
cargo clippy --all --all-features;
else
echo 'Skipping clippy';
fi
Expand Down Expand Up @@ -147,6 +151,7 @@ script:
env:
global:
- secure: "iwVcMVIF7ZSY82fK5UyyUvVvJxMSYrbZawh1+4Oi8pvOdYq1gptcDoOC8jxWwCwrNF1b+/85n+jlEUngEqqSmV5PjAbWPjoc+u4Zn7CRi1AlxoUlvHPiQm4vM4Mkkd6GsqoIZttCeedU9m/w0nQ18uUtK8uD6vr2FVdcMnUnkYQAxuGOowGLrwidukzfBXMCu/JrwKMIbt61knAFiI/KJknu0h1mRrhpeF/sQ3tJFzRRcQeFJkbfwDzltMpPo1hq5D3HI4ONjYi/qO2pwUhDk4umfp9cLW9MS8rQvptxJTQmWemHi+f2/U4ld6a0URL6kEuMkt/EbH0A74eFtlicfRs44dX9MlWoqbLypnC3ymqmHcpwcwNA3HmZyg800MTuU+BPK41HIPdO9tPpxjHEiqvNDknH7qs+YBnis0eH7DHJgEjXq651PjW7pm+rnHPwsj+OzKE1YBNxBQZZDkS3VnZJz+O4tVsOzc3IOz0e+lf7VVuI17C9haj117nKp3umC4MVBA0S8RfreFgqpyDeY2zwcqOr0YOlEGGRl0vyWP8Qcxx12kQ7+doLolt6Kxda4uO0hKRmIF6+qki1T+L7v8BOGOtCncz4f7IX48eQ7+Wu0OtglRn45qAa3CxjUuW6xX3KSNH66PCXV0Jtp8Ga2SSevX2wtbbFu9f+9R+PQY4="
- RUSTFLAGS=-Dwarnings

notifications:
email:
Expand Down
2 changes: 2 additions & 0 deletions futures-channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#![cfg_attr(not(feature = "std"), no_std)]

#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints have false positives in the minimum required version.
#![cfg_attr(test, warn(single_use_lifetimes))]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enables single_use_lifetimes lint when running cargo test, cargo check --tests etc. (FWIW, I often run cargo check --all-features --tests --all locally before opening PR).

#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
Expand Down
2 changes: 2 additions & 0 deletions futures-core/src/future/future_obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ pub struct LocalFutureObj<'a, T> {

impl<T> Unpin for LocalFutureObj<'_, T> {}

#[allow(single_use_lifetimes)]
#[allow(clippy::transmute_ptr_to_ptr)]
unsafe fn remove_future_lifetime<'a, T>(ptr: *mut (dyn Future<Output = T> + 'a))
-> *mut (dyn Future<Output = T> + 'static)
{
mem::transmute(ptr)
}

#[allow(single_use_lifetimes)]
unsafe fn remove_drop_lifetime<'a, T>(ptr: unsafe fn (*mut (dyn Future<Output = T> + 'a)))
-> unsafe fn(*mut (dyn Future<Output = T> + 'static))
{
Expand Down
2 changes: 2 additions & 0 deletions futures-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#![cfg_attr(not(feature = "std"), no_std)]

#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints have false positives in the minimum required version.
#![cfg_attr(test, warn(single_use_lifetimes))]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
Expand Down
2 changes: 2 additions & 0 deletions futures-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#![cfg_attr(not(feature = "std"), no_std)]

#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints have false positives in the minimum required version.
#![cfg_attr(test, warn(single_use_lifetimes))]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
Expand Down
2 changes: 2 additions & 0 deletions futures-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#![cfg_attr(not(feature = "std"), no_std)]

#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints have false positives in the minimum required version.
#![cfg_attr(test, warn(single_use_lifetimes))]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
Expand Down
2 changes: 1 addition & 1 deletion futures-select-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ std = []
proc-macro2 = "0.4"
proc-macro-hack = "0.5.3"
quote = "0.6"
syn = { version = "0.15.22", features = ["full"] }
syn = { version = "0.15.25", features = ["full"] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this change required?

Copy link
Member Author

@taiki-e taiki-e Jun 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A warning occurred when building with minimal versions: https://travis-ci.com/rust-lang-nursery/futures-rs/jobs/209211855. (that warning was fixed in dtolnay/syn#563, and that change is included in 0.15.25 and later versions)

(Context: After the first commit, I realized that CI did not catch(and reject) the warnings, so I added eb4cbfa and changed the warnings to be denied for all builds.)

2 changes: 2 additions & 0 deletions futures-select-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#![recursion_limit="128"]
#![warn(rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints have false positives in the minimum required version.
#![cfg_attr(test, warn(single_use_lifetimes))]
#![warn(clippy::all)]

extern crate proc_macro;
Expand Down
2 changes: 2 additions & 0 deletions futures-sink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints have false positives in the minimum required version.
#![cfg_attr(test, warn(single_use_lifetimes))]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
Expand Down
2 changes: 2 additions & 0 deletions futures-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Utilities to make testing [`Future`s](futures_core::Future) easier

#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints have false positives in the minimum required version.
#![cfg_attr(test, warn(single_use_lifetimes))]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
Expand Down
1 change: 1 addition & 0 deletions futures-util/src/compat/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ where Ex: Executor01<Executor01Future>,
}
}

#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
impl<Sp, Fut> Executor01<Fut> for Compat<Sp>
where
for<'a> &'a Sp: Spawn03,
Expand Down
2 changes: 2 additions & 0 deletions futures-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints have false positives in the minimum required version.
#![cfg_attr(test, warn(single_use_lifetimes))]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
Expand Down
2 changes: 2 additions & 0 deletions futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#![cfg_attr(not(feature = "std"), no_std)]

#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints have false positives in the minimum required version.
#![cfg_attr(test, warn(single_use_lifetimes))]
#![warn(clippy::all)]

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
Expand Down