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())
|
.and_then(|variant| variant.borrow.as_ref())
|
||||||
.map(|borrow| Meta(borrow.clone()));
|
.map(|borrow| Meta(borrow.clone()));
|
||||||
|
|
||||||
for meta_item in field
|
for meta_item in variant_borrow.into_iter().chain(
|
||||||
|
field
|
||||||
.attrs
|
.attrs
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|attr| get_serde_meta_items(cx, attr))
|
.flat_map(|attr| get_serde_meta_items(cx, attr))
|
||||||
.flatten()
|
.flatten(),
|
||||||
.chain(variant_borrow)
|
) {
|
||||||
{
|
|
||||||
match &meta_item {
|
match &meta_item {
|
||||||
// Parse `#[serde(rename = "foo")]`
|
// Parse `#[serde(rename = "foo")]`
|
||||||
Meta(NameValue(m)) if m.path == RENAME => {
|
Meta(NameValue(m)) if m.path == RENAME => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error: duplicate serde attribute `borrow`
|
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