Skip to content

Commit

Permalink
Enforce only upper bound on Dist size
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Jan 18, 2024
1 parent df9a394 commit aa23243
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ seahash = { version = "4.1.0" }
serde = { version = "1.0.194" }
serde_json = { version = "1.0.111" }
sha2 = { version = "0.10.8" }
static_assertions = { version = "1.1.0" }
tar = { version = "0.4.40" }
target-lexicon = { version = "0.12.13" }
tempfile = { version = "3.9.0" }
Expand Down
1 change: 0 additions & 1 deletion crates/distribution-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ rustc-hash = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
sha2 = { workspace = true }
static_assertions = { workspace = true }
thiserror = { workspace = true }
url = { workspace = true }
18 changes: 13 additions & 5 deletions crates/distribution-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;

use anyhow::Result;
use static_assertions::assert_eq_size;
use url::Url;

use distribution_filename::{DistFilename, SourceDistFilename, WheelFilename};
Expand Down Expand Up @@ -202,10 +201,6 @@ pub struct PathSourceDist {
pub editable: bool,
}

assert_eq_size!(Dist, [u8; 240]);
assert_eq_size!(BuiltDist, [u8; 240]);
assert_eq_size!(SourceDist, [u8; 168]);

impl Dist {
/// Create a [`Dist`] for a registry-based distribution.
pub fn from_registry(filename: DistFilename, file: File, index: IndexUrl) -> Self {
Expand Down Expand Up @@ -870,3 +865,16 @@ impl Identifier for Dist {
}
}
}

#[cfg(test)]
mod test {
use crate::{BuiltDist, Dist, SourceDist};

/// Ensure that we don't accidentally grow the `Dist` sizes.
#[test]
fn dist_size() {
assert!(std::mem::size_of::<Dist>() <= 240);
assert!(std::mem::size_of::<BuiltDist>() <= 240);
assert!(std::mem::size_of::<SourceDist>() <= 168);
}
}

0 comments on commit aa23243

Please sign in to comment.