Skip to content

Commit 9f65ae2

Browse files
committed
Use dummy value for macro file in bulitin macros
1 parent a9ba32e commit 9f65ae2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

crates/ra_hir_expand/src/builtin_macro.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,13 @@ register_builtin! {
6262
}
6363

6464
fn to_line_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize {
65-
// FIXME: Use expansion info
6665
let file_id = file.original_file(db);
66+
67+
// FIXME: if the file is coming from macro, we return a dummy value for now.
68+
if file.call_node(db).map(|it| it.file_id != file_id.into()).unwrap_or(true) {
69+
return 0;
70+
}
71+
6772
let text = db.file_text(file_id);
6873
let mut line_num = 1;
6974

@@ -150,8 +155,11 @@ fn option_env_expand(
150155
}
151156

152157
fn to_col_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize {
153-
// FIXME: Use expansion info
154158
let file_id = file.original_file(db);
159+
// FIXME: if the file is coming from macro, we return a dummy value for now.
160+
if file.call_node(db).map(|it| it.file_id != file_id.into()).unwrap_or(true) {
161+
return 0;
162+
}
155163
let text = db.file_text(file_id);
156164

157165
let pos = pos.to_usize();

0 commit comments

Comments
 (0)