Skip to content

Commit 8b85815

Browse files
authored
Rollup merge of rust-lang#99578 - steffahn:remove_redundant_bound, r=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:)_ ![Screenshot_20220722_014055](https://user-images.githubusercontent.com/3986214/180332665-424d0c05-afb3-40d8-a330-a57a2c9a494b.png)
2 parents 152a966 + c03d10c commit 8b85815

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

library/alloc/src/borrow.rs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use Cow::*;
2121
impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
2222
where
2323
B: ToOwned,
24-
<B as ToOwned>::Owned: 'a,
2524
{
2625
fn borrow(&self) -> &B {
2726
&**self

0 commit comments

Comments
 (0)