Repository navigation
feat(ts): translate the rest of the cells' and locks' methods - #374
Merged
Merged
Conversation
Quest-Claim: 3c47261cd62fb24a
Clone, Debug, get_mut, and get_or_try_init of OnceCell and OnceLock; Clone, get_mut, into_inner, try_borrow, try_borrow_mut, Ref::map, and Ref::clone of RefCell, and get_mut and into_inner of RwLock and Mutex, lending an rt.Place where JS copies the value. Completes the shared-ownership quest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and tree-shake the borrow errors Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # ts/fixtures/lang/expected/harness.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # ts/fixtures/lang/expected/core/bool.ts # ts/fixtures/lang/expected/core/result.ts # ts/fixtures/lang/expected/harness.ts
…hat reference Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 1, 2026 07:03
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Contributor
|
quest land removed this pull request from the queue: Conflicts with the base: ts/fixtures/reject/census.md |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
quest land removed this pull request from the queue: the batch check failed (exit 101). | ^^^^^
warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
--> fixtures/task/src/drops.rs:424:2
|
424 | drop(counts.entry(counted(20)).or_insert(guard(21)));
| ^^^^^----------------------------------------------^
| |
| argument has type `&mut Guard`
|
= note: `#[warn(dropping_references)]` on by default
help: use `let _ = ...` to ignore the expression or result
|
424 - drop(counts.entry(counted(20)).or_insert(guard(21)));
424 + let _ = counts.entry(counted(20)).or_insert(guard(21));
|
warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
--> fixtures/task/src/drops.rs:425:2
|
425 | drop(counts.entry(counted(22)).or_insert_with(|| guard(22)));
| ^^^^^------------------------------------------------------^
| |
| argument has type `&mut Guard`
|
help: use `let _ = ...` to ignore the expression or result
|
425 - drop(counts.entry(counted(22)).or_insert_with(|| guard(22)));
425 + let _ = counts.entry(counted(22)).or_insert_with(|| guard(22));
|
warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
--> fixtures/task/src/drops.rs:426:2
|
426 | drop(counts.entry(counted(20)).and_modify(|_| ()).or_insert(guard(23)));
| ^^^^^-----------------------------------------------------------------^
| |
| argument has type `&mut Guard`
|
help: use `let _ = ...` to ignore the expression or result
|
426 - drop(counts.entry(counted(20)).and_modify(|_| ()).or_insert(guard(23)));
426 + let _ = counts.entry(counted(20)).and_modify(|_| ()).or_insert(guard(23));
|
warning: for loop over an `Option`. This is more readably written as an `if let` statement
--> fixtures/task/src/drops/iters.rs:22:11
|
22 | for g in Some(guard(7)) {
| ^^^^^^^^^^^^^^
|
= note: `#[warn(for_loops_over_fallibles)]` on by default
help: to check pattern in a loop use `while let`
|
22 - for g in Some(guard(7)) {
22 + while let Some(g) = Some(guard(7)) {
|
help: consider using `if let` to clear intent
|
22 - for g in Some(guard(7)) {
22 + if let Some(g) = Some(guard(7)) {
|
test crates ... ok
warning: `task-fixture` (lib) generated 12 warnings (run `cargo fix --lib -p task-fixture` to apply 1 suggestion)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 49.87s
Compiling share-fixture v0.0.0 (/work/ts/fixtures/share)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 49.38s
Compiling share-fixture v0.0.0 (/work/ts/fixtures/share)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.27s
Compiling share-fixture v0.0.0 (/work/ts/fixtures/share)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.24s
test share ... ok
test task ... ok
test stable_names ... ok
test lang ... ok
failures:
---- reject stdout ----
thread 'reject' (19665) panicked at tests/fixtures.rs:553:5:
the errors differ; rerun with UPDATE_EXPECT=1
- 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
+ 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:2154: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:2160:4
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
reject
test result: FAILED. 11 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 474.65s
error: test failed, to rerun pass `--test fixtures`
error: recipe `test` failed on line 31 with exit code 101
error: recipe `test` failed on line 42 with exit code 101
error: recipe `ci` failed on line 37 with exit code 101
. |
Contributor
|
codex / Codex land fixer: (written by codex / Codex) |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
enabled auto-merge (squash)
November 1, 2026 07:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The last methods of quest/m2/ts-shared.md were refused:
Clone,Debug,get_mut, andget_or_try_initofOnceCellandOnceLock, andClone,get_mut,into_inner,try_borrow,Ref::map, andRef::cloneofRefCellandRwLock. Reproduced first by the new fixture cases, which failed translation with 148 refusals such asunsupported call to std::cell::Ref::<'_, T>::mapand`RwLock::get_mut` with a mutable reference to a value JS copies.Approach
get_mutlends the cell itself, already a place of itsOption, throughrt.optionAsMutwhere JS copies the value;get_or_try_initisget_or_initwhose error leaves the cell empty, before aOnceCellset from within would panicreentrant init;Cloneclones what it holds into the same class;DebugwritesOnceCell(<uninit>)as std does.RefCell:try_borrowandtry_borrow_mutgivert.BorrowErrorandrt.BorrowMutError, with std'sDebugandDisplay;Cloneborrows the cell while cloning, so it panics while mutably borrowed;Ref::clonecounts another borrow;Ref::mapmakes anrt.RefMap, aRefof the part it lends that counts its borrow in its cell, sorefReleasereleases the cell's.Arc, aWeak, a waker, or one of these cells is that reference: the stdClonearms now take only an owned receiver. TheArcandWeakarms already counted a strong reference for<&Arc<T>>::clone, as in a genericT: Clonegiven&Arc.get_mutandinto_innerofMutex,RefCell, andRwLock: the value, orrt.valuePlaceof the holder where JS copies it (whatArc::get_mutalready did, now shared).borrows::guardscase and extendedcells,locks, andrwlocks, with named scripts for every panic (RefCell already mutably borrowed,RefCell already borrowed,reentrant init,one-time initialization may not be performed recursively) and drop timing logged for clones andinto_inner.Model census (
ts/moq/model.toml, moq at the pin): 365 refusals before, 363 after. The two removed are moq'sContent::drop,Mutex::get_mutof anOption(model/group/content.rs:211and:216); none added.Choices made without asking, for review:
RwLockhas noClone,try_borrow,Ref::map, orRef::clonein std; its share of the list isget_mutandinto_inner.try_borrow_mut,Mutex::get_mutof a value JS copies, andMutex::into_innerare included: each is the same refusal as one on the list.Impact
rtgainsRefMap,refMap,refClone,refCellClone,refCellTryBorrow,refCellTryBorrowMut,BorrowError,BorrowMutErrorand theirDebugandDisplay,valuePlace,onceGetOrTryInit,onceClone, andonceDebug. Additive; noMIGRATE.mdentry.once_cell_try. The reject fixture dropsmutex_number, which now translates.Alternatives
Refas{ cell, value }everywhere instead of theRefMapsubclass: allocates for every borrow to serve the raremap.rt.BorrowErrorasundefined: anOption<BorrowError>would then needrt.None.Follow-ups
RefMut::map, the guards'filter_mapandmap_split, and anRwLockguard'smap. A mappedRefMutlends a place, whichRefMap's copy can't be.Review
mechanical fix by codex / Codex:
Merged base and reconciled generated census totals, preserving both sides.(head 44f51fa)Codex (
quest review), gpt-6.1-sol, medium effort, head 7577774: no findings.Round 1 (head 7107284) findings:
ts/src/lower/task.rs: a clone of a&RefCell,&OnceCell, or&OnceLockmade a new cell. Fixed, withArc,Weak, andWakertoo, and covered by differential aliasing cases.ts/src/lower/mir/mod.rs:964: boxed scalar aliases removed. Refuted: main's fix(ts): a &mut into a Box is the place holding the box #369 landed after my merge, so the two-dot diff showed it reversed; the PR never touched the file.Head 85b9d91: review skipped as trivial. It merges
main(#369, #376) and regenerates the reject snapshots. The land fixer's merge (44f51fa) failed the batch check becausereject/mistyped.txtkept line numbers from before this PR removed themutex_numbercase; this head's tree is the regenerated merge 0e77b8f, on which localjust cipassed.🤖 Generated with Claude Code