Ignore skipped fields when looking for borrowed lifetimes
This commit is contained in:
parent
2a557a1e36
commit
d5e5c520ac
@ -203,7 +203,9 @@ impl BorrowedLifetimes {
|
|||||||
fn borrowed_lifetimes(cont: &Container) -> BorrowedLifetimes {
|
fn borrowed_lifetimes(cont: &Container) -> BorrowedLifetimes {
|
||||||
let mut lifetimes = BTreeSet::new();
|
let mut lifetimes = BTreeSet::new();
|
||||||
for field in cont.body.all_fields() {
|
for field in cont.body.all_fields() {
|
||||||
lifetimes.extend(field.attrs.borrowed_lifetimes().iter().cloned());
|
if !field.attrs.skip_deserializing() {
|
||||||
|
lifetimes.extend(field.attrs.borrowed_lifetimes().iter().cloned());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if lifetimes.iter().any(|b| b.ident == "'static") {
|
if lifetimes.iter().any(|b| b.ident == "'static") {
|
||||||
BorrowedLifetimes::Static
|
BorrowedLifetimes::Static
|
||||||
|
@ -511,6 +511,14 @@ fn test_gen() {
|
|||||||
Tuple(&'a str, &'static str),
|
Tuple(&'a str, &'static str),
|
||||||
Newtype(&'static str),
|
Newtype(&'static str),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
struct SkippedStaticStr {
|
||||||
|
#[serde(skip_deserializing)]
|
||||||
|
skipped: &'static str,
|
||||||
|
other: isize,
|
||||||
|
}
|
||||||
|
assert::<SkippedStaticStr>();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user