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 @@ -20,7 +20,6 @@ generic std gap is planned here even when moq never calls it.
- [BufMut's provided writes through a &mut](/quest/m3/ts-buf-mut-forward.md) - `put`, `put_bytes`, `put_uint`, and `put_int` of a `&mut Vec<u8>` or `&mut BytesMut` translate
- [Trait objects](/quest/m3/ts-dyn.md) - `dyn Error`, `dyn Iterator`, `dyn Buf`, and `Arc<dyn Debug>` translate, so a consumer neither rewrites nor binds them
- [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
- [Type-check the output before success](/quest/m3/ts-check-output.md) - translation fails at a Rust span on output `tsc` rejects, rather than at the consumer's `tsc`
- [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
Expand Down
23 changes: 0 additions & 23 deletions quest/m3/ts-check-output.md

This file was deleted.

3 changes: 3 additions & 0 deletions quest/m3/ts-generic-byte-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ already read as its instance's type through a cast; a union of the element array
the byte form, cast on read the same way, may fit, as may refusing the `u8` instance as
`generic_erasure` refuses an `Option` of a type parameter that can be `undefined`.

The `reject` fixture's `mistyped` case tests the output's type check through this gap,
so the fix moves it to another typing gap translation has, if any is left.

Public API: the translator's output.
4 changes: 2 additions & 2 deletions quest/m3/ts-tsrs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

Condition: [tsrs](https://blog.cloudflare.com/typescript-rust-port/), the Rust port of
TypeScript, publishes a stable release usable as a Rust library. Then rust2-ts
type-checks bindings in process through it, with no `tsc` on `PATH`, failing at the
Rust item's span as today, and measures the translation's time against running `tsc`.
type-checks its output and bindings in process through it, with no `tsc` on `PATH`,
failing at the Rust span as today, and measures the translation's time against running `tsc`.
Check: tsrs's releases, and whether it ships a crate (it is moving into Oxc).

## Plan
Expand Down
3 changes: 3 additions & 0 deletions ts/MIGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

- Every translation needs `tsc` 7.0 or later on `PATH`, not only one with bindings: it
type-checks the output, and fails at the Rust span of each error, where it succeeded
before.
- A function the config's roots don't name takes each `&[u8]` or `&[u8; N]` parameter
whose object its body never makes as its `data`, `start`, and `length`:
`read(buf, form)` is `read(buf.data, buf.start, buf.length, form)`. A caller takes
Expand Down
11 changes: 9 additions & 2 deletions ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ or received, such as a parameter, a field, or a call, rather than again at each
holding one; any variable or temporary that holds a type whose JS value is ambiguous, such
as `Option<Option<()>>`, is refused at its own span.

Once the output is written, `tsc` 7.0 or later, from `PATH`, type-checks it as strictly as
the runtime, but for unused names. Output it rejects is a bug in rust2-ts, and fails the
translation at the Rust span the source map names there, or else at the item's, and the
output is removed. The same run checks the bindings, and an error in translated code is
reported once they pass, since a wrong binding fails its callers too.

```toml
# ts.toml, beside the package's Cargo.toml unless --manifest-path says otherwise.
package = "moq-net"
Expand Down Expand Up @@ -552,7 +558,7 @@ binding never changes a `Copy` value in place. Nor does a binding change in plac
takes by value or by `&`, or share with a clone what a `&mut` changes, and an integer it
returns is in its Rust type's range.

Once the output is written, `tsc` 7.0 or later, from `PATH`, checks each export against the
The check of the output also checks each export against the
translated signature of every instance translation calls, and each bound type's value. One
returning `()` is checked against `=> undefined`, not `=> void`, which accepts any value,
so its export is typed `: undefined`. A missing or mismatched binding fails the
Expand Down Expand Up @@ -880,7 +886,8 @@ built natively for wasm32 and run beside its translation on the same inputs by
from either end, and its `shared` feature adds a module of the dependency's name, with
the errors in `refused.txt`, `rev.txt`, and `shared.txt`.
- `reject` holds constructs outside the subset; its expected errors are `expected.txt`,
and its expected census is `census.md`.
and its expected census is `census.md`. `mistyped.toml` translates a typing gap that
`tsc` rejects, with the errors in `mistyped.txt`.

`tests/spawn.ts` checks that `rt.spawn` yields to a timer after its 128-poll budget, and
rejects when a future panics as it drops. `tests/retain.ts` runs a collection's `retain`
Expand Down
2 changes: 1 addition & 1 deletion ts/fixtures/reject/census.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Census of `reject-fixture`

- Refusals: 218
- Function instances: 270
- Function instances: 273
- Generic functions no instance reached, lowered over their type parameters: 13

## By construct
Expand Down
4 changes: 4 additions & 0 deletions ts/fixtures/reject/mistyped.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# A typing gap translation doesn't refuse, which `tsc` fails at the Rust the source map
# names: `mistyped.txt` holds the errors.
package = "reject-fixture"
roots = ["mistyped"]
2 changes: 2 additions & 0 deletions ts/fixtures/reject/mistyped.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib.Rows.ts:22:20 doesn't type-check, which is a bug in rust2-ts: error TS2339: Property 'data' does not exist on type 'u8[]'. at fixtures/reject/src/lib.rs:2161:3
lib.ts:8:47 doesn't type-check, which is a bug in rust2-ts: error TS2740: Type 'ByteVec' is missing the following properties from type 'u8[]': pop, push, concat, join, and 28 more. at fixtures/reject/src/lib.rs:2167:4
18 changes: 18 additions & 0 deletions ts/fixtures/reject/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2148,3 +2148,21 @@ pub fn generic_park_rebound<T>(mut w: Parking<T>, next: Parking<T>) -> i16 {
w = next;
unsafe { (*p).0.get() + w.park.0.get() }
}

/// A generic type's `Vec<T>`, typed `T[]` though its `u8` instance holds an `rt.ByteVec`:
/// translation writes output `tsc` rejects, and fails at the Rust it maps to.
pub struct Rows<T> {
pub items: Vec<T>,
}

impl<T: Copy> Rows<T> {
pub fn first(&self) -> T {
self.items[0]
}
}

pub fn mistyped(bytes: Vec<u8>, words: Vec<u16>) -> u32 {
let a = Rows { items: bytes };
let b = Rows { items: words };
a.first() as u32 + b.first() as u32
}
Loading