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/m3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ generic std gap is planned here even when moq never calls it.
- [Placeholders written to a crate's own fmt::Write](/quest/m3/ts-fmt-calls.md) - `write!` with placeholders into a crate's own writer translates, its `write_str` seeing each call std makes
- [Waiting: drop the lang fixture's mul_add allowance](/quest/m3/ts-fma-allowance.md) - the differential fails on any `mul_add` difference again once wasm32's `fma` rounds exactly
- [Waiting: type-check in process with tsrs](/quest/m3/ts-tsrs.md) - rust2-ts checks bindings through tsrs instead of `tsc` once it is a stable library
- [Drop order in std's folds and iterators](/quest/m3/ts-drop-order.md) - the values that drop still refused in std's consumers and collects drop as std's do
- [A slice of one value behind any &mut](/quest/m3/ts-slice-of-one.md) - `slice::from_mut` and `array::from_mut` of a `&mut u8`, or of an object no place names, translate
- [A function pointer or a boxed closure as a string pattern](/quest/m3/ts-fn-patterns.md) - `s.split(p)` of a `fn(char) -> bool` or a `Box<dyn FnMut(char) -> bool>` translates, dropping a box it owns where std does
- [std's char methods that have no mapping](/quest/m3/ts-char-methods.md) - `is_alphabetic`, `to_lowercase`, `len_utf8`, the escapes, and the rest of `char` translate, called or as values, by std's Unicode version
Expand Down
35 changes: 0 additions & 35 deletions quest/m3/ts-drop-order.md

This file was deleted.

3 changes: 3 additions & 0 deletions ts/MIGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
- `rt.iterReduce`, `rt.iterMaxBy`, `rt.iterMinBy`, `rt.iterMaxByKey`, and
`rt.iterMinByKey` take whether they own their closure, which they drop where std's do,
before the `rt.None` they take last, as in `rt.iterReduce(it, f, drops, owns, none)`.
- `rt.iterMaxByKey` and `rt.iterMinByKey` take what drops each key after whether they own
their function, before the `rt.None` they take last, as in
`rt.iterMaxByKey(it, f, lt, drops, drop, owns, dropKey, none)`.
- `rt.Hasher` has `Hasher`'s methods, `write`, `u8` to `isize`, `prefix`
(`write_length_prefix`), and `str`, and `ints`, an integer slice's `hash_slice`, in
place of `word`. A binding's `hash$Hash` writes a signed or pointer-sized integer
Expand Down
3 changes: 1 addition & 2 deletions ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,7 @@ hand-written TS ([bindings](#bindings)).

These fail translation: `f16` and `f128`, a `Poll` of a `Poll` of a `Poll`, a future whose output can be pending, an instance of a generic type whose field is a `Poll` of a type parameter that can be pending, a closure that owns a value
that drops given to a std function that keeps it other than in an iterator or a
`poll_fn`, or whose mapping doesn't drop it where std's does, and values that drop in some
iterators ([drop order](/quest/m3/ts-drop-order.md)), a `Cow` of other than `str` or a slice, a std
`poll_fn`, or whose mapping doesn't drop it where std's does, a `Cow` of other than `str` or a slice, a std
function without a mapping of its own that makes or reads an `Option` whose `None` is
`rt.None`, an `Option` of an `Option` of `()` or another
`Option`, an instance of a generic type whose field is an `Option` of a type parameter
Expand Down
8 changes: 4 additions & 4 deletions ts/fixtures/lang/nested/expected/nested.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,22 @@ export function consumers(data: rt.ByteSlice, out: rt.ByteVec): void {
return option_map$0cs071d(o2, (b4: rt.u8): rt.u8 => {
return rt.u8Rem(b4, 4);
});
}, rt.cmpLt(rt.cmpOption(rt.cmp)), undefined, undefined, undefined, rt.None)));
}, rt.cmpLt(rt.cmpOption(rt.cmp)), undefined, undefined, undefined, undefined, rt.None)));
rt.byteVecPush(out, code(rt.iterMinByKey(it(), (o3: rt.u8 | undefined): rt.u8 | undefined => {
return option_map$0cs071d(o3, (b5: rt.u8): rt.u8 => {
return rt.u8Rem(b5, 4);
});
}, rt.cmpLt(rt.cmpOption(rt.cmp)), undefined, undefined, undefined, rt.None)));
}, rt.cmpLt(rt.cmpOption(rt.cmp)), undefined, undefined, undefined, undefined, rt.None)));
rt.byteVecPush(out, code(rt.iterMaxByKey(it(), (o4: rt.u8 | undefined): rt.u8 | undefined | rt.None => {
return option_map$0rbsrz6(o4, (b6: rt.u8): rt.u8 | undefined => {
return thenSome$0d5am30(rt.u8Rem(b6, 4) !== 0, rt.u8Rem(b6, 3));
});
}, rt.cmpLt(rt.cmpOption(rt.cmpOption(rt.cmp), rt.None)), undefined, undefined, undefined, rt.None)));
}, rt.cmpLt(rt.cmpOption(rt.cmpOption(rt.cmp), rt.None)), undefined, undefined, undefined, undefined, rt.None)));
rt.byteVecPush(out, code(rt.iterMinByKey(it(), (o5: rt.u8 | undefined): rt.u8 | undefined | rt.None => {
return option_map$0rbsrz6(o5, (b7: rt.u8): rt.u8 | undefined => {
return thenSome$0d5am30(rt.u8Rem(b7, 4) !== 0, rt.u8Rem(b7, 3));
});
}, rt.cmpLt(rt.cmpOption(rt.cmpOption(rt.cmp), rt.None)), undefined, undefined, undefined, rt.None)));
}, rt.cmpLt(rt.cmpOption(rt.cmpOption(rt.cmp), rt.None)), undefined, undefined, undefined, undefined, rt.None)));
rt.byteVecPush(out, code(rt.iterFind(rt.iterSlice(items), (o6: rt.u8 | undefined): boolean => {
return o6 === undefined;
}, undefined, rt.None)));
Expand Down
1 change: 0 additions & 1 deletion ts/fixtures/reject/census.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ fixtures/reject/src/keys.rs:keyed_across+1:11: unsupported call to `std::ops::Ra
fixtures/reject/src/keys.rs:keyed_across+1:32: unsupported call to `<std::ops::RangeFrom<u8> as std::ops::RangeBounds<u8>>::contains::<keys::Key>`
fixtures/reject/src/keys.rs:place_bounds+1:9: unsupported call to `std::ops::Range::<&mut u8>::is_empty`
fixtures/reject/src/keys.rs:places_sorted+1:15: unsupported call to `<std::slice::IterMut<'_, u8> as std::iter::Iterator>::is_sorted`
fixtures/reject/src/keys.rs:ranked_cells+1:22: `collect` of `std::collections::BTreeMap<std::cell::Cell<keys::Ranked>, places::Noisy>`, which sorts by `std::cell::Cell<keys::Ranked>`'s own `Ord`, of entries that drop, which is not supported yet
fixtures/reject/src/keys.rs:set_keys+1:75: comparing `std::collections::BTreeSet<u8>` as a key, which is not supported yet
fixtures/reject/src/keys.rs:set_keys+1:75: hashing `std::collections::BTreeSet<u8>` as a key, which is not supported yet
fixtures/reject/src/objects.rs:any_type_id+1:2: unsupported call to `<std::any::TypeId as std::cmp::PartialEq>::eq`
Expand Down
1 change: 0 additions & 1 deletion ts/fixtures/reject/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ fixtures/reject/src/keys.rs:keyed_across+1:11: unsupported call to `std::ops::Ra
fixtures/reject/src/keys.rs:keyed_across+1:32: unsupported call to `<std::ops::RangeFrom<u8> as std::ops::RangeBounds<u8>>::contains::<keys::Key>`
fixtures/reject/src/keys.rs:place_bounds+1:9: unsupported call to `std::ops::Range::<&mut u8>::is_empty`
fixtures/reject/src/keys.rs:places_sorted+1:15: unsupported call to `<std::slice::IterMut<'_, u8> as std::iter::Iterator>::is_sorted`
fixtures/reject/src/keys.rs:ranked_cells+1:22: `collect` of `std::collections::BTreeMap<std::cell::Cell<keys::Ranked>, places::Noisy>`, which sorts by `std::cell::Cell<keys::Ranked>`'s own `Ord`, of entries that drop, which is not supported yet
fixtures/reject/src/keys.rs:set_keys+1:75: comparing `std::collections::BTreeSet<u8>` as a key, which is not supported yet
fixtures/reject/src/keys.rs:set_keys+1:75: hashing `std::collections::BTreeSet<u8>` as a key, which is not supported yet
fixtures/reject/src/objects.rs:any_type_id+1:2: unsupported call to `<std::any::TypeId as std::cmp::PartialEq>::eq`
Expand Down
32 changes: 0 additions & 32 deletions ts/fixtures/reject/src/keys.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Keys and orders of the crate's own, which the runtime's collections and comparisons don't call.

use crate::places::Noisy;

/// JS compares objects by identity, not by `PartialOrd`.
#[derive(PartialEq, PartialOrd)]
pub struct Key(pub u8);
Expand Down Expand Up @@ -72,36 +70,6 @@ pub fn places_sorted(v: &mut [u8]) -> bool {
v.iter_mut().is_sorted()
}

/// A key ordered by its own `Ord`.
#[derive(Clone, Copy)]
pub struct Ranked(pub u8);

impl PartialEq for Ranked {
fn eq(&self, other: &Self) -> bool {
self.0 % 4 == other.0 % 4
}
}

impl Eq for Ranked {}

impl PartialOrd for Ranked {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}

impl Ord for Ranked {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
(self.0 % 4).cmp(&(other.0 % 4))
}
}

/// Entries that drop, sorted by what a cell holds, whose own `Ord` the runtime's sort
/// calls where std's does not.
pub fn ranked_cells(entries: Vec<(std::cell::Cell<Ranked>, Noisy)>) -> usize {
entries.into_iter().collect::<std::collections::BTreeMap<_, _>>().len()
}

impl PartialEq<Key> for u8 {
fn eq(&self, other: &Key) -> bool {
*self == other.0
Expand Down
1 change: 0 additions & 1 deletion ts/fixtures/reject/ts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ roots = [
"keys::keyed_across",
"keys::place_bounds",
"keys::places_sorted",
"keys::ranked_cells",
"keys::set_keys",
"lopsided",
"missing",
Expand Down
8 changes: 8 additions & 0 deletions ts/fixtures/task/expected/core/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as rt from "../rt.ts";
import type * as Any from "../core/any.Any.ts";
import type * as Part from "../drops/objects.Part.ts";
import type * as Ranked from "../drops/orders.Ranked.ts";
import type * as Key from "../drops.Key.ts";
import * as Guard from "../model.Guard.ts";

Expand Down Expand Up @@ -72,6 +73,13 @@ export function map$0782hf5(self: Key.Key | undefined, f: (a0: Key.Key) => rt.u3
return f(self);
}

export function map$1t2fqxi(self: Ranked.Ranked | undefined, f: (a0: Ranked.Ranked) => rt.u32): rt.u32 | undefined {
if (self === undefined) {
return undefined;
}
return f(self);
}

export function map$1raha9y(self: Guard.Guard | undefined, f: (a0: Guard.Guard) => rt.u32): rt.u32 | undefined {
if (self === undefined) {
return undefined;
Expand Down
10 changes: 10 additions & 0 deletions ts/fixtures/task/expected/drops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { looped, collected, drained, extended, compared as iters_compared } from
import { run as lists_run } from "./drops/lists.ts";
import { boxed as objects_boxed, shared, anys, fns } from "./drops/objects.ts";
import { run as once_run } from "./drops/once.ts";
import { orders as orders_orders } from "./drops/orders.ts";
import { released as released_released } from "./drops/released.ts";
import { searched as searched_searched } from "./drops/searched.ts";
import * as Held from "./drops.Held.ts";
Expand Down Expand Up @@ -1321,6 +1322,15 @@ export function released(log: Log.Log, id: rt.u32, arg: rt.u8): void {
released_released(log, id, arg);
}

/**
* Run scenario `arg % 8` of what std drops as it orders: a B-tree's `collect` and `from`
* of keys whose own impls disagree, `max_by_key` and `min_by_key` by keys that drop, and
* a map's `into_keys`' `max` and `min`. The last panics in the sort.
*/
export function orders(log: Log.Log, id: rt.u32, arg: rt.u8): void {
orders_orders(log, id, arg);
}

/** Run scenario `arg % 3` of where std drops a closure given to a string's search or edit. */
export function searched(log: Log.Log, id: rt.u32, arg: rt.u8): void {
searched_searched(log, id, arg);
Expand Down
18 changes: 18 additions & 0 deletions ts/fixtures/task/expected/drops/orders.Rank.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "../rt.ts";

/** A key that copies, so a `Cell` of it orders by it, by its own `Ord` modulo 4. */
export interface Rank {
_0: rt.u8;
}

export function eq$cmp_PartialEq(self: Rank, other: Rank): boolean {
return rt.u8Rem(self._0, 4) === rt.u8Rem(other._0, 4);
}

export function cmp$cmp_Ord(self: Rank, other: Rank): rt.Ordering {
return rt.cmp(rt.u8Rem(self._0, 4), rt.u8Rem(other._0, 4));
}

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

import * as rt from "../rt.ts";
import * as Log from "../log.Log.ts";

/**
* A key that logs its drop and each call to its impls: `cmp` orders by `rank`,
* `partial_cmp` by half of it, and `eq` by it modulo 3. `cmp` panics of a rank of 99.
*/
export class Ranked {
id: rt.u32;
rank: rt.u8;
log: Log.Log;

constructor(id: rt.u32, rank: rt.u8, log: Log.Log) {
this.id = id;
this.rank = rank;
this.log = log;
}

[Symbol.dispose](): void {
drop$ops_Drop(this);
this.log[Symbol.dispose]();
}
}

export function drop$ops_Drop(self: Ranked): void {
const arg = self.id;
const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(arg, f)];
const _4: string = rt.fmtFormat(["k", args2[0], " drop"]);
Log.note(self.log, _4);
}

export function eq$cmp_PartialEq(self: Ranked, other: Ranked): boolean {
const arg = self.id;
const _12: rt.Fmt = (f: rt.Formatter) => rt.u32Display(arg, f);
const arg2 = other.id;
const args2: rt.Fmt[] = [_12, (f: rt.Formatter) => rt.u32Display(arg2, f)];
const _5: string = rt.fmtFormat(["eq ", args2[0], " ", args2[1]]);
Log.note(self.log, _5);
return rt.u8Rem(self.rank, 3) === rt.u8Rem(other.rank, 3);
}

export function partialCmp$cmp_PartialOrd(self: Ranked, other: Ranked): rt.Ordering | undefined {
const arg = self.id;
const _12: rt.Fmt = (f: rt.Formatter) => rt.u32Display(arg, f);
const arg2 = other.id;
const args2: rt.Fmt[] = [_12, (f: rt.Formatter) => rt.u32Display(arg2, f)];
const _5: string = rt.fmtFormat(["partial_cmp ", args2[0], " ", args2[1]]);
Log.note(self.log, _5);
return rt.cmp(rt.u8Div(self.rank, 2), rt.u8Div(other.rank, 2));
}

export function cmp$cmp_Ord(self: Ranked, other: Ranked): rt.Ordering {
const arg = self.id;
const _12: rt.Fmt = (f: rt.Formatter) => rt.u32Display(arg, f);
const arg2 = other.id;
const args2: rt.Fmt[] = [_12, (f: rt.Formatter) => rt.u32Display(arg2, f)];
const _5: string = rt.fmtFormat(["cmp ", args2[0], " ", args2[1]]);
Log.note(self.log, _5);
if (self.rank !== 99) {
if (other.rank !== 99) {
return rt.cmp(self.rank, other.rank);
}
}
const arg3 = self.id;
const _26: rt.Fmt = (f: rt.Formatter) => rt.u32Display(arg3, f);
const arg4 = other.id;
const args4: rt.Fmt[] = [_26, (f: rt.Formatter) => rt.u32Display(arg4, f)];
rt.panicFmt(["cmp of k", args4[0], " with k", args4[1]]);
}

//# sourceMappingURL=orders.Ranked.ts.map
Loading