diff options
Diffstat (limited to 'crates/hir_def/src/nameres')
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index 55228e480..a636ec77d 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -1289,20 +1289,20 @@ impl ModCollector<'_, '_> { | |||
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | fn collect_derives(&mut self, attrs: &Attrs, ast_id: FileAstId<ast::Item>) { | 1291 | fn collect_derives(&mut self, attrs: &Attrs, ast_id: FileAstId<ast::Item>) { |
1292 | for derive_subtree in attrs.by_key("derive").tt_values() { | 1292 | for derive in attrs.by_key("derive").attrs() { |
1293 | // for #[derive(Copy, Clone)], `derive_subtree` is the `(Copy, Clone)` subtree | 1293 | match derive.parse_derive() { |
1294 | for tt in &derive_subtree.token_trees { | 1294 | Some(derive_macros) => { |
1295 | let ident = match &tt { | 1295 | for path in derive_macros { |
1296 | tt::TokenTree::Leaf(tt::Leaf::Ident(ident)) => ident, | 1296 | let ast_id = AstIdWithPath::new(self.file_id, ast_id, path); |
1297 | tt::TokenTree::Leaf(tt::Leaf::Punct(_)) => continue, // , is ok | 1297 | self.def_collector |
1298 | _ => continue, // anything else would be an error (which we currently ignore) | 1298 | .unexpanded_attribute_macros |
1299 | }; | 1299 | .push(DeriveDirective { module_id: self.module_id, ast_id }); |
1300 | let path = ModPath::from_tt_ident(ident); | 1300 | } |
1301 | 1301 | } | |
1302 | let ast_id = AstIdWithPath::new(self.file_id, ast_id, path); | 1302 | None => { |
1303 | self.def_collector | 1303 | // FIXME: diagnose |
1304 | .unexpanded_attribute_macros | 1304 | log::debug!("malformed derive: {:?}", derive); |
1305 | .push(DeriveDirective { module_id: self.module_id, ast_id }); | 1305 | } |
1306 | } | 1306 | } |
1307 | } | 1307 | } |
1308 | } | 1308 | } |