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

100% Clippy #1112

Merged
merged 5 commits into from
Jul 25, 2018
Merged

100% Clippy #1112

merged 5 commits into from
Jul 25, 2018

Conversation

Nemo157
Copy link
Member

@Nemo157 Nemo157 commented Jul 21, 2018

I think merging all these changes is only worth it if we start gating CI on Clippy, otherwise the buggy allows should be dropped (just means dropping the last 2 commits). With this and #1111 the deny warnings job could be changed to cargo clippy -- -D warnings and hit all builtin + Clippy warnings on all the crates at once. (EDIT: Done since #1111 is merged)

I think the needless_lifetimes one could be fixed in Clippy relatively easily, presumably it just doesn't support arbitrary_self_types properly. The redundant_closures one seems like it won't be able to get a fix soon, it would need Clippy to somehow detect side-effect producing code.

I'm opening this mostly for discussion on whether gating CI on Clippy is of interest to the team. If it is then I might take a look at doing the upstream fixes to reduce the bad parts of this.

@Nemo157 Nemo157 force-pushed the clippy branch 3 times, most recently from f67a25a to 144acf9 Compare July 21, 2018 17:30
@@ -205,6 +205,12 @@ impl LocalPool {
}
}

impl Default for LocalPool {
Copy link
Member Author

Choose a reason for hiding this comment

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

I could see arguments for not implementing Default for LocalPool, if so I think having an explicit allow for it is good documentation that it has been considered and decided against.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't think of any such arguments ^^' Could you list some?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mostly that a LocalPool isn’t a data structure, so being able to create a default in a generic context isn’t that useful. IMO it’s still worth having the impl anyway though.

@@ -58,7 +58,8 @@ enum State<Fut, T> {
}

impl<Fut, T> State<Fut, T> {
fn as_pin_mut<'a>(
#[allow(needless_lifetimes, wrong_self_convention)] // https://github.com/rust-lang/rfcs/pull/2362#issuecomment-406804183
fn as_pin_mut(
self: PinMut<'a, Self>
Copy link
Contributor

Choose a reason for hiding this comment

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

missing trailing comma

@MajorBreakfast
Copy link
Contributor

I'm in favor of merging this. We can always remove it again from the CI if it proves to be a hassle. However, I'm optimistic that we'll benefit from having it in there.

@@ -288,7 +288,7 @@ pub trait AsyncWriteExt: AsyncWrite {
/// assert_eq!(output, [1, 2, 3, 4, 0]);
/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
/// ```
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self> {
fn write_all(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self> {
Copy link
Member

Choose a reason for hiding this comment

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

Was it intentional to use in-band-lifetimes here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, as far as I’m aware they’re still on track to be stable in 2018 Edition. If you’ve got some reason not to use them I can revert these changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cramertj My local waker opt PR you just merged also had an in-band lifetime in it 😇

@@ -212,7 +212,7 @@ pub trait SinkExt: Sink {
/// Doing `sink.send_all(stream)` is roughly equivalent to
/// `stream.forward(sink)`. The returned future will exhaust all items from
/// `stream` and send them to `self`.
fn send_all<'a, St>(
fn send_all<St>(
Copy link
Member

Choose a reason for hiding this comment

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

Ditto WRT in-band lifetimes

@@ -58,7 +58,8 @@ enum State<Fut, T> {
}

impl<Fut, T> State<Fut, T> {
fn as_pin_mut<'a>(
#[allow(needless_lifetimes, wrong_self_convention)] // https://github.com/rust-lang/rfcs/pull/2362#issuecomment-406804183
fn as_pin_mut(
Copy link
Member

Choose a reason for hiding this comment

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

And again

@@ -60,7 +60,8 @@ where
}

/// Get a pinned mutable reference to the inner sink.
pub fn get_pin_mut<'a>(self: PinMut<'a, Self>) -> PinMut<'a, Si> {
#[allow(needless_lifetimes)] // https://github.com/rust-lang/rfcs/pull/2362#issuecomment-406804183
pub fn get_pin_mut(self: PinMut<'a, Self>) -> PinMut<'a, Si> {
Copy link
Member

Choose a reason for hiding this comment

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

and again

@@ -84,7 +84,8 @@ where
///
/// Note that care must be taken to avoid tampering with the state of the
/// stream which may otherwise confuse this combinator.
pub fn get_pin_mut<'a>(self: PinMut<'a, Self>) -> PinMut<'a, St> {
#[allow(needless_lifetimes)] // https://github.com/rust-lang/rfcs/pull/2362#issuecomment-406804183
pub fn get_pin_mut(self: PinMut<'a, Self>) -> PinMut<'a, St> {
Copy link
Member

Choose a reason for hiding this comment

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

etc...

@MajorBreakfast
Copy link
Contributor

@Nemo157 It seems that my waker reference optimization PR triggered a clippy warning that broke the CI

@Nemo157
Copy link
Member Author

Nemo157 commented Jul 24, 2018

Oh, interesting, I didn't realise that Travis tested the merge commit. I was confused how those changes made it into this build. Rebased and fixed the new warning.

@MajorBreakfast
Copy link
Contributor

@Nemo157 I didn't know that as well. Interesting!

@Nemo157
Copy link
Member Author

Nemo157 commented Jul 24, 2018

I took a look at the needless_lifetimes issue again, it's not actually a Clippy issue, it's a Rust issue, if lifetime elision with arbitrary_self_types worked then signatures like

pub fn get_pinned_mut(self: PinMut<'_, Self>) -> PinMut<'_, Si>

would work, opened rust-lang/rust#52675 and will update the links in the code now.

@MajorBreakfast
Copy link
Contributor

@cramertj Are you okay with using in-band lifetimes? (i.e. "may I merge this when it's ready?")

@cramertj
Copy link
Member

@MajorBreakfast Yup, seems fine to me! I just wanted to check that it was an intentional decision.

@MajorBreakfast MajorBreakfast merged commit 6d422ae into rust-lang:master Jul 25, 2018
@MajorBreakfast
Copy link
Contributor

MajorBreakfast commented Jul 25, 2018

I merged this with the intention to remove the #[allow(needless_lifetimes) annotations once '_ lifetimes are supported in arbitrary self types. In the meantime these annotations can be happily in there 🙂

@Nemo157 Nemo157 deleted the clippy branch July 25, 2018 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants