Merge pull request #2398 from dtolnay/borrow
Treat field-level borrow attr as duplicate of variant-level borrow attr
This commit is contained in:
commit
696f6f56db
@ -1114,13 +1114,13 @@ impl Field {
|
||||
.and_then(|variant| variant.borrow.as_ref())
|
||||
.map(|borrow| Meta(borrow.clone()));
|
||||
|
||||
for meta_item in field
|
||||
for meta_item in variant_borrow.into_iter().chain(
|
||||
field
|
||||
.attrs
|
||||
.iter()
|
||||
.flat_map(|attr| get_serde_meta_items(cx, attr))
|
||||
.flatten()
|
||||
.chain(variant_borrow)
|
||||
{
|
||||
.flatten(),
|
||||
) {
|
||||
match &meta_item {
|
||||
// Parse `#[serde(rename = "foo")]`
|
||||
Meta(NameValue(m)) if m.path == RENAME => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: duplicate serde attribute `borrow`
|
||||
--> tests/ui/borrow/duplicate_variant.rs:8:13
|
||||
--> tests/ui/borrow/duplicate_variant.rs:9:15
|
||||
|
|
||||
8 | #[serde(borrow)]
|
||||
9 | S(#[serde(borrow)] Str<'a>),
|
||||
| ^^^^^^
|
||||
|
Loading…
x
Reference in New Issue
Block a user