diff --git a/ts/fixtures/lang/dyns/expected/ids.ts b/ts/fixtures/lang/dyns/expected/ids.ts index c637605f5..5a0e3cee5 100644 --- a/ts/fixtures/lang/dyns/expected/ids.ts +++ b/ts/fixtures/lang/dyns/expected/ids.ts @@ -27,32 +27,32 @@ export function capped(id: rs.TypeId, cap: rs.usize): [rs.Result"; } /** `T`'s `TypeId`, through a type parameter. */ export function idOf$u8(): rs.TypeId { - return "cfb1622e7734f8af272d8d182905dc25"; + return ""; } /** The `TypeId` of what `x` is, through a type parameter that may be a trait object. */ export function idOfVal$dyn_Any(_1: Any.Any): rs.TypeId { - return "f48384178e2341267f2bcf8f82c035ac"; + return ""; } /** The `TypeId` of what `x` is, through a type parameter that may be a trait object. */ export function idOfVal$dyn_ids_Marked(_1: Marked.Marked): rs.TypeId { - return "d356aeac368968f265dedab8a8d72ad8"; + return ""; } /** The `TypeId` of what `x` is, through a type parameter that may be a trait object. */ export function idOfVal$ids_Mood(_1: Mood.Mood): rs.TypeId { - return "328e59b82c6cb0a6eb720af972265604"; + return ""; } /** The `TypeId` of what `x` is, through a type parameter that may be a trait object. */ export function idOfVal$str(_1: string): rs.TypeId { - return "b7381ee5f3fdfc9d7fa709f37e151622"; + return ""; } /** The 128-bit hash `Debug` writes, if it writes `TypeId(0x…)` of 32 hex digits. */ @@ -116,8 +116,8 @@ export function ids(dataData: Uint8Array, dataStart: number, dataLen: number, ou mood = "Calm" as Mood.Mood; } const byte: Byte.Byte = { _0: b }; - const ids: rs.TypeId[] = ["cfb1622e7734f8af272d8d182905dc25", "79f19461b401588885a89e43144b08f1", "8f5d7517f5a241dab4213252fd0d53e8", "328e59b82c6cb0a6eb720af972265604", "24c161f26c70c1f1b9f602dc5fe9f65c", "b7381ee5f3fdfc9d7fa709f37e151622", "05fc01408e45e7cddf9e041e3391eafc", "3801bd64778907c7633cf473fe556a70", "513ce68a38c017b0c2e73410455cb3b0", "f48384178e2341267f2bcf8f82c035ac", "37a732caafaf8e089d3a9d4c07b2ec78", "d356aeac368968f265dedab8a8d72ad8", "25ff997ce0b3a76fb5ce30b55accc57f"]; - const found: rs.TypeId[] = [idOf$u8(), "cfb1622e7734f8af272d8d182905dc25", "cfb1622e7734f8af272d8d182905dc25", "8f5d7517f5a241dab4213252fd0d53e8", "cfb1622e7734f8af272d8d182905dc25", "79f19461b401588885a89e43144b08f1", "8f5d7517f5a241dab4213252fd0d53e8", idOfVal$str("str"), idOfVal$ids_Mood(mood), idOfVal$dyn_Any(new of$u8(a)), idOf$Option_u8()]; + const ids: rs.TypeId[] = ["", "", "", "", "", "", "", "", "", "", "", "", ""]; + const found: rs.TypeId[] = [idOf$u8(), "", "", "", "", "", "", idOfVal$str("str"), idOfVal$ids_Mood(mood), idOfVal$dyn_Any(new of$u8(a)), idOf$Option_u8()]; const iter: rs.Iter = rs.iterSlice(found); while (true) { const _53: rs.TypeId | rs.Done = iter.next(); @@ -131,7 +131,7 @@ export function ids(dataData: Uint8Array, dataStart: number, dataLen: number, ou put(out, rs.fmtFormat([(f: rs.Formatter) => rs.fmtOption(part, f, rs.usizeDebug), " "]).v); } const part2 = rs.iterPosition(rs.iterSlice(ids), (i2: rs.TypeId): boolean => { - return i2 === "cfb1622e7734f8af272d8d182905dc25"; + return i2 === ""; }); put(out, rs.fmtFormat([(f: rs.Formatter) => rs.fmtOption(part2, f, rs.usizeDebug), " "]).v); const iter2: rs.Iter = rs.iterSlice([new of$u8(a), new of$u32(n), new of$ids_Byte(byte), new of$ids_Mood(mood), new of$ref_str("str")]); @@ -168,7 +168,7 @@ export function ids(dataData: Uint8Array, dataStart: number, dataLen: number, ou return i5 === _165.typeId$Any(); }); const _187: boolean = _165.typeId$Any() === any.typeId$Any(); - const _193: boolean = idOfVal$dyn_ids_Marked(_165) === "d356aeac368968f265dedab8a8d72ad8"; + const _193: boolean = idOfVal$dyn_ids_Marked(_165) === ""; const args43 = [(f: rs.Formatter) => rs.u8Display(_178, f), (f: rs.Formatter) => rs.fmtOption(_180, f, rs.usizeDebug), (f: rs.Formatter) => rs.fmtBool(_187, f), (f: rs.Formatter) => rs.fmtBool(_193, f)]; put(out, rs.fmtFormat([args43[0], " ", args43[1], " ", args43[2], " ", args43[3], " "]).v); } @@ -189,16 +189,16 @@ export function ids(dataData: Uint8Array, dataStart: number, dataLen: number, ou const _240: rs.usize | undefined = rs.iterPosition(rs.iterSlice(ids), (i6: rs.TypeId): boolean => { return i6 === inner; }); - const _248: boolean = "37a732caafaf8e089d3a9d4c07b2ec78" === "37a732caafaf8e089d3a9d4c07b2ec78"; + const _248: boolean = "" === ""; const args44 = [(f: rs.Formatter) => rs.fmtOption(_240, f, rs.usizeDebug), (f: rs.Formatter) => rs.fmtBool(_248, f)]; put(out, rs.fmtFormat([args44[0], " ", args44[1], " "]).v); } const _259: rs.Arc = new rs.Arc(byte); const shared: rs.Arc = new rs.ArcDyn(_259, new of$ids_Byte(_259.value)); const boxed: Marked.Marked = new of$u8(a); - const _270: boolean = shared.value.typeId$Any() === "8f5d7517f5a241dab4213252fd0d53e8"; - const _278: boolean = "6864f1ad0ca168ae5e502d6898f6f9c3" === "6864f1ad0ca168ae5e502d6898f6f9c3"; - const _285: boolean = boxed.typeId$Any() === "cfb1622e7734f8af272d8d182905dc25"; + const _270: boolean = shared.value.typeId$Any() === ""; + const _278: boolean = "" === ""; + const _285: boolean = boxed.typeId$Any() === ""; const args45 = [(f: rs.Formatter) => rs.fmtBool(_270, f), (f: rs.Formatter) => rs.fmtBool(_278, f), (f: rs.Formatter) => rs.fmtBool(_285, f)]; put(out, rs.fmtFormat([args45[0], " ", args45[1], " ", args45[2], " "]).v); const _298: rs.Slice = rs.sliceFrom(ids); @@ -349,7 +349,7 @@ export function ids(dataData: Uint8Array, dataStart: number, dataLen: number, ou const _580: rs.usize = rs.hashLen(hashed); const args57 = [(f: rs.Formatter) => rs.fmtBool(ordered, f), (f: rs.Formatter) => rs.usizeDisplay(_577, f), (f: rs.Formatter) => rs.usizeDisplay(_580, f)]; put(out, rs.fmtFormat([args57[0], " ", args57[1], " ", args57[2], " "]).v); - const _590: rs.Iter<[rs.TypeId, string]> = rs.iterSlice([["cfb1622e7734f8af272d8d182905dc25", "u8"] as [rs.TypeId, string], ["8f5d7517f5a241dab4213252fd0d53e8", "byte"] as [rs.TypeId, string], ["328e59b82c6cb0a6eb720af972265604", "mood"] as [rs.TypeId, string]]); + const _590: rs.Iter<[rs.TypeId, string]> = rs.iterSlice([["", "u8"] as [rs.TypeId, string], ["", "byte"] as [rs.TypeId, string], ["", "mood"] as [rs.TypeId, string]]); const names: rs.HashMap = rs.hashExtend(rs.hashNew(rs.hashing(rs.typeIdHash, rs.same)) as rs.HashMap, _590, undefined, undefined, undefined, 58720256); for (const _603 of boxes.items) { const part8 = rs.hashGet(names, _603.typeId$Any()); diff --git a/ts/fixtures/lang/dyns/expected/lib.ts b/ts/fixtures/lang/dyns/expected/lib.ts index 28cc47b27..960fd3f8c 100644 --- a/ts/fixtures/lang/dyns/expected/lib.ts +++ b/ts/fixtures/lang/dyns/expected/lib.ts @@ -337,7 +337,7 @@ export class of$Option_u8 { } typeId$Any(): rs.TypeId { - return "3801bd64778907c7633cf473fe556a70"; + return ""; } } @@ -583,7 +583,7 @@ export class of$dyns_Noisy { } typeId$Any(): rs.TypeId { - return "8abb48f5c9ad521e17c8b05ce0f1d679"; + return ""; } } @@ -659,7 +659,7 @@ export class of$dyns_Square { } typeId$Any(): rs.TypeId { - return "0ba6291209e997830eaef6cade61afd2"; + return ""; } } @@ -751,7 +751,7 @@ export class of$dyns_Tri { } typeId$Any(): rs.TypeId { - return "66772eb3554749a10355c03efd41f5ad"; + return ""; } } @@ -859,7 +859,7 @@ export class of$ids_Byte { } typeId$Any(): rs.TypeId { - return "8f5d7517f5a241dab4213252fd0d53e8"; + return ""; } } @@ -871,7 +871,7 @@ export class of$ids_Mood { } typeId$Any(): rs.TypeId { - return "328e59b82c6cb0a6eb720af972265604"; + return ""; } } @@ -887,7 +887,7 @@ export class of$ref_str { } typeId$Any(): rs.TypeId { - return "24c161f26c70c1f1b9f602dc5fe9f65c"; + return ""; } } @@ -1129,7 +1129,7 @@ export class of$tuple2_u8_u8 { } typeId$Any(): rs.TypeId { - return "7d311253455a5117c9570c9455e07dcc"; + return ""; } } @@ -1205,7 +1205,7 @@ export class of$u32 { } typeId$Any(): rs.TypeId { - return "79f19461b401588885a89e43144b08f1"; + return ""; } } @@ -1237,7 +1237,7 @@ export class of$u8 { } typeId$Any(): rs.TypeId { - return "cfb1622e7734f8af272d8d182905dc25"; + return ""; } } @@ -1249,7 +1249,7 @@ export class of$unit { } typeId$Any(): rs.TypeId { - return "05fc01408e45e7cddf9e041e3391eafc"; + return ""; } } @@ -1261,7 +1261,7 @@ export class ofPlace$Option_u8 { } typeId$Any(): rs.TypeId { - return "3801bd64778907c7633cf473fe556a70"; + return ""; } } @@ -1341,7 +1341,7 @@ export class ofPlace$dyns_Tri { } typeId$Any(): rs.TypeId { - return "66772eb3554749a10355c03efd41f5ad"; + return ""; } } @@ -1353,7 +1353,7 @@ export class ofPlace$ids_Mood { } typeId$Any(): rs.TypeId { - return "328e59b82c6cb0a6eb720af972265604"; + return ""; } } @@ -1423,7 +1423,7 @@ export class ofPlace$u32 { } typeId$Any(): rs.TypeId { - return "79f19461b401588885a89e43144b08f1"; + return ""; } } @@ -1443,7 +1443,7 @@ export class ofPlace$u8 { } typeId$Any(): rs.TypeId { - return "cfb1622e7734f8af272d8d182905dc25"; + return ""; } } @@ -1455,7 +1455,7 @@ export class ofPlace$unit { } typeId$Any(): rs.TypeId { - return "05fc01408e45e7cddf9e041e3391eafc"; + return ""; } } diff --git a/ts/fixtures/lang/panics/hook/expected/hooked.ts b/ts/fixtures/lang/panics/hook/expected/hooked.ts index 8a2f337d4..c9e2b714f 100644 --- a/ts/fixtures/lang/panics/hook/expected/hooked.ts +++ b/ts/fixtures/lang/panics/hook/expected/hooked.ts @@ -20,7 +20,7 @@ import { withBorrow$097wfl1 } from "./std/thread/local.ts"; export function record(info: rs.PanicHookInfo): void { let kind!: rs.String; const payload: Any.Any = rs.hookPayload(info, of$ref_str, of$String); - if (!(payload.typeId$Any() === "24c161f26c70c1f1b9f602dc5fe9f65c")) { + if (!(payload.typeId$Any() === "")) { if (!(payload instanceof of$String)) { const _12: rs.u32 | undefined = payload instanceof of$u32 ? payload.v : payload instanceof ofPlace$u32 ? payload.v.v : undefined; if (_12 !== undefined) { diff --git a/ts/fixtures/lang/panics/hook/expected/lib.ts b/ts/fixtures/lang/panics/hook/expected/lib.ts index b72d52964..e5622da04 100644 --- a/ts/fixtures/lang/panics/hook/expected/lib.ts +++ b/ts/fixtures/lang/panics/hook/expected/lib.ts @@ -41,7 +41,7 @@ export class of$String { } typeId$Any(): rs.TypeId { - return "1430db79e63c4bb92bf94c26df7c977d"; + return ""; } } @@ -81,7 +81,7 @@ export class of$panics_Point { } typeId$Any(): rs.TypeId { - return "8e48006f0a085ab0ca68bcd6079f396f"; + return ""; } } @@ -93,7 +93,7 @@ export class of$ref_str { } typeId$Any(): rs.TypeId { - return "24c161f26c70c1f1b9f602dc5fe9f65c"; + return ""; } } @@ -105,7 +105,7 @@ export class of$u32 { } typeId$Any(): rs.TypeId { - return "79f19461b401588885a89e43144b08f1"; + return ""; } } @@ -121,7 +121,7 @@ export class of$u8 { } typeId$Any(): rs.TypeId { - return "cfb1622e7734f8af272d8d182905dc25"; + return ""; } via$Tracked(): rs.Location { @@ -137,7 +137,7 @@ export class ofPlace$u32 { } typeId$Any(): rs.TypeId { - return "79f19461b401588885a89e43144b08f1"; + return ""; } } @@ -149,7 +149,7 @@ export class ofPlace$u8 { } typeId$Any(): rs.TypeId { - return "cfb1622e7734f8af272d8d182905dc25"; + return ""; } } diff --git a/ts/tests/fixtures.rs b/ts/tests/fixtures.rs index 0680ceeeb..392870e4f 100644 --- a/ts/tests/fixtures.rs +++ b/ts/tests/fixtures.rs @@ -114,7 +114,10 @@ fn sources(dir: &Path) -> Vec<(PathBuf, String)> { /// Compare the output with the fixture's `expected/` directory. fn snapshot(name: &str, out: &Path) { let expected = fixture(name).join("expected"); - let got = sources(out); + let got: Vec<_> = sources(out) + .into_iter() + .map(|(rel, text)| (rel, mask_type_ids(&text))) + .collect(); if std::env::var_os("UPDATE_EXPECT").is_some() { let _ = std::fs::remove_dir_all(&expected); for (rel, text) in &got { @@ -141,6 +144,34 @@ fn snapshot(name: &str, out: &Path) { } } +/// `text` with each `TypeId`, a string literal of 32 hex digits, named by its first +/// appearance: cargo hashes the host's profile into a crate's `-C metadata`, and so into +/// the hash of every type it defines, which leaves only which ids are equal alike on +/// every host. +fn mask_type_ids(text: &str) -> String { + let mut seen: Vec<&str> = Vec::new(); + let mut out = String::with_capacity(text.len()); + let mut rest = text; + while let Some(at) = rest.find('"') { + out.push_str(&rest[..=at]); + rest = &rest[at + 1..]; + let hash = rest + .get(..32) + .filter(|hash| hash.bytes().all(|b| matches!(b, b'0'..=b'9' | b'a'..=b'f'))) + .filter(|_| rest[32..].starts_with('"')); + if let Some(hash) = hash { + let n = seen.iter().position(|seen| *seen == hash).unwrap_or_else(|| { + seen.push(hash); + seen.len() - 1 + }); + out.push_str(&format!("\"", n + 1)); + rest = &rest[33..]; + } + } + out.push_str(rest); + out +} + /// The first lines where two texts differ. fn diff(want: &str, got: &str) -> String { let (want, got): (Vec<&str>, Vec<&str>) = (want.lines().collect(), got.lines().collect());