Skip to content

Commit

Permalink
Restore compatibility with rustc <1.31 in Borrowed identifier deseria…
Browse files Browse the repository at this point in the history
…lizer

The implied lifetime bound on T only works on 1.31+. Older versions fail
with:

    error[E0309]: the parameter type `T` may not live long enough
        --> serde/src/private/de.rs:2548:37
         |
    2548 | pub struct Borrowed<'de, T: ?Sized>(pub &'de T);
         |                          --         ^^^^^^^^^^
         |                          |
         |                          help: consider adding an explicit lifetime bound `T: 'de`...
         |
    note: ...so that the reference type `&'de T` does not outlive the data it points at
        --> serde/src/private/de.rs:2548:37
         |
    2548 | pub struct Borrowed<'de, T: ?Sized>(pub &'de T);
         |                                     ^^^^^^^^^^
  • Loading branch information
dtolnay committed Jan 24, 2021
1 parent b6a2d07 commit 3f48ed3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion serde/src/private/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,7 @@ pub trait IdentifierDeserializer<'de, E: Error> {
fn from(self) -> Self::Deserializer;
}

pub struct Borrowed<'de, T: ?Sized>(pub &'de T);
pub struct Borrowed<'de, T: 'de + ?Sized>(pub &'de T);

impl<'de, E> IdentifierDeserializer<'de, E> for u64
where
Expand Down

0 comments on commit 3f48ed3

Please sign in to comment.