Change:
Stable, and nightly-2019-09-09: nightly-2019-09-10: Mentioning because this is likely from .
Yeah, this is some known shortcut taken in , sorry. Didn't expect people to hit it that fast. Will fix ~this weekend.
Thanks. The realistic usage where this appears is if you forget to import a derive macro, which happens commonly.
Un-nominating since Vadim self-assigned.
triage: P-high.
Fixed in

Discussion:
self.definitions.create_def_with_parent(parent_def, node_id, data, self.expansion, span) } <del> pub fn with_parent<F: FnOnce(&mut Self)>(&mut self, parent_def: DefIndex, f: F) { </del> <ins> fn with_parent<F: FnOnce(&mut Self)>(&mut self, parent_def: DefIndex, f: F) { </ins> let orig_parent_def = std::mem::replace(&mut self.parent_def, parent_def); f(self); self.parent_def = orig_parent_def;

}) } <ins> fn collect_field(&mut self, field: &'a StructField, index: Option<usize>) { if field.is_placeholder { self.visit_macro_invoc(field.id); } else { let name = field.ident.map(|ident| ident.name) .or_else(|| index.map(sym::integer)) .unwrap_or_else(|| { let node_id = NodeId::placeholder_from_expn_id(self.expansion); sym::integer(self.definitions.placeholder_field_indices[&node_id]) }) .as_interned_str(); let def = self.create_def(field.id, DefPathData::ValueNs(name), field.span); self.with_parent(def, |this| visit::walk_struct_field(this, field)); } } </ins> pub fn visit_macro_invoc(&mut self, id: NodeId) { self.definitions.set_invocation_parent(id.placeholder_to_expn_id(), self.parent_def); }

} fn visit_variant_data(&mut self, data: &'a VariantData) { <ins> // The assumption here is that non-`cfg` macro expansion cannot change field indices. // It currently holds because only inert attributes are accepted on fields, // and every such attribute expands into a single field after it's resolved. </ins> for (index, field) in data.fields().iter().enumerate() { <del> if field.is_placeholder { self.visit_macro_invoc(field.id); continue; </del> <ins> self.collect_field(field, Some(index)); if field.is_placeholder && field.ident.is_none() { self.definitions.placeholder_field_indices.insert(field.id, index); </ins> } <del> let name = field.ident.map(|ident| ident.name) .unwrap_or_else(|| sym::integer(index)); let def = self.create_def(field.id, DefPathData::ValueNs(name.as_interned_str()), field.span); self.with_parent(def, |this| visit::walk_struct_field(this, field)); </del> } }

} } <del> fn visit_struct_field(&mut self, sf: &'a StructField) { if sf.is_placeholder { self.visit_macro_invoc(sf.id) } else { let name = sf.ident.map(|ident| ident.name) .unwrap_or_else(|| panic!("don't know the field number in this context")); let def = self.create_def(sf.id, DefPathData::ValueNs(name.as_interned_str()), sf.span); self.with_parent(def, |this| visit::walk_struct_field(this, sf)); } </del> <ins> // This method is called only when we are visiting an individual field // after expanding an attribute on it. fn visit_struct_field(&mut self, field: &'a StructField) { self.collect_field(field, None); </ins> } }

/// When collecting definitions from an AST fragment produced by a macro invocation `ExpnId` /// we know what parent node that fragment should be attached to thanks to this table. invocation_parents: FxHashMap<ExpnId, DefIndex>, <ins> /// Indices of unnamed struct or variant fields with unresolved attributes. pub(super) placeholder_field_indices: NodeMap<usize>, </ins> } /// A unique identifier that we can use to lookup a definition

<ins> // check-pass struct S( #[rustfmt::skip] u8, u16, #[rustfmt::skip] u32, ); fn main() {} </ins>