Don't add --all-targets to runnables for no-std crates

This commit is contained in:
Lukas Wirth 2023-05-26 22:41:32 +02:00
parent 7c81fff520
commit bbd9e41606
6 changed files with 47 additions and 13 deletions

View file

@ -531,6 +531,11 @@ impl Analysis {
self.with_db(|db| db.crate_graph()[crate_id].edition)
}
/// Returns true if this crate has `no_std` or `no_core` specified.
pub fn is_crate_no_std(&self, crate_id: CrateId) -> Cancellable<bool> {
self.with_db(|db| hir::db::DefDatabase::crate_def_map(db, crate_id).is_no_std())
}
/// Returns the root file of the given crate.
pub fn crate_root(&self, crate_id: CrateId) -> Cancellable<FileId> {
self.with_db(|db| db.crate_graph()[crate_id].root_file_id)