aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_expand/src/lib.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-04-08 19:43:07 +0100
committerJonas Schievink <[email protected]>2021-04-08 19:43:07 +0100
commit86b7861612ba074120dfb6bd32c80c569688748d (patch)
tree3403086d9e04417e92b0c3ad2af09151e698a3c5 /crates/hir_expand/src/lib.rs
parent5f279d57f0cba600eae8c550654a00b4268812ac (diff)
Use named fields in `MacroCallKind`
Diffstat (limited to 'crates/hir_expand/src/lib.rs')
-rw-r--r--crates/hir_expand/src/lib.rs18
1 files changed, 10 insertions, 8 deletions
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 {
290 290
291#[derive(Debug, Clone, PartialEq, Eq, Hash)] 291#[derive(Debug, Clone, PartialEq, Eq, Hash)]
292pub enum MacroCallKind { 292pub enum MacroCallKind {
293 FnLike(AstId<ast::MacroCall>), 293 FnLike { ast_id: AstId<ast::MacroCall> },
294 Derive(AstId<ast::Item>, String), 294 Derive { ast_id: AstId<ast::Item>, derive_name: String },
295} 295}
296 296
297impl MacroCallKind { 297impl MacroCallKind {
298 fn file_id(&self) -> HirFileId { 298 fn file_id(&self) -> HirFileId {
299 match self { 299 match self {
300 MacroCallKind::FnLike(ast_id) => ast_id.file_id, 300 MacroCallKind::FnLike { ast_id, .. } => ast_id.file_id,
301 MacroCallKind::Derive(ast_id, _) => ast_id.file_id, 301 MacroCallKind::Derive { ast_id, .. } => ast_id.file_id,
302 } 302 }
303 } 303 }
304 304
305 fn node(&self, db: &dyn db::AstDatabase) -> InFile<SyntaxNode> { 305 fn node(&self, db: &dyn db::AstDatabase) -> InFile<SyntaxNode> {
306 match self { 306 match self {
307 MacroCallKind::FnLike(ast_id) => ast_id.with_value(ast_id.to_node(db).syntax().clone()), 307 MacroCallKind::FnLike { ast_id, .. } => {
308 MacroCallKind::Derive(ast_id, _) => { 308 ast_id.with_value(ast_id.to_node(db).syntax().clone())
309 }
310 MacroCallKind::Derive { ast_id, .. } => {
309 ast_id.with_value(ast_id.to_node(db).syntax().clone()) 311 ast_id.with_value(ast_id.to_node(db).syntax().clone())
310 } 312 }
311 } 313 }
@@ -313,10 +315,10 @@ impl MacroCallKind {
313 315
314 fn arg(&self, db: &dyn db::AstDatabase) -> Option<SyntaxNode> { 316 fn arg(&self, db: &dyn db::AstDatabase) -> Option<SyntaxNode> {
315 match self { 317 match self {
316 MacroCallKind::FnLike(ast_id) => { 318 MacroCallKind::FnLike { ast_id, .. } => {
317 Some(ast_id.to_node(db).token_tree()?.syntax().clone()) 319 Some(ast_id.to_node(db).token_tree()?.syntax().clone())
318 } 320 }
319 MacroCallKind::Derive(ast_id, _) => Some(ast_id.to_node(db).syntax().clone()), 321 MacroCallKind::Derive { ast_id, .. } => Some(ast_id.to_node(db).syntax().clone()),
320 } 322 }
321 } 323 }
322} 324}