Skip to content

Commit 9c913f6

Browse files
authored
rust: Don't require mutability for P64ToP cast (#891)
Arguments to functions aren't declared as mutable so use a method that only needs `&self` which avoids the need to declare tyeps as mutable. Closes #890
1 parent 52d0b3d commit 9c913f6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

crates/rust/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ fn perform_cast(operand: &str, cast: &Bitcast) -> String {
13571357
// Convert a `MaybeUninit<u64>` holding a pointer value back into
13581358
// the pointer value.
13591359
Bitcast::P64ToP => {
1360-
format!("{}.as_mut_ptr().cast::<*mut u8>().read()", operand)
1360+
format!("{}.as_ptr().cast::<*mut u8>().read()", operand)
13611361
}
13621362
// Convert an `i32` or a `usize` into a pointer.
13631363
Bitcast::I32ToP | Bitcast::LToP => {

tests/codegen/variants-unioning-types.wit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,10 @@ world a {
9292
b(f32),
9393
}
9494
import f-s64-f32: func(x: v-s64-f32);
95+
96+
variant v-string-u64 {
97+
a(string),
98+
b(u64),
99+
}
100+
export f-string-u64: func(x: v-string-u64);
95101
}

0 commit comments

Comments
 (0)