tracel-ai/burn · error
Path meta unsupported
Error message
Path meta unsupported
What it means
Attribute-syntax guard in the shared derive helper: `AttributeAnalyzer::item` accepts only list-style (`#[attr(key = value)]`) and name-value (`#[attr = "x"]`) metadata; a bare path attribute like `#[attr]` with no value reaches the `Meta::Path` arm and panics during macro expansion. The failing input is an attribute written without an `= value` part.
Source
Thrown at crates/burn-derive/src/shared/attribute.rs:21
pub struct AttributeAnalyzer {
attr: Attribute,
}
#[derive(Clone)]
pub struct AttributeItem {
pub value: syn::Lit,
}
impl AttributeAnalyzer {
pub fn new(attr: Attribute) -> Self {
Self { attr }
}
pub fn item(&self) -> AttributeItem {
let value = match &self.attr.meta {
Meta::List(val) => val.parse_args::<syn::MetaNameValue>().unwrap(),
Meta::NameValue(meta) => meta.clone(),
Meta::Path(_) => panic!("Path meta unsupported"),
};
let lit = match value.value {
syn::Expr::Lit(lit) => lit.lit,
_ => panic!("Only literal is supported"),
};
AttributeItem { value: lit }
}
pub fn has_name(&self, name: &str) -> bool {
Self::path_syn_name(self.attr.path()) == name
}
fn path_syn_name(path: &syn::Path) -> String {
let length = path.segments.len();
let mut name = String::new();
for (i, segment) in path.segments.iter().enumerate() {View on GitHub (pinned to d16f7ba2ed)
Solutions
- Use a plain literal (string, integer, bool) as the attribute value instead of an expression.
- Precompute the value in source (e.g. `1_024` not `1024 * 1024` is still a literal; function calls are not).
- Extend `AttributeAnalyzer` to evaluate constant expressions if dynamic values are genuinely required.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/burn-derive/src/shared/attribute.rs:21 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/5ad69864ebddf2d9.
Report an issue: GitHub.