Skip to content

Commit 1ba24cb

Browse files
committed
Fix #114: Rust 2024 compatibility
1 parent 104c483 commit 1ba24cb

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎cpp2rust/converter/converter.cpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ Converter::MaterializeTemp(const std::string &binding_name,
284284

285285
auto binding =
286286
std::format("{} mut {} : {} = {};", decl, binding_name, type_str, value);
287-
auto ref = std::format("& mut {}", binding_name);
287+
auto ref = in_const_initializer_
288+
? std::format("& mut *& raw mut {}", binding_name)
289+
: std::format("& mut {}", binding_name);
288290
return {binding, ref};
289291
}
290292

‎tests/lit/lit/formats/Cpp2RustTest.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@ def build_rust(self):
247247
"strip=symbols",
248248
"-C",
249249
"panic=abort",
250-
"-W", ## TODO: remove this once we fix the errors in the generated code
251-
"static_mut_refs",
252250
"--out-dir",
253251
str(self.tmp_dir),
254252
"-L",

‎tests/unit/out/unsafe/rvalue_ref_global.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
88
use std::rc::Rc;
99
static mut __tmp_0: i32 = 5;
1010
pub static mut g_0: std::cell::LazyCell<*mut i32> =
11-
std::cell::LazyCell::new(|| unsafe { &mut __tmp_0 });
11+
std::cell::LazyCell::new(|| unsafe { &mut *&raw mut __tmp_0 });
1212
pub fn main() {
1313
unsafe {
1414
__cpp2rust_init_globals();

0 commit comments

Comments
 (0)