-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Don't provide hint to add lifetime on impl items #37481
Don't provide hint to add lifetime on impl items #37481
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @eddyb (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
8b3646f
to
b00ad7b
Compare
} | ||
} | ||
ast_map::NodeImplItem(item) => { | ||
match item.node { | ||
hir::ImplItemKind::Method(ref sig, _) => { | ||
Some((&sig.decl, | ||
(true, Some((&sig.decl, |
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.
I think you can just add an early return here and that might be enough. Also this should only be done if the impl
is for a trait, not inherent.
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.
- Changed to early return
- Check that impl if for a trait
- Add unittest
d45f985
to
0c4104a
Compare
@bors r+ |
📌 Commit 0c4104a has been approved by |
⌛ Testing commit 0c4104a with merge 6b14097... |
💔 Test failed - auto-win-gnu-32-opt-rustbuild |
0c4104a
to
3e83628
Compare
@estebank looks like the travis failures are legit? |
@alexcrichton Yes. I'll fix tonight. I need a new r+ after pushing a fix, right? |
@estebank indeed! |
Don't provide hint to add lifetime on impl items that implement a trait. ```rust use std::str::FromStr; pub struct Foo<'a> { field: &'a str, } impl<'a> FromStr for Foo<'a> { type Err = (); fn from_str(path: &str) -> Result<Self, ()> { Ok(Foo { field: path }) } } ``` would give the following hint: ```nocode help: consider using an explicit lifetime parameter as shown: fn from_str(path: &'a str) -> Result<Self, ()> --> <anon>:9:5 | 9 | fn from_str(path: &str) -> Result<Self, ()> { | ^ ``` which is never correct, since then there will be a lifetime mismatch between the impl and the trait. Remove this hint for impl items that implement a trait.
3e83628
to
87b6d38
Compare
@alexcrichton @eddyb fixed the test error. |
@bors: r=eddyb |
📌 Commit 87b6d38 has been approved by |
…impl, r=eddyb Don't provide hint to add lifetime on impl items ``` rust use std::str::FromStr; pub struct Foo<'a> { field: &'a str, } impl<'a> FromStr for Foo<'a> { type Err = (); fn from_str(path: &str) -> Result<Self, ()> { Ok(Foo { field: path }) } } ``` would give the following hint: ``` nocode help: consider using an explicit lifetime parameter as shown: fn from_str(path: &'a str) -> Result<Self, ()> --> <anon>:9:5 | 9 | fn from_str(path: &str) -> Result<Self, ()> { | ^ ``` which is never correct, since then there will be a lifetime mismatch between the `impl` and the trait. Remove this hint for all `impl` items. Re: rust-lang#37363.
⌛ Testing commit 87b6d38 with merge 65ba338... |
…impl, r=eddyb Don't provide hint to add lifetime on impl items ``` rust use std::str::FromStr; pub struct Foo<'a> { field: &'a str, } impl<'a> FromStr for Foo<'a> { type Err = (); fn from_str(path: &str) -> Result<Self, ()> { Ok(Foo { field: path }) } } ``` would give the following hint: ``` nocode help: consider using an explicit lifetime parameter as shown: fn from_str(path: &'a str) -> Result<Self, ()> --> <anon>:9:5 | 9 | fn from_str(path: &str) -> Result<Self, ()> { | ^ ``` which is never correct, since then there will be a lifetime mismatch between the `impl` and the trait. Remove this hint for all `impl` items. Re: rust-lang#37363.
⛄ The build was interrupted to prioritize another pull request. |
Rollup of 30 pull requests - Successful merges: #37190, #37368, #37481, #37503, #37527, #37535, #37551, #37584, #37600, #37613, #37615, #37659, #37662, #37669, #37682, #37688, #37690, #37692, #37693, #37694, #37695, #37696, #37698, #37699, #37705, #37708, #37709, #37716, #37724, #37727 - Failed merges: #37640, #37689, #37717
would give the following hint:
which is never correct, since then there will be a lifetime mismatch between the
impl
and the trait.Remove this hint for all
impl
items.Re: #37363.