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 @@ -19,7 +19,6 @@ generic std gap is planned here even when moq never calls it.
- [f32](/quest/m3/ts-f32.md) - `f32` and `Duration`'s `f32` methods translate as `f64` does
- [Trait objects](/quest/m3/ts-dyn.md) - `dyn Trait` and `Box<dyn Future>` translate, so a consumer neither rewrites nor binds them
- [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
- [Fold matches across tests that aren't variant switches](/quest/m3/ts-fold-guards.md) - a match an `if` or guard decided drops its dead arms
- [An inclusive range drained by a fold](/quest/m3/ts-range-fold.md) - a folded `RangeInclusive` ends in core's state
- [bool's combinators from core's MIR](/quest/m3/ts-bool-core.md) - `bool::then` lowers from core, retiring `rt.boolThen`
- [Binding gaps](/quest/m3/ts-bind-gaps.md) - bound types as keys, unit returns checked, renamed dependencies
Expand Down
21 changes: 0 additions & 21 deletions quest/m3/ts-fold-guards.md

This file was deleted.

55 changes: 55 additions & 0 deletions ts/fixtures/lang/expected/shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,10 @@ export function rematched(data: rt.ByteSlice, out: rt.ByteVec): void {
let _127!: rt.u8;
let _131!: Shape.Shape;
let _189!: rt.u8;
let _192!: rt.u8;
let lift!: rt.u8;
let _206!: rt.u8;
let _226!: rt.u8;
const s: Shape.Shape = shape(data);
if (s.tag === "Dot") {
_5 = 2;
Expand Down Expand Up @@ -1820,6 +1824,57 @@ export function rematched(data: rt.ByteSlice, out: rt.ByteVec): void {
}
rt.byteVecPush(out, _189);
}
if (s.tag === "Line") {
const from3: Point.Point = s._0;
if (!(data.length > 2)) {
lift = 2;
} else {
lift = 1;
}
_192 = ((from3.y ^ s._1.x) & 0xff) ^ lift;
} else {
_192 = 49;
}
rt.byteVecPush(out, _192);
b30: {
if (s.tag === "Dot") {
if (!(data.length > 1)) {
_206 = 53;
break b30;
}
_206 = 51;
break b30;
}
if (s.tag === "Rect") {
if (s.width > 300) {
_206 = s.height & 0xff;
break b30;
}
}
_206 = 55;
}
rt.byteVecPush(out, _206);
b32: {
let w: Shape.Shape = s;
if (w.tag === "Dot") {
let i2: rt.usize = 0;
while (true) {
if (!(i2 < rt.min(data.length, 3))) {
break b32;
}
if (w.tag === "Dot") {
w = shape(rt.byteSliceFrom(Uint8Array.of(1)));
_226 = 56;
} else if (w.tag === "Line") {
_226 = 57;
} else {
_226 = 58;
}
rt.byteVecPush(out, _226);
i2 = rt.usizeAdd(i2, 1);
}
}
}
reseated(data, out);
}

Expand Down
42 changes: 42 additions & 0 deletions ts/fixtures/lang/src/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,48 @@ fn rematched(data: &[u8], out: &mut Vec<u8>) {
_ => 26,
});
}
// An `if` or a guard between the matches keeps what the outer one decided.
out.push(match s {
Shape::Line(from, _) => {
let lift = if data.len() > 2 { 1 } else { 2 };
match s {
Shape::Line(_, to) => (from.y ^ to.x) as u8 ^ lift,
_ => 48,
}
}
_ => 49,
});
out.push(match s {
Shape::Dot if data.len() > 1 => match s {
Shape::Line(..) => 50,
_ => 51,
},
Shape::Rect { width, .. } if width > 300 => match s {
Shape::Rect { height, .. } => height as u8,
_ => 52,
},
Shape::Dot => match s {
Shape::Dot => 53,
_ => 54,
},
_ => 55,
});
// A loop's test keeps only what every way around it knows.
let mut w = s;
if let Shape::Dot = w {
let mut i = 0;
while i < data.len().min(3) {
out.push(match w {
Shape::Dot => {
w = shape(&[1]);
56
}
Shape::Line(..) => 57,
_ => 58,
});
i += 1;
}
}
reseated(data, out);
}

Expand Down
7 changes: 1 addition & 6 deletions ts/src/lower/mir/decided.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,13 +589,8 @@ impl<'tcx> Flow<'tcx> {
}
decided = Some((def, kept, otherwise));
}
// A test of anything else changes nothing. What is known stays with the
// switches on a variant, which fold by it.
// A test of anything else, as an `if` or a match guard, changes nothing.
TerminatorKind::SwitchInt { targets, .. } => {
let facts = Facts {
known: Vec::new(),
narrowed: facts.narrowed.clone(),
};
for &to in targets.all_targets() {
if !out.iter().any(|(t, _)| *t == to) {
out.push((to, facts.clone()));
Expand Down
4 changes: 2 additions & 2 deletions ts/src/lower/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3008,8 +3008,6 @@ impl<'tcx> Fx<'_, '_, '_, 'tcx> {
}
}

/// Whether `place` is part of its local's own value, rather than reached through a
/// reference or pointer.
/// `value` as a value of `ty`, its JS union type: `Ok` of it, or `Err` of an `Ok` or `Err`,
/// which TypeScript types as the whole union already.
pub(super) fn whole(value: Expr, ty: Type) -> Result<Expr, Expr> {
Expand All @@ -3024,6 +3022,8 @@ pub(super) fn whole(value: Expr, ty: Type) -> Result<Expr, Expr> {
}
}

/// Whether `place` is part of its local's own value, rather than reached through a
/// reference or pointer.
pub(super) fn own(place: Place<'_>) -> bool {
place
.projection
Expand Down