Skip to content

Commit c089795

Browse files
Merge #8104
8104: Rename derive-specific APIs r=jonas-schievink a=jonas-schievink Indicate that they're derive-specific bors r+ Co-authored-by: Jonas Schievink <[email protected]>
2 parents a627377 + 54c78c9 commit c089795

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

crates/hir_def/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ fn macro_call_as_call_id(
673673
Ok(res)
674674
}
675675

676-
fn item_attr_as_call_id(
676+
fn derive_macro_as_call_id(
677677
item_attr: &AstIdWithPath<ast::Item>,
678678
db: &dyn db::DefDatabase,
679679
krate: CrateId,
@@ -685,7 +685,7 @@ fn item_attr_as_call_id(
685685
.as_lazy_macro(
686686
db.upcast(),
687687
krate,
688-
MacroCallKind::Attr(item_attr.ast_id, last_segment.to_string()),
688+
MacroCallKind::Derive(item_attr.ast_id, last_segment.to_string()),
689689
)
690690
.into();
691691
Ok(res)

crates/hir_def/src/nameres.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ mod diagnostics {
575575
let node = ast.to_node(db.upcast());
576576
(ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)), None)
577577
}
578-
MacroCallKind::Attr(ast, name) => {
578+
MacroCallKind::Derive(ast, name) => {
579579
let node = ast.to_node(db.upcast());
580580

581581
// Compute the precise location of the macro name's token in the derive
@@ -631,7 +631,7 @@ mod diagnostics {
631631
let node = ast.to_node(db.upcast());
632632
(ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)))
633633
}
634-
MacroCallKind::Attr(ast, _) => {
634+
MacroCallKind::Derive(ast, _) => {
635635
let node = ast.to_node(db.upcast());
636636
(ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)))
637637
}

crates/hir_def/src/nameres/collector.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use syntax::ast;
2222
use crate::{
2323
attr::Attrs,
2424
db::DefDatabase,
25-
item_attr_as_call_id,
25+
derive_macro_as_call_id,
2626
item_scope::{ImportType, PerNsGlobImports},
2727
item_tree::{
2828
self, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, MacroRules, Mod, ModItem, ModKind,
@@ -820,8 +820,8 @@ impl DefCollector<'_> {
820820
true
821821
});
822822
attribute_macros.retain(|directive| {
823-
match item_attr_as_call_id(&directive.ast_id, self.db, self.def_map.krate, |path| {
824-
self.resolve_attribute_macro(&directive, &path)
823+
match derive_macro_as_call_id(&directive.ast_id, self.db, self.def_map.krate, |path| {
824+
self.resolve_derive_macro(&directive, &path)
825825
}) {
826826
Ok(call_id) => {
827827
resolved.push((directive.module_id, call_id, 0));
@@ -844,7 +844,7 @@ impl DefCollector<'_> {
844844
res
845845
}
846846

847-
fn resolve_attribute_macro(
847+
fn resolve_derive_macro(
848848
&self,
849849
directive: &DeriveDirective,
850850
path: &ModPath,

crates/hir_expand/src/builtin_derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ $0
317317
local_inner: false,
318318
},
319319
krate: CrateId(0),
320-
kind: MacroCallKind::Attr(attr_id, name.to_string()),
320+
kind: MacroCallKind::Derive(attr_id, name.to_string()),
321321
};
322322

323323
let id: MacroCallId = db.intern_macro(loc).into();

crates/hir_expand/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,21 +271,21 @@ pub struct MacroCallLoc {
271271
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
272272
pub enum MacroCallKind {
273273
FnLike(AstId<ast::MacroCall>),
274-
Attr(AstId<ast::Item>, String),
274+
Derive(AstId<ast::Item>, String),
275275
}
276276

277277
impl MacroCallKind {
278278
fn file_id(&self) -> HirFileId {
279279
match self {
280280
MacroCallKind::FnLike(ast_id) => ast_id.file_id,
281-
MacroCallKind::Attr(ast_id, _) => ast_id.file_id,
281+
MacroCallKind::Derive(ast_id, _) => ast_id.file_id,
282282
}
283283
}
284284

285285
fn node(&self, db: &dyn db::AstDatabase) -> InFile<SyntaxNode> {
286286
match self {
287287
MacroCallKind::FnLike(ast_id) => ast_id.with_value(ast_id.to_node(db).syntax().clone()),
288-
MacroCallKind::Attr(ast_id, _) => {
288+
MacroCallKind::Derive(ast_id, _) => {
289289
ast_id.with_value(ast_id.to_node(db).syntax().clone())
290290
}
291291
}
@@ -296,7 +296,7 @@ impl MacroCallKind {
296296
MacroCallKind::FnLike(ast_id) => {
297297
Some(ast_id.to_node(db).token_tree()?.syntax().clone())
298298
}
299-
MacroCallKind::Attr(ast_id, _) => Some(ast_id.to_node(db).syntax().clone()),
299+
MacroCallKind::Derive(ast_id, _) => Some(ast_id.to_node(db).syntax().clone()),
300300
}
301301
}
302302
}

0 commit comments

Comments
 (0)