mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Check dep name to detect it is core
This commit is contained in:
parent
6d3b0af900
commit
c69f9c1b0a
1 changed files with 6 additions and 4 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue