-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
new_ret_no_self: allow Self in inner type for impl Trait return types #4365
Conversation
tests/ui/methods.rs
Outdated
struct AsyncNew; | ||
|
||
impl AsyncNew { | ||
fn new() -> impl Future<Output = Option<Self>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just make this function async
and use the async_await
feature in this test?
Everything else LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the tests seem to use Rust 2015 (which does not have async fns) and I don't know how to change that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this again 😄
You have to add
rust-clippy/tests/ui/issue_4266.rs
Lines 1 to 2 in d71e9c4
// compile-flags: --edition 2018 | |
#![feature(async_await)] |
at the top of the test case. We should document this.
tests/ui/methods.rs
Outdated
@@ -23,10 +25,13 @@ use std::collections::BTreeMap; | |||
use std::collections::HashMap; | |||
use std::collections::HashSet; | |||
use std::collections::VecDeque; | |||
use std::future::Future; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports are now unused.
Thanks! @bors r+ |
📌 Commit d553158 has been approved by |
new_ret_no_self: allow Self in inner type for impl Trait return types Check the inner types of associated types of a trait when checking for Self in the return type of a `new` method. This means that the following will no longer warn: ```rust trait Trait { type Inner; } struct S; impl S { fn new() -> impl Trait<Inner = Option<Self>> { struct TraitImpl; impl Trait for TraitImpl { type Inner = Option<S>; } TraitImpl } } ``` ```rust #![feature(async_await)] struct Connection; impl Connection { async fn new() -> Result<Self, ()> { Ok(S) } } ``` closes #4359
💔 Test failed - checks-travis |
Forgot the changelog @bors r+ |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit d553158 has been approved by |
new_ret_no_self: allow Self in inner type for impl Trait return types Check the inner types of associated types of a trait when checking for Self in the return type of a `new` method. This means that the following will no longer warn: ```rust trait Trait { type Inner; } struct S; impl S { fn new() -> impl Trait<Inner = Option<Self>> { struct TraitImpl; impl Trait for TraitImpl { type Inner = Option<S>; } TraitImpl } } ``` ```rust #![feature(async_await)] struct Connection; impl Connection { async fn new() -> Result<Self, ()> { Ok(S) } } ``` closes #4359 changelog: fix `new_ret_no_self` lint for async `new` functions.
💔 Test failed - checks-travis |
Document how to write tests requiring the 2018 edition [Rendered](https://github.com/flip1995/rust-clippy/blob/doc_edition_2018_tests/doc/adding_lints.md#Edition-2018-tests) cc #4365 changelog: none
@bors retry |
new_ret_no_self: allow Self in inner type for impl Trait return types Check the inner types of associated types of a trait when checking for Self in the return type of a `new` method. This means that the following will no longer warn: ```rust trait Trait { type Inner; } struct S; impl S { fn new() -> impl Trait<Inner = Option<Self>> { struct TraitImpl; impl Trait for TraitImpl { type Inner = Option<S>; } TraitImpl } } ``` ```rust #![feature(async_await)] struct Connection; impl Connection { async fn new() -> Result<Self, ()> { Ok(S) } } ``` closes #4359 changelog: fix `new_ret_no_self` lint for async `new` functions.
☀️ Test successful - checks-travis, status-appveyor |
Check the inner types of associated types of a trait when checking for Self in the return type of a
new
method. This means that the following will no longer warn:closes #4359
changelog: fix
new_ret_no_self
lint for asyncnew
functions.