Remove redundant lifetime bound from impl Borrow for Cow#99578
Remove redundant lifetime bound from impl Borrow for Cow#99578bors merged 1 commit intorust-lang:masterfrom
impl Borrow for Cow#99578Conversation
The lifetime bound `B::Owned: 'a` is redundant and doesn't make a difference, because `Cow<'a, B>` comes with an implicit `B: 'a`, and associated types will outlive lifetimes outlived by the `Self` type (and all the trait's generic parameters, of which there are none in this case), so the implicit `B: 'a` implies `B::Owned: 'a` anyway. The explicit lifetime bound here does however end up in documentation, and that's confusing in my opinion, so let's remove it ^^
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
|
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
| @@ -21,7 +21,6 @@ use Cow::*; | |||
| impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B> | |||
There was a problem hiding this comment.
If you want it to look the same as the AsRef impl, you can also remove the 'a lifetime:
| impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B> | |
| impl<B: ?Sized> Borrow<B> for Cow<'_, B> |
There was a problem hiding this comment.
In terms of how the rendered documentation comes out, I actually prefer the way it looks with the explicit lifetime, since otherwise it still renders as invalid Rust code with the impl<'_> part.
|
This is a small improvement that doesn't change semantics at all, but helps the generated documentation. @bors r+ rollup |
…thomcc Remove redundant lifetime bound from `impl Borrow for Cow` The lifetime bound `B::Owned: 'a` is redundant and doesn't make a difference, because `Cow<'a, B>` comes with an implicit `B: 'a`, and associated types will outlive lifetimes outlived by the `Self` type (and all the trait's generic parameters, of which there are none in this case), so the implicit `B: 'a` implies `B::Owned: 'a` anyway. The explicit lifetime bound here does however [end up in documentation](https://doc.rust-lang.org/std/borrow/enum.Cow.html#impl-Borrow%3CB%3E), and that's confusing in my opinion, so let's remove it ^^ _(Documentation right now, compare to `AsRef`, too:)_ 
…thomcc Remove redundant lifetime bound from `impl Borrow for Cow` The lifetime bound `B::Owned: 'a` is redundant and doesn't make a difference, because `Cow<'a, B>` comes with an implicit `B: 'a`, and associated types will outlive lifetimes outlived by the `Self` type (and all the trait's generic parameters, of which there are none in this case), so the implicit `B: 'a` implies `B::Owned: 'a` anyway. The explicit lifetime bound here does however [end up in documentation](https://doc.rust-lang.org/std/borrow/enum.Cow.html#impl-Borrow%3CB%3E), and that's confusing in my opinion, so let's remove it ^^ _(Documentation right now, compare to `AsRef`, too:)_ 
Rollup of 7 pull requests Successful merges: - rust-lang#99578 (Remove redundant lifetime bound from `impl Borrow for Cow`) - rust-lang#99939 (Sort tests at compile time, not at startup) - rust-lang#102271 (Stabilize `duration_checked_float`) - rust-lang#102766 (Don't link to `libresolv` in libstd on Darwin) - rust-lang#103277 (Update libstd's libc to 0.2.135 (to make `libstd` no longer pull in `libiconv.dylib` on Darwin)) - rust-lang#103437 (Sync rustc_codegen_cranelift) - rust-lang#103466 (Fix grammar in docs for std::io::Read) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
The lifetime bound
B::Owned: 'ais redundant and doesn't make a difference,because
Cow<'a, B>comes with an implicitB: 'a, and associated typeswill outlive lifetimes outlived by the
Selftype (and all the trait'sgeneric parameters, of which there are none in this case), so the implicit
B: 'aimplies
B::Owned: 'aanyway.The explicit lifetime bound here does however end up in documentation,
and that's confusing in my opinion, so let's remove it ^^
(Documentation right now, compare to

AsRef, too:)