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/ts-model/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ kept separate since each lands alone; rejected: one quest for `ArrayString`.

- [Addresses as identity](/quest/m2/ts-model/addresses.md) - `Arc::as_ptr(a) as usize` as a key, which needs a decision
- [Option fields at a unit instance](/quest/m2/ts-model/unit-option-fields.md) - `Idle<()>`'s `Option<T>` field tells `Some(())` from `None`
- [panic! in a 2015 or 2018 crate](/quest/m2/ts-model/begin-panic.md) - the `begin_panic` mapping keyed by its defining module
- [A string's bytes through its pointer](/quest/m2/ts-model/str-as-ptr.md) - `str::as_ptr` reads the string's UTF-8

Public API: the translator's output for moq-net's model.
15 changes: 0 additions & 15 deletions quest/m2/ts-model/begin-panic.md

This file was deleted.

5 changes: 5 additions & 0 deletions ts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ts/fixtures/lang/panics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ hook = ["dep:bytes"]

[dependencies]
bytes = { version = "1.12.1", optional = true }
edition2018 = { path = "edition2018" }

[lints]
workspace = true
10 changes: 10 additions & 0 deletions ts/fixtures/lang/panics/edition2018/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "edition2018"
description = "A 2018-edition crate's panics, which expand to std's `begin_panic`"
version = "0.0.0"
edition = "2018"
license.workspace = true
publish = false

[lints]
workspace = true
22 changes: 22 additions & 0 deletions ts/fixtures/lang/panics/edition2018/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//! `panic!` in a 2018-edition crate, whose message is any value: none, a literal, text, a
//! value of another type, and a format string with arguments.

/// Panic as `kind` picks, or write the first byte.
#[expect(non_fmt_panics, reason = "a 2018 crate's `panic!` takes any value as its payload")]
pub fn panicked(kind: u8, data: &[u8], out: &mut Vec<u8>) {
let first = data.first().copied().unwrap_or(0);
match kind % 7 {
0 => panic!(),
1 => panic!("a literal"),
2 => panic!(format!("{} bytes", data.len())),
3 => panic!(if first % 2 == 0 { "even" } else { "odd" }),
4 => panic!(first),
5 => panic!("{} bytes", data.len()),
_ => {
if first > 200 {
panic!("past 200");
}
out.push(first);
}
}
}
37 changes: 37 additions & 0 deletions ts/fixtures/lang/panics/expected/edition2018.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Generated by rust2-ts. Do not edit.

import * as rs from "./rs.ts";
import { unwrapOr$1fr498u as option_unwrapOr$1fr498u } from "./core/option.ts";

/** Panic as `kind` picks, or write the first byte. */
export function panicked(kind: rs.u8, data: rs.ByteSlice, out: rs.ByteVec): void {
let _23!: string;
const first: rs.u8 = option_unwrapOr$1fr498u(rs.byteSliceFirst(data), 0);
const _7: rs.u8 = rs.u8Rem(kind, 7);
if (_7 === 0) {
rs.panic("explicit panic");
} else if (_7 === 1) {
rs.panic("a literal");
} else if (_7 === 2) {
const arg2 = data.length;
rs.panic(rs.fmtFormat([(f: rs.Formatter) => rs.usizeDisplay(arg2, f), " bytes"]));
} else if (_7 === 3) {
if (!(rs.u8Rem(first, 2) === 0)) {
_23 = "odd";
} else {
_23 = "even";
}
rs.panic(_23);
} else if (_7 === 4) {
rs.panic("Box<dyn Any>");
} else if (_7 === 5) {
const arg = data.length;
rs.panicFmt([(f: rs.Formatter) => rs.usizeDisplay(arg, f), " bytes"]);
} else if (!(first > 200)) {
rs.byteVecPush(out, first);
} else {
rs.panic("past 200");
}
}

//# sourceMappingURL=edition2018.ts.map
5 changes: 3 additions & 2 deletions ts/fixtures/lang/panics/expected/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import * as rs from "./rs.ts";
import type * as Any from "./core/any.Any.ts";
import { via$located_Tracked_u8, at$located_Tracked_u8, called as located_called, read, panicked } from "./located.ts";
import { panicked as edition2018_panicked } from "./edition2018.ts";
import { via$located_Tracked_u8, at$located_Tracked_u8, called as located_called, read, panicked as located_panicked } from "./located.ts";
import * as Inherits from "./located.Inherits.ts";
import * as Own from "./located.Own.ts";
import { wrapped, called as panics_called, awaited, raised } from "./panics.ts";
Expand Down Expand Up @@ -83,7 +84,7 @@ export class of$u8 {
* their count, so a case added at the end moves no other.
*/
export function cases(): rs.Vec<[string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined]> {
return rs.vecFrom([["panics::wrapped", wrapped as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["panics::called", panics_called as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["panics::awaited", awaited as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["panics::raised", raised as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["located::called", located_called as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["located::read", read as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["located::panicked", panicked as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined]]);
return rs.vecFrom([["panics::wrapped", wrapped as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["panics::called", panics_called as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["panics::awaited", awaited as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["panics::raised", raised as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["located::called", located_called as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["located::read", read as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["located::panicked", located_panicked as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined], ["edition2018::panicked", edition2018_panicked as (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined] as [string, (a0: rs.u8, a1: rs.ByteSlice, a2: rs.ByteVec) => undefined]]);
}

export const NOTE: rs.LocalKey<rs.RefCell<string>> = /* @__PURE__ */ new rs.LocalKey(NOTE$init, false);
Expand Down
38 changes: 38 additions & 0 deletions ts/fixtures/lang/panics/hook/expected/edition2018.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Generated by rust2-ts. Do not edit.

import * as rs from "./rs.ts";
import { of$u8 } from "./lib.ts";
import { unwrapOr$1fr498u as option_unwrapOr$1fr498u } from "./core/option.ts";

/** Panic as `kind` picks, or write the first byte. */
export function panicked(kind: rs.u8, data: rs.ByteSlice, out: rs.ByteVec): void {
let _23!: string;
const first: rs.u8 = option_unwrapOr$1fr498u(rs.byteSliceFirst(data), 0);
const _7: rs.u8 = rs.u8Rem(kind, 7, { file: "fixtures/lang/panics/edition2018/src/lib.rs", line: 8, col: 11 });
if (_7 === 0) {
rs.panic("explicit panic", { file: "fixtures/lang/panics/edition2018/src/lib.rs", line: 9, col: 14 }, false);
} else if (_7 === 1) {
rs.panic("a literal", { file: "fixtures/lang/panics/edition2018/src/lib.rs", line: 10, col: 14 }, false);
} else if (_7 === 2) {
const arg2 = data.length;
rs.panic(rs.fmtFormat([(f: rs.Formatter) => rs.usizeDisplay(arg2, f), " bytes"]), { file: "fixtures/lang/panics/edition2018/src/lib.rs", line: 11, col: 14 }, true);
} else if (_7 === 3) {
if (!(rs.u8Rem(first, 2, { file: "fixtures/lang/panics/edition2018/src/lib.rs", line: 12, col: 24 }) === 0)) {
_23 = "odd";
} else {
_23 = "even";
}
rs.panic(_23, { file: "fixtures/lang/panics/edition2018/src/lib.rs", line: 12, col: 14 }, false);
} else if (_7 === 4) {
rs.panicAny(new of$u8(first), { file: "fixtures/lang/panics/edition2018/src/lib.rs", line: 13, col: 14 });
} else if (_7 === 5) {
const arg = data.length;
rs.panicFmt([(f: rs.Formatter) => rs.usizeDisplay(arg, f), " bytes"], { file: "fixtures/lang/panics/edition2018/src/lib.rs", line: 14, col: 14 });
} else if (!(first > 200)) {
rs.byteVecPush(out, first);
} else {
rs.panic("past 200", { file: "fixtures/lang/panics/edition2018/src/lib.rs", line: 17, col: 17 }, false);
}
}

//# sourceMappingURL=edition2018.ts.map
2 changes: 1 addition & 1 deletion ts/fixtures/lang/panics/hook/expected/hooked.Shown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function fmt$fmt_Display(self: Shown, f: rs.Formatter): rs.Result<undefin
if (!self.again) {
return rs.fmtWriteStr(f, "shown");
}
rs.panicFmt(["shown"], { file: "fixtures/lang/panics/src/hooked.rs", line: 139, col: 13 });
rs.panicFmt(["shown"], { file: "fixtures/lang/panics/src/hooked.rs", line: 142, col: 13 });
}

//# sourceMappingURL=hooked.Shown.ts.map
Loading