diff options
author | Edwin Cheng <[email protected]> | 2020-04-27 21:11:24 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-04-27 21:11:24 +0100 |
commit | c69f9c1b0a849b2cf5349e707508358e42bc8bb5 (patch) | |
tree | cc62092d79a995bc84cf95b375defa9838ee2204 /crates/ra_hir_expand/src | |
parent | 6d3b0af900e6cefb507939b311672b7795703461 (diff) |
Check dep name to detect it is core
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r-- | crates/ra_hir_expand/src/builtin_derive.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index 3bd3f7041..e60f879a3 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs | |||
@@ -169,11 +169,13 @@ fn find_builtin_crate(db: &dyn AstDatabase, id: LazyMacroId) -> tt::TokenTree { | |||
169 | } | 169 | } |
170 | }; | 170 | }; |
171 | 171 | ||
172 | // Check whether it has any deps, if not, it should be core: | 172 | // XXX |
173 | let tt = if cg[*krate].dependencies.is_empty() { | 173 | // All crates except core itself should have a dependency on core, |
174 | quote! { crate } | 174 | // We detect `core` by seeing whether it doesn't have such a dependency. |
175 | } else { | 175 | let tt = if cg[*krate].dependencies.iter().any(|dep| dep.name == "core") { |
176 | quote! { core } | 176 | quote! { core } |
177 | } else { | ||
178 | quote! { crate } | ||
177 | }; | 179 | }; |
178 | 180 | ||
179 | tt.token_trees[0].clone() | 181 | tt.token_trees[0].clone() |