Skip to content

Commit

Permalink
Rollup merge of #131403 - practicalrs:fix_needless_lifetimes_p2, r=pe…
Browse files Browse the repository at this point in the history
…trochenkov

Fix needless_lifetimes in rustc_serialize

Hi,

This PR fixes the following clipy warnings:

```
warning: the following explicit lifetimes could be elided: 'a
   --> compiler/rustc_serialize/src/serialize.rs:328:6
    |
328 | impl<'a, S: Encoder, T: Encodable<S>> Encodable<S> for Cow<'a, [T]>
    |      ^^                                                    ^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
    = note: `#[warn(clippy::needless_lifetimes)]` on by default
help: elide the lifetimes
    |
328 - impl<'a, S: Encoder, T: Encodable<S>> Encodable<S> for Cow<'a, [T]>
328 + impl<S: Encoder, T: Encodable<S>> Encodable<S> for Cow<'_, [T]>
    |

warning: the following explicit lifetimes could be elided: 'a
   --> compiler/rustc_serialize/src/serialize.rs:348:6
    |
348 | impl<'a, S: Encoder> Encodable<S> for Cow<'a, str> {
    |      ^^                                   ^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
help: elide the lifetimes
    |
348 - impl<'a, S: Encoder> Encodable<S> for Cow<'a, str> {
348 + impl<S: Encoder> Encodable<S> for Cow<'_, str> {
    |

warning: the following explicit lifetimes could be elided: 'a
   --> compiler/rustc_serialize/src/serialize.rs:355:6
    |
355 | impl<'a, D: Decoder> Decodable<D> for Cow<'a, str> {
    |      ^^                                   ^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
help: elide the lifetimes
    |
355 - impl<'a, D: Decoder> Decodable<D> for Cow<'a, str> {
355 + impl<D: Decoder> Decodable<D> for Cow<'_, str> {
```

Best regards,
Michal
  • Loading branch information
matthiaskrgr authored Oct 9, 2024
2 parents d583450 + 7ab4666 commit 50f7e80
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_serialize/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl<D: Decoder, const N: usize> Decodable<D> for [u8; N] {
}
}

impl<'a, S: Encoder, T: Encodable<S>> Encodable<S> for Cow<'a, [T]>
impl<S: Encoder, T: Encodable<S>> Encodable<S> for Cow<'_, [T]>
where
[T]: ToOwned<Owned = Vec<T>>,
{
Expand All @@ -345,14 +345,14 @@ where
}
}

impl<'a, S: Encoder> Encodable<S> for Cow<'a, str> {
impl<S: Encoder> Encodable<S> for Cow<'_, str> {
fn encode(&self, s: &mut S) {
let val: &str = self;
val.encode(s)
}
}

impl<'a, D: Decoder> Decodable<D> for Cow<'a, str> {
impl<D: Decoder> Decodable<D> for Cow<'_, str> {
fn decode(d: &mut D) -> Cow<'static, str> {
let v: String = Decodable::decode(d);
Cow::Owned(v)
Expand Down

0 comments on commit 50f7e80

Please sign in to comment.