fix: Correctly handle no_core/no_std for preludes

This commit is contained in:
Lukas Wirth 2024-05-02 09:53:42 +02:00
parent cfce2bb46d
commit a268eaf053
9 changed files with 120 additions and 71 deletions

View file

@ -324,21 +324,27 @@ pub struct Dependency {
pub crate_id: CrateId,
pub name: CrateName,
prelude: bool,
sysroot: bool,
}
impl Dependency {
pub fn new(name: CrateName, crate_id: CrateId) -> Self {
Self { name, crate_id, prelude: true }
Self { name, crate_id, prelude: true, sysroot: false }
}
pub fn with_prelude(name: CrateName, crate_id: CrateId, prelude: bool) -> Self {
Self { name, crate_id, prelude }
pub fn with_prelude(name: CrateName, crate_id: CrateId, prelude: bool, sysroot: bool) -> Self {
Self { name, crate_id, prelude, sysroot }
}
/// Whether this dependency is to be added to the depending crate's extern prelude.
pub fn is_prelude(&self) -> bool {
self.prelude
}
/// Whether this dependency is a sysroot injected one.
pub fn is_sysroot(&self) -> bool {
self.sysroot
}
}
impl CrateGraph {