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
1 change: 0 additions & 1 deletion quest/m2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ The fork's feature quests folded into the [exporter](/quest/m1/ffi-export/README
## Required

- [Byte-slice locals that crash the translator](/quest/m2/ts-scalar-ice.md) - `take_apart` never reaches the arm `find_scalars` promised it wouldn't
- [Replacing an indexed element whose drop may panic](/quest/m2/ts-index-cleanup.md) - `v[i] = x` type-checks and unwinds as Rust does when the old element's drop may panic
- [Byte slices without objects](/quest/m2/ts-byte-views/README.md) - reading through a translated cursor allocates no object per read
- [Async in the TypeScript translator](/quest/m2/ts-async.md) - moq-net's and kio's async code translates with Rust's lazy futures
- [Shared ownership](/quest/m2/ts-shared.md) - `Arc`/`Rc`/`Weak` keep exact counts, and locks and atomics become plain values
Expand Down
28 changes: 0 additions & 28 deletions quest/m2/ts-index-cleanup.md

This file was deleted.

51 changes: 51 additions & 0 deletions ts/fixtures/task/expected/drops.Ring.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import { lend } from "./drops.ts";
import type * as Bomb from "./drops.Bomb.ts";

/** Slots in an array, replaced through a reference to one. */
export class Ring {
slots: Array<Bomb.Bomb | undefined>;

constructor(fields: { slots: Array<Bomb.Bomb | undefined> }) {
this.slots = fields.slots;
}

[Symbol.dispose](): void {
rt.dropAll(this.slots);
}
}

export function lent(self: Ring, index: rt.usize, bomb: Bomb.Bomb): void {
let _7!: Bomb.Bomb | undefined;
let _9!: boolean;
let unwind: number = 0;
try {
unwind = 8;
_9 = false;
_9 = true;
if (!(index < 2)) {
rt.panic("index out of bounds: the len is " + 2 + " but the index is " + index);
}
lend(rt.place(() => self.slots[index], (value) => self.slots[index] = value));
unwind = 5;
_9 = false;
_7 = bomb;
rt.drop(self.slots[index]);
self.slots[index] = _7;
} catch (e) {
if (unwind === 0) {
throw e;
}
if (unwind === 5) {
self.slots[index] = _7;
}
if (_9) {
rt.drop(bomb);
}
throw e;
}
}

//# sourceMappingURL=drops.Ring.ts.map
50 changes: 50 additions & 0 deletions ts/fixtures/task/expected/drops.Slots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import type * as Bomb from "./drops.Bomb.ts";

/** Slots that may hold a value, replaced in place. */
export class Slots {
_0: Array<Bomb.Bomb | undefined>;

constructor(_0: Array<Bomb.Bomb | undefined>) {
this._0 = _0;
}

[Symbol.dispose](): void {
rt.dropAll(this._0);
}
}

export function put(self: Slots, index: rt.usize, bomb: Bomb.Bomb): void {
let at!: number;
let _4!: Bomb.Bomb | undefined;
let _7!: boolean;
let unwind: number = 0;
try {
unwind = 7;
_7 = false;
_7 = true;
_4 = bomb;
at = rt.idx(self._0, index);
unwind = 4;
rt.drop(self._0[at]);
_7 = false;
self._0[at] = _4;
_7 = false;
} catch (e) {
if (unwind === 0) {
throw e;
}
if (unwind === 4) {
_7 = false;
self._0[at] = _4;
}
if (_7) {
rt.drop(_4);
}
throw e;
}
}

//# sourceMappingURL=drops.Slots.ts.map
Loading