diff options
Diffstat (limited to 'src/librustc_expand')
| -rw-r--r-- | src/librustc_expand/expand.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/librustc_expand/expand.rs b/src/librustc_expand/expand.rs index f915f44c17a..a65ba8903be 100644 --- a/src/librustc_expand/expand.rs +++ b/src/librustc_expand/expand.rs @@ -435,14 +435,13 @@ impl<'a, 'b> MacroExpander<'a, 'b> { _ => unreachable!(), }; if !item.derive_allowed() { - let attr = attr::find_by_name(item.attrs(), sym::derive) - .expect("`derive` attribute should exist"); - let span = attr.span; + let attr = attr::find_by_name(item.attrs(), sym::derive); + let span = attr.map_or(item.span(), |attr| attr.span); let mut err = self.cx.struct_span_err( span, "`derive` may only be applied to structs, enums and unions", ); - if let ast::AttrStyle::Inner = attr.style { + if let Some(ast::Attribute { style: ast::AttrStyle::Inner, .. }) = attr { let trait_list = derives .iter() .map(|t| pprust::path_to_string(t)) |
