diff options
author | Edwin Cheng <[email protected]> | 2020-03-07 08:25:43 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-03-07 11:08:42 +0000 |
commit | 18f88ad10bed9f8d82a3a67c2bb9eb23995641a0 (patch) | |
tree | f6d9895dc110a963f147dee9140775853412fd30 /crates/ra_hir_expand | |
parent | 919747c323359724b3b451a43ed82152014c73de (diff) |
Prevent include! macro include itself
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r-- | crates/ra_hir_expand/src/builtin_macro.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index a57e9285f..9bc33cfa8 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs | |||
@@ -279,7 +279,12 @@ fn relative_file(db: &dyn AstDatabase, call_id: MacroCallId, path: &str) -> Opti | |||
279 | let call_site = call_id.as_file().original_file(db); | 279 | let call_site = call_id.as_file().original_file(db); |
280 | let path = RelativePath::new(&path); | 280 | let path = RelativePath::new(&path); |
281 | 281 | ||
282 | db.resolve_relative_path(call_site, &path) | 282 | let res = db.resolve_relative_path(call_site, &path)?; |
283 | // Prevent include itself | ||
284 | if res == call_site { | ||
285 | return None; | ||
286 | } | ||
287 | Some(res) | ||
283 | } | 288 | } |
284 | 289 | ||
285 | fn include_expand( | 290 | fn include_expand( |