fix(users/edef/weave): use safer_owning_ref

owning_ref has serious unsoundness.

Change-Id: Ie760697cd6399e6bc75f1ad17c9bb74adc077a35
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12656
Reviewed-by: edef <edef@edef.eu>
Tested-by: BuildkiteCI
Autosubmit: edef <edef@edef.eu>
Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
edef 2024-10-17 22:37:05 +00:00 committed by clbot
parent 211cf7ba7c
commit dfff592784
4 changed files with 35 additions and 33 deletions

View file

@ -1021,15 +1021,6 @@ version = "1.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
[[package]]
name = "owning_ref"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce"
dependencies = [
"stable_deref_trait",
]
[[package]]
name = "parking_lot"
version = "0.12.3"
@ -1586,6 +1577,15 @@ version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
[[package]]
name = "safer_owning_ref"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af21b9de2df966f61c07b5b541c81c98225b86e48ababd43366a642654de30ef"
dependencies = [
"stable_deref_trait",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
@ -2036,9 +2036,9 @@ dependencies = [
"anyhow",
"hashbrown 0.14.5",
"nix-compat",
"owning_ref",
"polars",
"rayon",
"safer_owning_ref",
"tokio",
]

View file

@ -3004,22 +3004,6 @@ rec {
};
resolvedDefaultFeatures = [ "alloc" "default" "race" "std" ];
};
"owning_ref" = rec {
crateName = "owning_ref";
version = "0.4.1";
edition = "2015";
sha256 = "1kjj9m28wjv452jw49p1mp3d8ql058x78v4bz00avr7rvsnmpxbg";
authors = [
"Marvin Löbel <loebel.marvin@gmail.com>"
];
dependencies = [
{
name = "stable_deref_trait";
packageId = "stable_deref_trait";
}
];
};
"parking_lot" = rec {
crateName = "parking_lot";
version = "0.12.3";
@ -5499,6 +5483,24 @@ rec {
"no-panic" = [ "dep:no-panic" ];
};
};
"safer_owning_ref" = rec {
crateName = "safer_owning_ref";
version = "0.5.0";
edition = "2015";
sha256 = "1vrhvra2cr3a6r1vvflawj35n8lq3k443ddm0wfgcrpr5pgbj8dg";
libName = "owning_ref";
authors = [
"Marvin Löbel <loebel.marvin@gmail.com>"
"Noam Ta Shma noam.tashma@gmail.com"
];
dependencies = [
{
name = "stable_deref_trait";
packageId = "stable_deref_trait";
}
];
};
"scopeguard" = rec {
crateName = "scopeguard";
version = "1.2.0";
@ -6784,10 +6786,6 @@ rec {
name = "nix-compat";
packageId = "nix-compat";
}
{
name = "owning_ref";
packageId = "owning_ref";
}
{
name = "polars";
packageId = "polars";
@ -6797,6 +6795,10 @@ rec {
name = "rayon";
packageId = "rayon";
}
{
name = "safer_owning_ref";
packageId = "safer_owning_ref";
}
{
name = "tokio";
packageId = "tokio";

View file

@ -11,7 +11,7 @@ members = ["."]
anyhow = { version = "1.0.79", features = ["backtrace"] }
hashbrown = "0.14.3"
nix-compat = { version = "0.1.0", path = "../../../tvix/nix-compat" }
owning_ref = "0.4.1"
safer_owning_ref = "0.5.0"
rayon = "1.8.1"
tokio = { version = "1.36.0", features = ["full"] }

View file

@ -3,7 +3,7 @@ use polars::export::arrow::buffer::Buffer;
use std::ops::Deref;
/// An shared `[[u8; N]]` backed by a Polars [Buffer].
pub type FixedBytes<const N: usize> = OwningRef<Bytes, [[u8; N]]>;
pub type FixedBytes<const N: usize> = OwningRef<'static, Bytes, [[u8; N]]>;
/// Wrapper struct to make [Buffer] implement [StableAddress].
/// TODO(edef): upstream the `impl`
@ -13,7 +13,7 @@ pub struct Bytes(pub Buffer<u8>);
unsafe impl StableAddress for Bytes {}
impl Bytes {
pub fn map<U: ?Sized>(self, f: impl FnOnce(&[u8]) -> &U) -> OwningRef<Self, U> {
pub fn map<U: ?Sized>(self, f: impl FnOnce(&[u8]) -> &U) -> OwningRef<'static, Self, U> {
OwningRef::new(self).map(f)
}
}