denoland/deno · error · syn::Error
`content` requires `tag` to be specified
Error message
`content` requires `tag` to be specified
What it means
In ToV8's enum mode parser, the (tag, content) pair maps to: neither = externally tagged, tag only = internally tagged, tag+content = adjacently tagged, and content without tag is impossible (adjacent tagging needs a tag key to work), so it returns this compile error. The message points you at the missing half of the pair.
Source
Thrown at libs/ops/conversion/to_v8/enum.rs:281
if tag.is_some() || content.is_some() {
return Err(Error::new(
Span::call_site(),
"Cannot combine `untagged` with `tag` or `content`",
));
}
return Ok(EnumMode::Untagged);
}
match (tag, content) {
(None, None) => Ok(EnumMode::ExternallyTagged),
(Some(tag), None) => Ok(EnumMode::InternallyTagged {
tag: crate::get_internalized_string(Ident::new(&tag, span))?,
}),
(Some(tag), Some(content)) => Ok(EnumMode::AdjacentlyTagged {
tag: crate::get_internalized_string(Ident::new(&tag, span))?,
content: crate::get_internalized_string(Ident::new(&content, span))?,
}),
(None, Some(_)) => Err(Error::new(
Span::call_site(),
"`content` requires `tag` to be specified",
)),
}
}
}
#[allow(dead_code, reason = "unused properties")]
enum EnumModeArgument {
Tag {
name_token: shared_kw::tag,
eq_token: Token![=],
value: LitStr,
},
Content {
name_token: shared_kw::content,
eq_token: Token![=],
value: LitStr,View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Add the tag argument: #[to_v8(tag = "kind", content = "data")] — content is only valid as the second half of adjacent tagging.
- If you did not want a tag at all, remove the content argument to fall back to plain externally-tagged output.
Example fix
// before
#[derive(ToV8)]
#[to_v8(content = "data")] // error: `content` requires `tag` to be specified
enum Event {
Click { x: i32 },
}
// after
#[derive(ToV8)]
#[to_v8(tag = "type", content = "data")]
enum Event {
Click { x: i32 },
} Defensive patterns
Strategy: validation
Prevention
- Remember content= is only valid together with tag=; copy adjacently-tagged examples as a pair.
- Let the compiler guide you: fix the first enum-mode error before adding more container attributes.
When it happens
Trigger: Writing #[to_v8(content = "data")] on a #[derive(ToV8)] enum without also specifying #[to_v8(tag = "...")].
Common situations: Copying just the content argument from an adjacently-tagged serde/ToV8 example; renaming or deleting the tag argument during a refactor and missing that content depends on it.
Related errors
- Cannot use serde on unit variant
- Cannot combine `untagged` with `tag` or `content`
- FromV8 enum derive currently supports only unit and single-e
- Unions are not supported
- Unit structs cannot be destructured
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/e9bc86171a978820.
Report an issue: GitHub.