-
Notifications
You must be signed in to change notification settings - Fork 1.7k
from_over_into suggests docs antipatterns for foreign types #6607
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Nightly clippy strikes again. `Request` and `Response` ignore this, because it makes the docs worse. See rust-lang/rust-clippy#6607 Switched `RequestBuilder` -> `Request` to use `From`.
Nightly clippy strikes again. `Request` and `Response` ignore this, because it makes the docs worse. See rust-lang/rust-clippy#6607 Switched `RequestBuilder` -> `Request` to use `From`.
Refs: #6476 |
The recommendation is correct even if triggers a rustdoc bug - rust-lang/rust#42066. This should be fixed on the rustdoc side. |
Why exactly this isn't an error? |
From docs: |
https://blog.rust-lang.org/2020/01/30/Rust-1.41.0.html#relaxed-restrictions-when-implementing-traits
That's exactly what the lint is recommending. |
@mikerite shouldn't linter follow official docs and guidelines? |
That's what we're doing. We lint |
This issue here is that it is hard to deduce the conversions when reading rustdoc. Which means, frankly, we'll continue to ignore this until that improves (hence the "docs antipatterns"). |
Closing per mikerite's comments. |
Lint name: from_over_into
I tried this code:
https://github.com/http-rs/surf at today's HEAD: 97790c19664466efa4cf33d9eafee23486a12b3e
I expected to see this happen: no warnings
Instead, this happened:
Changing this to
From
is, shockingly, not an error, despite being a foreign trait on a foreign type.However, it results in Rust docs which are even more difficult to read than today's.
I will note there is some "super-structing" / inheritance going on here, where
surf::Response
is essentially a supertype ofhttp_types::Response
, and hasFrom
/Into
each other, and down-referencing viaAsRef
/AsMut
.I don't think this rule should detect
Into<foreign type>
.Docs examples:
Into<Response>
:From<Response>
:Meta
cargo clippy -V
: clippy 0.1.51 (4253153 2021-01-17)rustc -Vv
:The text was updated successfully, but these errors were encountered: