mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 05:31:02 +00:00
Merge pull request #2592 from dtolnay/remotenonexhaustive
Fix "cannot move out of *self which is behind a shared reference"
This commit is contained in:
@@ -409,9 +409,9 @@ fn serialize_enum(params: &Parameters, variants: &[Variant], cattrs: &attr::Cont
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if cattrs.non_exhaustive() {
|
if cattrs.remote().is_some() && cattrs.non_exhaustive() {
|
||||||
arms.push(quote! {
|
arms.push(quote! {
|
||||||
unrecognized => _serde::__private::Err(_serde::ser::Error::custom(_serde::__private::ser::CannotSerializeVariant(unrecognized))),
|
ref unrecognized => _serde::__private::Err(_serde::ser::Error::custom(_serde::__private::ser::CannotSerializeVariant(unrecognized))),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ struct Test {
|
|||||||
enum_concrete: remote::EnumGeneric<u8>,
|
enum_concrete: remote::EnumGeneric<u8>,
|
||||||
|
|
||||||
#[serde(with = "ErrorKindDef")]
|
#[serde(with = "ErrorKindDef")]
|
||||||
io_error_kind: std::io::ErrorKind,
|
io_error_kind: ErrorKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
@@ -200,8 +200,16 @@ enum EnumConcrete {
|
|||||||
Variant(u8),
|
Variant(u8),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
enum ErrorKind {
|
||||||
|
NotFound,
|
||||||
|
PermissionDenied,
|
||||||
|
#[allow(dead_code)]
|
||||||
|
ConnectionRefused,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[serde(remote = "std::io::ErrorKind")]
|
#[serde(remote = "ErrorKind")]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
enum ErrorKindDef {
|
enum ErrorKindDef {
|
||||||
NotFound,
|
NotFound,
|
||||||
|
|||||||
Reference in New Issue
Block a user