Fix panic when a reference has unspecified lifetime

This will fail later in compilation anyway, but serde_derive needs to
not crash before then.

    #[derive(Deserialize)]
    struct A {
        field: &str,
    }

    error[E0106]: missing lifetime specifier
      --> src/main.rs
       |
       |     field: &str,
       |            ^ expected lifetime parameter
This commit is contained in:
David Tolnay 2018-03-13 09:55:29 -07:00
parent 5bc805329e
commit 56b2e39dda
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -936,7 +936,7 @@ impl Field {
} else if is_rptr(&field.ty, is_str) || is_rptr(&field.ty, is_slice_u8) {
// Types &str and &[u8] are always implicitly borrowed. No need for
// a #[serde(borrow)].
borrowed_lifetimes = borrowable_lifetimes(cx, &ident, &field.ty).unwrap();
collect_lifetimes(&field.ty, &mut borrowed_lifetimes);
}
let ser_name = ser_name.get();