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 @@ -21,7 +21,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: 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, flattens, and collects drop as std's do
- [Fresh writes in a body generic over a type](/quest/m3/ts-fresh-type-params.md) - a whole write into fresh memory holding a type parameter's values fills it, as one generic over a length alone does
- [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 slice's searches by a closure](/quest/m3/ts-binary-search-by.md) - `binary_search_by`, `binary_search_by_key`, and `partition_point` translate, probing as std's do
- [Waiting: a slice object for a mutable part of other values](/quest/m3/ts-slice-object.md) - waits on a moq profile showing the `Proxy` view's traps matter, then decides on an `rt.ByteSlice`-like form
Expand Down
19 changes: 0 additions & 19 deletions quest/m3/ts-fresh-type-params.md

This file was deleted.

6 changes: 6 additions & 0 deletions ts/fixtures/lang/expected/lengths.Tagged.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import { put$lengths_Put_u32 as lengths_put$lengths_Put_u32 } from "./lengths.ts";

export class Tagged<T> {
_0: T;
Expand All @@ -12,4 +13,9 @@ export class Tagged<T> {
}
}

export function put$lengths_Put_u32(self: Tagged<rt.u32>, out: rt.ByteVec): void {
lengths_put$lengths_Put_u32(self._0, out);
rt.byteVecPush(out, self._1);
}

//# sourceMappingURL=lengths.Tagged.ts.map
886 changes: 689 additions & 197 deletions ts/fixtures/lang/expected/lengths.ts

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions ts/fixtures/lang/expected/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ export function copy$array_keys_Hop(v: Hop.Hop[]): Hop.Hop[] {
return v.map(copy$keys_Hop);
}

export function copy$array_lengths_Tagged_u32(v: lengths_Tagged.Tagged<rt.u32>[]): lengths_Tagged.Tagged<rt.u32>[] {
return v.slice();
}

export function copy$array_ptr_array4_u8(v: rt.ByteSlice[]): rt.ByteSlice[] {
return v.slice();
}
Expand Down Expand Up @@ -434,6 +438,13 @@ export function copy$mem_MaybeUninit_array_array3_u8(v: Uint8Array[]): Uint8Arra
return v.map(copy$mem_MaybeUninit_array_u8);
}

export function copy$mem_MaybeUninit_array_lengths_Tagged_u32(v: lengths_Tagged.Tagged<rt.u32>[]): lengths_Tagged.Tagged<rt.u32>[] {
if (v === undefined) {
return v;
}
return v.slice();
}

export function copy$mem_MaybeUninit_array_u32(v: rt.u32[]): rt.u32[] {
if (v === undefined) {
return v;
Expand All @@ -455,6 +466,13 @@ export function copy$mem_MaybeUninit_tuple2_array0_array0_u8_tuple2_u8_u8(v: [Ui
return [copy$mem_MaybeUninit_array_array0_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])];
}

export function copy$mem_MaybeUninit_tuple2_array0_lengths_Tagged_u32_tuple2_u8_u8(v: [lengths_Tagged.Tagged<rt.u32>[], [rt.u8, rt.u8]]): [lengths_Tagged.Tagged<rt.u32>[], [rt.u8, rt.u8]] {
if (v === undefined) {
return v;
}
return [copy$mem_MaybeUninit_array_lengths_Tagged_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])];
}

export function copy$mem_MaybeUninit_tuple2_array0_u32_tuple2_u8_u8(v: [rt.u32[], [rt.u8, rt.u8]]): [rt.u32[], [rt.u8, rt.u8]] {
if (v === undefined) {
return v;
Expand All @@ -476,6 +494,13 @@ export function copy$mem_MaybeUninit_tuple2_array17_array17_u8_tuple2_u8_u8(v: [
return [copy$mem_MaybeUninit_array_array17_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])];
}

export function copy$mem_MaybeUninit_tuple2_array17_lengths_Tagged_u32_tuple2_u8_u8(v: [lengths_Tagged.Tagged<rt.u32>[], [rt.u8, rt.u8]]): [lengths_Tagged.Tagged<rt.u32>[], [rt.u8, rt.u8]] {
if (v === undefined) {
return v;
}
return [copy$mem_MaybeUninit_array_lengths_Tagged_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])];
}

export function copy$mem_MaybeUninit_tuple2_array17_u32_tuple2_u8_u8(v: [rt.u32[], [rt.u8, rt.u8]]): [rt.u32[], [rt.u8, rt.u8]] {
if (v === undefined) {
return v;
Expand All @@ -497,6 +522,13 @@ export function copy$mem_MaybeUninit_tuple2_array1_array1_u8_tuple2_u8_u8(v: [Ui
return [copy$mem_MaybeUninit_array_array1_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])];
}

export function copy$mem_MaybeUninit_tuple2_array1_lengths_Tagged_u32_tuple2_u8_u8(v: [lengths_Tagged.Tagged<rt.u32>[], [rt.u8, rt.u8]]): [lengths_Tagged.Tagged<rt.u32>[], [rt.u8, rt.u8]] {
if (v === undefined) {
return v;
}
return [copy$mem_MaybeUninit_array_lengths_Tagged_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])];
}

export function copy$mem_MaybeUninit_tuple2_array1_u32_tuple2_u8_u8(v: [rt.u32[], [rt.u8, rt.u8]]): [rt.u32[], [rt.u8, rt.u8]] {
if (v === undefined) {
return v;
Expand All @@ -518,6 +550,13 @@ export function copy$mem_MaybeUninit_tuple2_array3_array3_u8_tuple2_u8_u8(v: [Ui
return [copy$mem_MaybeUninit_array_array3_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])];
}

export function copy$mem_MaybeUninit_tuple2_array3_lengths_Tagged_u32_tuple2_u8_u8(v: [lengths_Tagged.Tagged<rt.u32>[], [rt.u8, rt.u8]]): [lengths_Tagged.Tagged<rt.u32>[], [rt.u8, rt.u8]] {
if (v === undefined) {
return v;
}
return [copy$mem_MaybeUninit_array_lengths_Tagged_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])];
}

export function copy$mem_MaybeUninit_tuple2_array3_u32_tuple2_u8_u8(v: [rt.u32[], [rt.u8, rt.u8]]): [rt.u32[], [rt.u8, rt.u8]] {
if (v === undefined) {
return v;
Expand Down
78 changes: 44 additions & 34 deletions ts/fixtures/lang/src/lengths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ fn each<const N: usize>(data: &[u8], out: &mut Vec<u8>) {
joined(data, vec![[0xa5; N], std::array::from_fn(|i| i as u8)], out);
retagged(&rows, out);
recloned(&wide, out);
filled_bytes::<N>(data, std::array::from_fn(|i| i as u8), out);
filled_words::<N>(data, std::array::from_fn(|i| 0x0102_0304 * i as u32), out);
filled_rows::<N>(
filled::<u8, N>(data, std::array::from_fn(|i| i as u8), out);
filled::<u32, N>(data, std::array::from_fn(|i| 0x0102_0304 * i as u32), out);
filled::<[u8; N], N>(
data,
std::array::from_fn(|i| std::array::from_fn(|j| (i * N + j) as u8)),
out,
);
filled::<Tagged<u32>, N>(
data,
std::array::from_fn(|i| Tagged(i as u32 * 0x0101, !(i as u8))),
out,
);
swapped(data, &rows, out);
swapped(data, &wide, out);
}
Expand Down Expand Up @@ -77,40 +82,38 @@ fn recloned<T: Copy + Into<u32>, const N: usize>(rows: &[[T; N]], out: &mut Vec<
}
}

/// Slots of `MaybeUninit` arrays of `$elem`, each written whole through an iterator
/// while nothing points into them, then changed in place, a pair of tags through a pointer
/// to it, and read back. Over the length alone: a type parameter's values would be types
/// std's iterators may run the crate's code on.
macro_rules! filled {
($name:ident, $elem:ty) => {
fn $name<const N: usize>(data: &[u8], fill: [$elem; N], out: &mut Vec<u8>) {
let mut slots: [MaybeUninit<([$elem; N], (u8, u8))>; 3] = [const { MaybeUninit::uninit() }; 3];
for (slot, at) in slots.iter_mut().zip(0u8..) {
slot.write((fill, (at, !at)));
}
for &byte in data {
let slot = unsafe { slots[usize::from(byte) % 3].assume_init_mut() };
slot.0.rotate_left(usize::from(byte) % N.max(1));
let tags = &raw mut slot.1;
unsafe {
(*tags).0 ^= byte;
(*tags).1 = (*tags).1.wrapping_add(byte);
out.extend([(*tags).0, (*tags).1]);
}
}
for slot in &slots {
let (values, (a, b)) = unsafe { slot.assume_init_ref() };
values.iter().for_each(|v| v.put(out));
out.extend([*a, *b]);
}
/// Slots of `MaybeUninit` arrays of `T`, each written whole through an iterator while
/// nothing points into them, the last two again beside a vector's iterator, which std
/// drops, then changed in place, a pair of tags through a pointer to it, and read back.
fn filled<T: Copy + Put, const N: usize>(data: &[u8], fill: [T; N], out: &mut Vec<u8>) {
let mut slots: [MaybeUninit<([T; N], (u8, u8))>; 3] = [const { MaybeUninit::uninit() }; 3];
for (slot, at) in slots.iter_mut().zip(0u8..) {
slot.write((fill, (at, !at)));
}
let mut picks = Vec::new();
for &v in &fill {
picks.push(Some(v));
}
for (slot, _) in slots.iter_mut().skip(1).zip(picks) {
slot.write((fill, (N as u8, 0x5a)));
}
for &byte in data {
let slot = unsafe { slots[usize::from(byte) % 3].assume_init_mut() };
slot.0.rotate_left(usize::from(byte) % N.max(1));
let tags = &raw mut slot.1;
unsafe {
(*tags).0 ^= byte;
(*tags).1 = (*tags).1.wrapping_add(byte);
out.extend([(*tags).0, (*tags).1]);
}
};
}
for slot in &slots {
let (values, (a, b)) = unsafe { slot.assume_init_ref() };
values.iter().for_each(|v| v.put(out));
out.extend([*a, *b]);
}
}

filled!(filled_bytes, u8);
filled!(filled_words, u32);
filled!(filled_rows, [u8; N]);

/// A value's bytes.
trait Put {
fn put(&self, out: &mut Vec<u8>);
Expand All @@ -134,6 +137,13 @@ impl<const N: usize> Put for [u8; N] {
}
}

impl<T: Put> Put for Tagged<T> {
fn put(&self, out: &mut Vec<u8>) {
self.0.put(out);
out.push(self.1);
}
}

/// Rows of a grid swapped whole, each copy kept apart from the row it was read from as
/// either changes.
fn swapped<T: Copy + Into<u32>, const N: usize>(data: &[u8], rows: &[[T; N]], out: &mut Vec<u8>) {
Expand Down
22 changes: 17 additions & 5 deletions ts/fixtures/reject/census.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Census of `reject-fixture`

- Refusals: 227
- Function instances: 281
- Refusals: 231
- Function instances: 293
- Generic functions no instance reached, lowered over their type parameters: 13

## By construct

| Count | Construct | First |
| ---: | --- | --- |
| 45 | a raw pointer to `_` in `_`, which the crate may put another object in place of | fixtures/reject/src/lib.rs:608:10 |
| 49 | a raw pointer to `_` in `_`, which the crate may put another object in place of | fixtures/reject/src/lib.rs:608:10 |
| 25 | unsupported call to `_` | fixtures/reject/src/lib.rs:160:8 |
| 22 | a raw pointer to `_` in a variable assigned again while it may point there | fixtures/reject/src/lib.rs:616:10 |
| 15 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | fixtures/reject/src/lib.rs:1337:33 |
Expand Down Expand Up @@ -95,6 +95,7 @@ The type or module each refused type or path belongs to.
| 6 | `f16` | fixtures/reject/src/lib.rs:7:14 |
| 6 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:331:2 |
| 6 | `u32` | fixtures/reject/src/lib.rs:555:27 |
| 5 | `(u8, u8)` | fixtures/reject/src/lib.rs:1272:31 |
| 5 | `Gap` | fixtures/reject/src/lib.rs:908:10 |
| 5 | `Option` | fixtures/reject/src/lib.rs:16:15 |
| 5 | `u8` | fixtures/reject/src/lib.rs:253:6 |
Expand Down Expand Up @@ -134,14 +135,17 @@ The type or module each refused type or path belongs to.
| 2 | `std::sync::Arc` | fixtures/reject/src/lib.rs:291:2 |
| 2 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:83:2 |
| 2 | `std::vec::IntoIter` | fixtures/reject/src/lib.rs:434:17 |
| 1 | `(Dropped, (u8, u8))` | fixtures/reject/src/lib.rs:2263:2 |
| 1 | `([Cloned; 2], (u8, u8))` | fixtures/reject/src/lib.rs:2247:2 |
| 1 | `([Greatest; 2], (u8, u8))` | fixtures/reject/src/lib.rs:2281:13 |
| 1 | `([Touched; 2], (u8, u8))` | fixtures/reject/src/lib.rs:2312:2 |
| 1 | `(std::vec::Vec, Tens)` | fixtures/reject/src/lib.rs:1272:31 |
| 1 | `(u16, ByKeyReplace)` | fixtures/reject/src/lib.rs:1621:55 |
| 1 | `(u16, ByKeySet)` | fixtures/reject/src/lib.rs:1613:51 |
| 1 | `(u16, ByKeyTake)` | fixtures/reject/src/lib.rs:1628:52 |
| 1 | `(u16, ByRefReplace)` | fixtures/reject/src/lib.rs:1597:32 |
| 1 | `(u16, ByRefTake)` | fixtures/reject/src/lib.rs:1605:32 |
| 1 | `(u16, InTuple)` | fixtures/reject/src/lib.rs:1346:33 |
| 1 | `(u8, u8)` | fixtures/reject/src/lib.rs:1272:31 |
| 1 | `*const [u8]` | fixtures/reject/src/lib.rs:1714:28 |
| 1 | `*const u8` | fixtures/reject/src/lib.rs:1713:33 |
| 1 | `*mut [u8; 4]` | fixtures/reject/src/lib.rs:1712:41 |
Expand Down Expand Up @@ -321,6 +325,10 @@ The type or module each refused type or path belongs to.
| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u32, u32)`, `Track` | fixtures/reject/src/lib.rs:852:19 |
| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u32, u32)`, `Window` | fixtures/reject/src/lib.rs:669:2 |
| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u32, u32)`, `std::cell::UnsafeCell` | fixtures/reject/src/lib.rs:687:15 |
| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u8, u8)`, `(Dropped, (u8, u8))` | fixtures/reject/src/lib.rs:2263:2 |
| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u8, u8)`, `([Cloned; 2], (u8, u8))` | fixtures/reject/src/lib.rs:2247:2 |
| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u8, u8)`, `([Greatest; 2], (u8, u8))` | fixtures/reject/src/lib.rs:2281:13 |
| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u8, u8)`, `([Touched; 2], (u8, u8))` | fixtures/reject/src/lib.rs:2312:2 |
| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `ByKeyReplace`, `(u16, ByKeyReplace)` | fixtures/reject/src/lib.rs:1621:55 |
| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `ByKeySet`, `(u16, ByKeySet)` | fixtures/reject/src/lib.rs:1613:51 |
| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `ByKeyTake`, `(u16, ByKeyTake)` | fixtures/reject/src/lib.rs:1628:52 |
Expand Down Expand Up @@ -434,7 +442,7 @@ The type or module each refused type or path belongs to.

## Spans

<details><summary>a raw pointer to `_` in `_`, which the crate may put another object in place of (45)</summary>
<details><summary>a raw pointer to `_` in `_`, which the crate may put another object in place of (49)</summary>

- fixtures/reject/src/lib.rs:608:10: a raw pointer to `(u32, u32)` in `Span2`, which the crate may put another object in place of
- fixtures/reject/src/lib.rs:669:2: a raw pointer to `(u32, u32)` in `Window`, which the crate may put another object in place of
Expand Down Expand Up @@ -481,6 +489,10 @@ The type or module each refused type or path belongs to.
- fixtures/reject/src/lib.rs:1613:51: a raw pointer to `ByKeySet` in `(u16, ByKeySet)`, which the crate may put another object in place of
- fixtures/reject/src/lib.rs:1621:55: a raw pointer to `ByKeyReplace` in `(u16, ByKeyReplace)`, which the crate may put another object in place of
- fixtures/reject/src/lib.rs:1628:52: a raw pointer to `ByKeyTake` in `(u16, ByKeyTake)`, which the crate may put another object in place of
- fixtures/reject/src/lib.rs:2247:2: a raw pointer to `(u8, u8)` in `([Cloned; 2], (u8, u8))`, which the crate may put another object in place of
- fixtures/reject/src/lib.rs:2263:2: a raw pointer to `(u8, u8)` in `(Dropped, (u8, u8))`, which the crate may put another object in place of
- fixtures/reject/src/lib.rs:2281:13: a raw pointer to `(u8, u8)` in `([Greatest; 2], (u8, u8))`, which the crate may put another object in place of
- fixtures/reject/src/lib.rs:2312:2: a raw pointer to `(u8, u8)` in `([Touched; 2], (u8, u8))`, which the crate may put another object in place of

</details>

Expand Down
4 changes: 4 additions & 0 deletions ts/fixtures/reject/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,7 @@ a raw pointer to `std::cell::UnsafeCell<u16>` in `InField`, which the crate may
a raw pointer to `std::cell::UnsafeCell<u16>` in `InGeneric`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1322:9
a raw pointer to `std::cell::UnsafeCell<u16>` in `InWritten`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1326:9
a reference to `std::option::Option<Block<2>>`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:2108:13
a raw pointer to `(u8, u8)` in `([Cloned; 2], (u8, u8))`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:2225:23
a raw pointer to `(u8, u8)` in `(Dropped, (u8, u8))`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:2225:23
a raw pointer to `(u8, u8)` in `([Greatest; 2], (u8, u8))`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:2281:13
a raw pointer to `(u8, u8)` in `([Touched; 2], (u8, u8))`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:2225:23
Loading