Restore compatibility with rustc <1.31 in Borrowed identifier deserializer

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);
         |                                     ^^^^^^^^^^
This commit is contained in:
David Tolnay 2021-01-23 20:18:15 -08:00
parent b6a2d07f26
commit 3f48ed36cc
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -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