Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions ts/fixtures/lang/dyns/expected/ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,32 @@ export function capped(id: rs.TypeId, cap: rs.usize): [rs.Result<undefined, rs.F

/** `T`'s `TypeId`, through a type parameter. */
export function idOf$Option_u8(): rs.TypeId {
return "3801bd64778907c7633cf473fe556a70";
return "<TypeId 1>";
}

/** `T`'s `TypeId`, through a type parameter. */
export function idOf$u8(): rs.TypeId {
return "cfb1622e7734f8af272d8d182905dc25";
return "<TypeId 2>";
}

/** 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 "<TypeId 3>";
}

/** 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 "<TypeId 4>";
}

/** 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 "<TypeId 5>";
}

/** 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 "<TypeId 6>";
}

/** The 128-bit hash `Debug` writes, if it writes `TypeId(0x…)` of 32 hex digits. */
Expand Down Expand Up @@ -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[] = ["<TypeId 2>", "<TypeId 7>", "<TypeId 8>", "<TypeId 5>", "<TypeId 9>", "<TypeId 6>", "<TypeId 10>", "<TypeId 1>", "<TypeId 11>", "<TypeId 3>", "<TypeId 12>", "<TypeId 4>", "<TypeId 13>"];
const found: rs.TypeId[] = [idOf$u8(), "<TypeId 2>", "<TypeId 2>", "<TypeId 8>", "<TypeId 2>", "<TypeId 7>", "<TypeId 8>", idOfVal$str("str"), idOfVal$ids_Mood(mood), idOfVal$dyn_Any(new of$u8(a)), idOf$Option_u8()];
const iter: rs.Iter<rs.TypeId> = rs.iterSlice(found);
while (true) {
const _53: rs.TypeId | rs.Done = iter.next();
Expand All @@ -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 === "<TypeId 2>";
});
put(out, rs.fmtFormat([(f: rs.Formatter) => rs.fmtOption(part2, f, rs.usizeDebug), " "]).v);
const iter2: rs.Iter<Any.Any> = 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")]);
Expand Down Expand Up @@ -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) === "<TypeId 4>";
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);
}
Expand All @@ -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 = "<TypeId 12>" === "<TypeId 12>";
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<Byte.Byte> = new rs.Arc(byte);
const shared: rs.Arc<Any.Any> = 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() === "<TypeId 8>";
const _278: boolean = "<TypeId 14>" === "<TypeId 14>";
const _285: boolean = boxed.typeId$Any() === "<TypeId 2>";
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.TypeId> = rs.sliceFrom(ids);
Expand Down Expand Up @@ -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([["<TypeId 2>", "u8"] as [rs.TypeId, string], ["<TypeId 8>", "byte"] as [rs.TypeId, string], ["<TypeId 5>", "mood"] as [rs.TypeId, string]]);
const names: rs.HashMap<rs.TypeId, string> = rs.hashExtend(rs.hashNew(rs.hashing(rs.typeIdHash, rs.same)) as rs.HashMap<rs.TypeId, string>, _590, undefined, undefined, undefined, 58720256);
for (const _603 of boxes.items) {
const part8 = rs.hashGet(names, _603.typeId$Any());
Expand Down
34 changes: 17 additions & 17 deletions ts/fixtures/lang/dyns/expected/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export class of$Option_u8 {
}

typeId$Any(): rs.TypeId {
return "3801bd64778907c7633cf473fe556a70";
return "<TypeId 1>";
}
}

Expand Down Expand Up @@ -583,7 +583,7 @@ export class of$dyns_Noisy {
}

typeId$Any(): rs.TypeId {
return "8abb48f5c9ad521e17c8b05ce0f1d679";
return "<TypeId 2>";
}
}

Expand Down Expand Up @@ -659,7 +659,7 @@ export class of$dyns_Square {
}

typeId$Any(): rs.TypeId {
return "0ba6291209e997830eaef6cade61afd2";
return "<TypeId 3>";
}
}

Expand Down Expand Up @@ -751,7 +751,7 @@ export class of$dyns_Tri {
}

typeId$Any(): rs.TypeId {
return "66772eb3554749a10355c03efd41f5ad";
return "<TypeId 4>";
}
}

Expand Down Expand Up @@ -859,7 +859,7 @@ export class of$ids_Byte {
}

typeId$Any(): rs.TypeId {
return "8f5d7517f5a241dab4213252fd0d53e8";
return "<TypeId 5>";
}
}

Expand All @@ -871,7 +871,7 @@ export class of$ids_Mood {
}

typeId$Any(): rs.TypeId {
return "328e59b82c6cb0a6eb720af972265604";
return "<TypeId 6>";
}
}

Expand All @@ -887,7 +887,7 @@ export class of$ref_str {
}

typeId$Any(): rs.TypeId {
return "24c161f26c70c1f1b9f602dc5fe9f65c";
return "<TypeId 7>";
}
}

Expand Down Expand Up @@ -1129,7 +1129,7 @@ export class of$tuple2_u8_u8 {
}

typeId$Any(): rs.TypeId {
return "7d311253455a5117c9570c9455e07dcc";
return "<TypeId 8>";
}
}

Expand Down Expand Up @@ -1205,7 +1205,7 @@ export class of$u32 {
}

typeId$Any(): rs.TypeId {
return "79f19461b401588885a89e43144b08f1";
return "<TypeId 9>";
}
}

Expand Down Expand Up @@ -1237,7 +1237,7 @@ export class of$u8 {
}

typeId$Any(): rs.TypeId {
return "cfb1622e7734f8af272d8d182905dc25";
return "<TypeId 10>";
}
}

Expand All @@ -1249,7 +1249,7 @@ export class of$unit {
}

typeId$Any(): rs.TypeId {
return "05fc01408e45e7cddf9e041e3391eafc";
return "<TypeId 11>";
}
}

Expand All @@ -1261,7 +1261,7 @@ export class ofPlace$Option_u8 {
}

typeId$Any(): rs.TypeId {
return "3801bd64778907c7633cf473fe556a70";
return "<TypeId 1>";
}
}

Expand Down Expand Up @@ -1341,7 +1341,7 @@ export class ofPlace$dyns_Tri {
}

typeId$Any(): rs.TypeId {
return "66772eb3554749a10355c03efd41f5ad";
return "<TypeId 4>";
}
}

Expand All @@ -1353,7 +1353,7 @@ export class ofPlace$ids_Mood {
}

typeId$Any(): rs.TypeId {
return "328e59b82c6cb0a6eb720af972265604";
return "<TypeId 6>";
}
}

Expand Down Expand Up @@ -1423,7 +1423,7 @@ export class ofPlace$u32 {
}

typeId$Any(): rs.TypeId {
return "79f19461b401588885a89e43144b08f1";
return "<TypeId 9>";
}
}

Expand All @@ -1443,7 +1443,7 @@ export class ofPlace$u8 {
}

typeId$Any(): rs.TypeId {
return "cfb1622e7734f8af272d8d182905dc25";
return "<TypeId 10>";
}
}

Expand All @@ -1455,7 +1455,7 @@ export class ofPlace$unit {
}

typeId$Any(): rs.TypeId {
return "05fc01408e45e7cddf9e041e3391eafc";
return "<TypeId 11>";
}
}

Expand Down
2 changes: 1 addition & 1 deletion ts/fixtures/lang/panics/hook/expected/hooked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() === "<TypeId 1>")) {
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) {
Expand Down
14 changes: 7 additions & 7 deletions ts/fixtures/lang/panics/hook/expected/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class of$String {
}

typeId$Any(): rs.TypeId {
return "1430db79e63c4bb92bf94c26df7c977d";
return "<TypeId 1>";
}
}

Expand Down Expand Up @@ -81,7 +81,7 @@ export class of$panics_Point {
}

typeId$Any(): rs.TypeId {
return "8e48006f0a085ab0ca68bcd6079f396f";
return "<TypeId 2>";
}
}

Expand All @@ -93,7 +93,7 @@ export class of$ref_str {
}

typeId$Any(): rs.TypeId {
return "24c161f26c70c1f1b9f602dc5fe9f65c";
return "<TypeId 3>";
}
}

Expand All @@ -105,7 +105,7 @@ export class of$u32 {
}

typeId$Any(): rs.TypeId {
return "79f19461b401588885a89e43144b08f1";
return "<TypeId 4>";
}
}

Expand All @@ -121,7 +121,7 @@ export class of$u8 {
}

typeId$Any(): rs.TypeId {
return "cfb1622e7734f8af272d8d182905dc25";
return "<TypeId 5>";
}

via$Tracked(): rs.Location {
Expand All @@ -137,7 +137,7 @@ export class ofPlace$u32 {
}

typeId$Any(): rs.TypeId {
return "79f19461b401588885a89e43144b08f1";
return "<TypeId 4>";
}
}

Expand All @@ -149,7 +149,7 @@ export class ofPlace$u8 {
}

typeId$Any(): rs.TypeId {
return "cfb1622e7734f8af272d8d182905dc25";
return "<TypeId 5>";
}
}

Expand Down
33 changes: 32 additions & 1 deletion ts/tests/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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!("<TypeId {}>\"", 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());
Expand Down