From c69f9c1b0a849b2cf5349e707508358e42bc8bb5 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 28 Apr 2020 04:11:24 +0800 Subject: Check dep name to detect it is core --- crates/ra_hir_expand/src/builtin_derive.rs | 10 ++++++---- 1 file 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 { } }; - // Check whether it has any deps, if not, it should be core: - let tt = if cg[*krate].dependencies.is_empty() { - quote! { crate } - } else { + // XXX + // All crates except core itself should have a dependency on core, + // We detect `core` by seeing whether it doesn't have such a dependency. + let tt = if cg[*krate].dependencies.iter().any(|dep| dep.name == "core") { quote! { core } + } else { + quote! { crate } }; tt.token_trees[0].clone() -- cgit v1.2.3