Skip to content

Commit c69f9c1

Browse files
committed
Check dep name to detect it is core
1 parent 6d3b0af commit c69f9c1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crates/ra_hir_expand/src/builtin_derive.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,13 @@ fn find_builtin_crate(db: &dyn AstDatabase, id: LazyMacroId) -> tt::TokenTree {
169169
}
170170
};
171171

172-
// Check whether it has any deps, if not, it should be core:
173-
let tt = if cg[*krate].dependencies.is_empty() {
174-
quote! { crate }
175-
} else {
172+
// XXX
173+
// All crates except core itself should have a dependency on core,
174+
// We detect `core` by seeing whether it doesn't have such a dependency.
175+
let tt = if cg[*krate].dependencies.iter().any(|dep| dep.name == "core") {
176176
quote! { core }
177+
} else {
178+
quote! { crate }
177179
};
178180

179181
tt.token_trees[0].clone()

0 commit comments

Comments
 (0)