-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix4894 Using Into
and TryInto
instead of From
and TryFrom
#6620
Conversation
r? @phansch (rust-highfive has picked a reviewer for you, use r? to override) |
Oh, this is a draft for discussion, how can I disable |
clippy_lints/src/into_and_try_into_instead_of_from_and_try_from.rs
Outdated
Show resolved
Hide resolved
Into
and TryInto
instead of From
and TryFrom
r? @flip1995 |
clippy_lints/src/into_and_try_into_instead_of_from_and_try_from.rs
Outdated
Show resolved
Hide resolved
clippy_lints/src/into_and_try_into_instead_of_from_and_try_from.rs
Outdated
Show resolved
Hide resolved
…jasper Make more traits of the From/Into family diagnostic items Following traits are now diagnostic items: - `From` (unchanged) - `Into` - `TryFrom` - `TryInto` This also adds symbols for those items: - `into_trait` - `try_from_trait` - `try_into_trait` Related: rust-lang/rust-clippy#6620 (comment)
…jasper Make more traits of the From/Into family diagnostic items Following traits are now diagnostic items: - `From` (unchanged) - `Into` - `TryFrom` - `TryInto` This also adds symbols for those items: - `into_trait` - `try_from_trait` - `try_into_trait` Related: rust-lang/rust-clippy#6620 (comment)
…jasper Make more traits of the From/Into family diagnostic items Following traits are now diagnostic items: - `From` (unchanged) - `Into` - `TryFrom` - `TryInto` This also adds symbols for those items: - `into_trait` - `try_from_trait` - `try_into_trait` Related: rust-lang/rust-clippy#6620 (comment)
Make more traits of the From/Into family diagnostic items Following traits are now diagnostic items: - `From` (unchanged) - `Into` - `TryFrom` - `TryInto` This also adds symbols for those items: - `into_trait` - `try_from_trait` - `try_into_trait` Related: rust-lang#6620 (comment)
@xiongmao86 You now should also have access to the diagnostic items for |
@flip1995 Thanks for the guidance, I found toolchain update today and I The error message is:
and What is the problem? |
When you rebase, you have to force push. Force pushing deletes your previous commits from the repository and you can't get them back (well you can if you still have them locally, but that requires much more git-fu), so you should be careful. If your rebase goes through without any conflicts (which I assume is the case here) force pushing is usually save after a rebase. So |
@flip1995 , May be I mistake |
@flip1995, I was thinking maybe I expressed this item in the wrong way, maybe the name should be |
And about the The description is:
And I see now the point is to understand the concept of |
So
when running
I'm not really sure what you mean. The name of the struct does not really matter for the lint. The lint name comes from the all-caps name in the |
You can understand |
@flip1995, thanks for your explanation, I see what -u is using now, it's for shortcut using. About the lint name, I have not been clear. I used to write lint name And to read |
I think I may have made a mistake when I think of naming the lint. I want to make sure the naming is right. |
Ah good catch. Yeah |
Co-authored-by: Philipp Krones <hello@philkrones.com>
help: remove From bound | ||
| | ||
LL | , | ||
| -- |
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.
This is probably not the best diagnostic message, From<T>
is removed and only comma left.
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.
Yeah, I don't even know if that still compiles. I think you have to track how many bounds there are and tweak the suggestion depending on this.
help: Add this bound predicate | ||
| | ||
LL | u32: From<T>T: Into<u32>, | ||
| ^^^^^^^^^^^^ | ||
|
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 made a mistake here. Didn't notice until now. I'll fix this.
| -- | ||
help: Add this bound predicate | ||
| | ||
LL | u32: Copy + Clone + From<T>, T: Into<u32>, |
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 this probably should be u32: Copy + Clone, T: Into<u32>
, but I don't know how to remove From
showing in this span.
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.
You have to get the span of the From<T>
bound and extend it to the end of the span of the Clone
bound with span.with_lo(clone_bound_span.hi())
And as the suggestion you can just use String::new()
, which will automatically suggest removing it.
@flip1995, are you suggesting using |
☔ The latest upstream changes (presumably #6787) made this pull request unmergeable. Please resolve the merge conflicts. |
You can use |
Sorry for being absent for so long. I currently can't really keep up with my reviews... |
Sorry, @flip1995, seems github.com is ban again at my location. I am trying to get to github.com(read prs, push commits etc.) in a secure way. |
Thank you very much for your help. Please take your time. |
ping from triage @xiongmao86. Can you have any update on this? |
@giraffate, I recently don't have time for this, if you want to take over, please go ahead. |
ping from triage @xiongmao86. According to the triage procedure, I'm closing this because 2 weeks have passed with no activity. |
If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.
check again after every change:
cargo test
passes locallycargo dev update_lints
cargo dev fmt
.stderr
file)Fixes #4894. Using
Into
andTryInto
instead of usingFrom
andTryFrom
.Please write a short comment explaining your change (or "none" for internal only changes)
changelog:
Using
Into
andTryInto
instead of usingFrom
andTryFrom
.