Skip to content

Bump rustc to remove ShallowInitBox#1033

Open
N1ark wants to merge 4 commits intoAeneasVerif:mainfrom
soteria-tools:bump-rustc-boxes
Open

Bump rustc to remove ShallowInitBox#1033
N1ark wants to merge 4 commits intoAeneasVerif:mainfrom
soteria-tools:bump-rustc-boxes

Conversation

@N1ark
Copy link
Copy Markdown
Contributor

@N1ark N1ark commented Feb 24, 2026

Continuation of #1030
Fixes #973
Related to rust-lang/rust#148190

Added a transformation pass to make vec! safe. For the following original MIR:

((((*_4)).1).0).0 = [move _5]
storage_dead(_5)
_3 = move _4
conditional_drop[{impl Destruct for alloc::boxed::Box<T>[@TraitClause0, @TraitClause1]}<MaybeUninit<[u8; 1 : usize]>[{built_in impl Sized for [u8; 1 : usize]}], Global>[{built_in impl MetaSized for MaybeUninit<[u8; 1 : usize]>[{built_in impl Sized for [u8; 1 : usize]}]}, {built_in impl Sized for Global}]] _4
storage_dead(_4)
vec_2 = box_assume_init_into_vec_unsafe<u8, 1 : usize>[{built_in impl Sized for u8}](move _3)

we want something akin to

_T = [move _5]
_3 = Box::write(move _4, move _T)
_B = unsize<Box<[T; N]>, Box<[T]>>(move _3)
vec_2 = std::slice::{impl}::into_vec(move _B)

@N1ark N1ark force-pushed the bump-rustc-boxes branch from 23c1721 to f1141c7 Compare April 10, 2026 00:28
@N1ark N1ark marked this pull request as ready for review April 10, 2026 12:24
@N1ark
Copy link
Copy Markdown
Contributor Author

N1ark commented Apr 10, 2026

@Nadrieril ready for review :D
fyi i added builtin functions rather than actual function calls for Box::write and Box::into_vec, because by the time the pass runs the TyCtx is lost so we can't retrieve them. Either way I think it makes sense given the other builtin functions (cough cough BoxNew)

@N1ark N1ark force-pushed the bump-rustc-boxes branch from 8b64f36 to af64464 Compare April 10, 2026 12:29
Comment on lines +431 to +436
/// Used instead of `alloc::boxed::Box::write` when rewriting `vec!` lowering.
/// Writes into a `Box<MaybeUninit<T>>` and returns a `Box<T>`.
BoxWrite,
/// Used instead of `alloc::slice::into_vec` when rewriting `vec!` lowering.
/// Takes a `Box<[T]>` and returns a `Vec<T>`.
SliceIntoVec,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to use the actual std functions, is that doable? I'm thinking that when we encounter a call to box_assume_init_into_vec_unsafe during translation we can trigger translation of these two, so that the reconstruction pass can find them later (or even maybe we can directly transform during translation, whichever easiest)

@@ -1,5 +1,5 @@

thread 'rustc' panicked at /nix/store/1nbfrsmfmhmhq75gkxk9nik63sq798g5-rust-default-1.95.0-nightly-2026-02-07/lib/rustlib/rustc-src/rust/compiler/rustc_hir/src/def.rs:823:45:
thread 'rustc' panicked at /Users/opale/.rustup/toolchains/nightly-2026-02-22-aarch64-apple-darwin/lib/rustlib/rustc-src/rust/compiler/rustc_hir/src/def.rs:823:45:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh I don't know why our normal path normalization didn't work here, plz just mark this test as //@ no-check-output

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just manually fixed, will do it next time :P

@Nadrieril
Copy link
Copy Markdown
Member

(I really want to get rid of BoxNew, it's an artefact of a time long past ^^)

@N1ark N1ark force-pushed the bump-rustc-boxes branch from cc5ca80 to a315830 Compare April 10, 2026 12:35
@N1ark
Copy link
Copy Markdown
Contributor Author

N1ark commented Apr 16, 2026

@Nadrieril is it ok to leave this as is for now so we can keep bumping the toolchain, and we eventually get rid of all the builtin functions later? ill go through the issues for this PR dw; this is partly because @joshlf is opening a PR to have some sort of automatic toolchain bumper in CI (since often the toolchain bump doesn't cause any breakage)

@Nadrieril
Copy link
Copy Markdown
Member

Nadrieril commented Apr 17, 2026

yes do leave the builtins like this we can make it better later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Incorrect reconstruction of vec!

2 participants