Skip to content
Myr

Fix borrow error on pre-NLL compilers

Before adoption: this commit came in with the history the project adopted, so no landing records it.

error[E0506]: cannot assign to `missing_content` because it is borrowed --> serde_derive/src/de.rs:1414:9 | 1388 | .filter_map(|(i, variant)| { | -------------- borrow of `missing_content` occurs here ... 1414 | / missing_content = quote! { 1415 | | match __field { 1416 | | #(#missing_content_arms)* 1417 | | #missing_content_fallthrough 1418 | | } 1419 | | }; | |_________^ assignment to borrowed `missing_content` occurs here error[E0502]: cannot borrow `missing_content_fallthrough` as immutable because it is also borrowed as mutable --> serde_derive/src/de.rs:1414:27 | 1388 | .filter_map(|(i, variant)| { | -------------- mutable borrow occurs here ... 1404 | missing_content_fallthrough = quote!(_ => #missing_content); | --------------------------- previous borrow occurs due to use of `missing_content_fallthrough` in closure ... 1414 | missing_content = quote! { | ___________________________^ 1415 | | match __field { 1416 | | #(#missing_content_arms)* 1417 | | #missing_content_fallthrough 1418 | | } 1419 | | }; | |_________^ immutable borrow occurs here ... 1622 | } | - mutable borrow ends here | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

authored by David Tolnay · committed by David Tolnay · parent b97a183 · Browse files · 1 file+3 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−3 removed

  • other:+3 added−3 removed

1 file+3 added−3 removed

modified:serde_derive/src/de.rs+3 added-3 removed
1379 unmodified lines
1380 let mut missing_content = quote! {1381 _serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#content))1382 };1383 let mut missing_content_fallthrough = quote!();1384 let mut missing_content_arms = variants1384 let missing_content_arms = variants1385 .iter()1386 .enumerate()1387 .filter(|&(_, variant)| !variant.attrs.skip_deserializing())1388 .filter_map(|(i, variant)| {
19 unmodified lines
1408 Some(quote! {1409 __Field::#variant_index => #arm,1410 })1411 })1412 .peekable();1413 if missing_content_arms.peek().is_some() {1412 .collect::<Vec<_>>();1413 if !missing_content_arms.is_empty() {1414 missing_content = quote! {1415 match __field {1416 #(#missing_content_arms)*1417 #missing_content_fallthrough
1632 unmodified lines