From 86b7861612ba074120dfb6bd32c80c569688748d Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 8 Apr 2021 20:43:07 +0200 Subject: Use named fields in `MacroCallKind` --- crates/hir_expand/src/lib.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'crates/hir_expand/src/lib.rs') diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs index 3e332ee47..a179102f0 100644 --- a/crates/hir_expand/src/lib.rs +++ b/crates/hir_expand/src/lib.rs @@ -290,22 +290,24 @@ pub struct MacroCallLoc { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum MacroCallKind { - FnLike(AstId), - Derive(AstId, String), + FnLike { ast_id: AstId }, + Derive { ast_id: AstId, derive_name: String }, } impl MacroCallKind { fn file_id(&self) -> HirFileId { match self { - MacroCallKind::FnLike(ast_id) => ast_id.file_id, - MacroCallKind::Derive(ast_id, _) => ast_id.file_id, + MacroCallKind::FnLike { ast_id, .. } => ast_id.file_id, + MacroCallKind::Derive { ast_id, .. } => ast_id.file_id, } } fn node(&self, db: &dyn db::AstDatabase) -> InFile { match self { - MacroCallKind::FnLike(ast_id) => ast_id.with_value(ast_id.to_node(db).syntax().clone()), - MacroCallKind::Derive(ast_id, _) => { + MacroCallKind::FnLike { ast_id, .. } => { + ast_id.with_value(ast_id.to_node(db).syntax().clone()) + } + MacroCallKind::Derive { ast_id, .. } => { ast_id.with_value(ast_id.to_node(db).syntax().clone()) } } @@ -313,10 +315,10 @@ impl MacroCallKind { fn arg(&self, db: &dyn db::AstDatabase) -> Option { match self { - MacroCallKind::FnLike(ast_id) => { + MacroCallKind::FnLike { ast_id, .. } => { Some(ast_id.to_node(db).token_tree()?.syntax().clone()) } - MacroCallKind::Derive(ast_id, _) => Some(ast_id.to_node(db).syntax().clone()), + MacroCallKind::Derive { ast_id, .. } => Some(ast_id.to_node(db).syntax().clone()), } } } -- cgit v1.2.3