Skip to content
Open
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
11 changes: 11 additions & 0 deletions kmir/src/kmir/kdist/mir-semantics/rt/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,17 @@ This is done without consideration of the validity of the Downcast[^downcast].
[^downcast]: See discussion in https://github.com/rust-lang/rust/issues/93688#issuecomment-1032929496.

```k
// fast elimination: SingletonArray + Field(0) + ConstantIndex(0) on a single-element Aggregate
rule <k> #traverseProjection(
DEST,
Aggregate(IDX, ARGS),
projectionElemSingletonArray projectionElemField(fieldIdx(0), TY) projectionElemConstantIndex(0, 0, false) PROJS,
CTXTS
)
=> #traverseProjection(DEST, Aggregate(IDX, ARGS), projectionElemField(fieldIdx(0), TY) PROJS, CTXTS) ... </k>
requires size(ARGS) ==Int 1
[preserves-definedness]

rule <k> #traverseProjection(
DEST,
Aggregate(IDX, ARGS),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#![allow(invalid_reference_casting)]

fn main() {
let _keep: fn(&AccountInfo<'_>, Pubkey) = repro;
}

#[inline(never)]
#[no_mangle]
pub fn repro(account: &AccountInfo<'_>, replacement: Pubkey) {
account.assign(replacement);
assert_eq!(*account.owner, replacement);
}

struct AccountInfo<'a> {
owner: &'a Pubkey,
}

impl<'a> AccountInfo<'a> {
#[inline(never)]
fn assign(&self, new_owner: Pubkey) {
unsafe {
std::ptr::write_volatile(
self.owner as *const Pubkey as *mut [u8; 32],
new_owner.to_bytes(),
);
}
}
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
struct Pubkey([u8; 32]);

impl Pubkey {
fn to_bytes(self) -> [u8; 32] {
self.0
}
}
1 change: 1 addition & 0 deletions kmir/src/tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
'test_offset_from-fail': ['testing'],
'iter-eq-copied-take-dereftruncate': ['repro'],
'spl-multisig-iter-eq-copied-next': ['repro'],
'write_volatile_pubkey_array': ['repro'],
}
PROVE_SHOW_SPECS = [
'local-raw-fail',
Expand Down
Loading