diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-01-11 20:13:48 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-11 20:13:48 +0000 |
commit | 7c1af25b228dd2d039dd7129aab5798fd18f0d6a (patch) | |
tree | e5a1a06d7522ec5c2cf68c27aab9d3688aea9496 /crates/ra_hir_expand | |
parent | 73266085364d2a559d805c6ab942efee7be56f62 (diff) | |
parent | 9f65ae20c2eb862ffd73d0389e4efc272d52ce39 (diff) |
Merge #2795
2795: Use dummy value for macro file in bulitin macros r=matklad a=edwin0cheng
This PR skip the actual line and column computation for `MacroFile` and return a dummy value instead.
Related to #2794
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r-- | crates/ra_hir_expand/src/builtin_macro.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index 2c119269c..e9e275670 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs | |||
@@ -62,8 +62,13 @@ register_builtin! { | |||
62 | } | 62 | } |
63 | 63 | ||
64 | fn to_line_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { | 64 | fn to_line_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { |
65 | // FIXME: Use expansion info | ||
66 | let file_id = file.original_file(db); | 65 | 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 | |||
67 | let text = db.file_text(file_id); | 72 | let text = db.file_text(file_id); |
68 | let mut line_num = 1; | 73 | let mut line_num = 1; |
69 | 74 | ||
@@ -150,8 +155,11 @@ fn option_env_expand( | |||
150 | } | 155 | } |
151 | 156 | ||
152 | fn to_col_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { | 157 | fn to_col_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { |
153 | // FIXME: Use expansion info | ||
154 | let file_id = file.original_file(db); | 158 | 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 | } | ||
155 | let text = db.file_text(file_id); | 163 | let text = db.file_text(file_id); |
156 | 164 | ||
157 | let pos = pos.to_usize(); | 165 | let pos = pos.to_usize(); |