mem.rs:104 error: cannot borrow immutable dereference of & pointer as mutable
glycerine opened this issue · 1 comments
Trying to learn Rust by studying this codebase. It doesn't compile with the latest rustc, and I'm a so new to the language that I don't know how to fix this:
/rust/sprocketnes$ make
rustc --cfg ndebug --cfg ncpuspew -O -L . nes.rc -o nes || echo ""If this build failed due to missing SDL bindings, please install the
m from https://github.com/brson/rust-sdl and copy the .dll/.dylib/.so into this directory or use RUSTLDFLAGS.""
mem.rs:104:16: 104:22 error: cannot borrow immutable dereference of & pointer as mutable
mem.rs:104 mapper.prg_loadb(addr)
^~~~~~
mem.rs:122:16: 122:22 error: cannot borrow immutable dereference of & pointer as mutable
mem.rs:122 mapper.prg_storeb(addr, val)
^~~~~~
ppu.rs:181:16: 181:22 error: cannot borrow immutable dereference of & pointer as mutable
ppu.rs:181 mapper.chr_loadb(addr)
^~~~~~
ppu.rs:195:16: 195:22 error: cannot borrow immutable dereference of & pointer as mutable
ppu.rs:195 mapper.chr_storeb(addr, val)
^~~~~~
ppu.rs:773:19: 773:25 error: cannot borrow immutable dereference of & pointer as mutable
ppu.rs:773 if mapper.next_scanline() == Irq {
^~~~~~
error: aborting due to 5 previous errors
If this build failed due to missing SDL bindings, please install them from https://github.com/brson/rust-sdl and copy the .dll/.dylib/
.so into this directory or use RUSTLDFLAGS.
/rust/sprocketnes$ rustc --version
rustc 0.8-pre (bb35e23 2013-08-30 21:40:32 -0700)
host: x86_64-unknown-linux-gnu
I did fix a one earlier compile error as follows:
/rust/sprocketnes$ git branch -v
- master 8b6fcfa Update for language changes and go runtimeless!
/rust/sprocketnes$ git diff
diff --git a/util.rs b/util.rs^[[m
index ac46941..dece364 100644^[[m
--- a/util.rs^[[m
+++ b/util.rs^[[m
@@ -10,6 +10,7 @@ use std::libc::time_t;^[[m
use std::libc;^[[m
use std::ptr::null;^[[m
use std::uint;^[[m
+use std::c_str::ToCStr;^[[m
^[[m
//^[[m
// Standard library I/O replacements^[[m
@@ -37,7 +38,7 @@ impl Fd {^[[m
ForReading => O_RDONLY,^[[m
ForWriting => O_WRONLY | O_CREAT | O_TRUNC^[[m
} as c_int;^[[m
-
do path.as_c_str |c_path| {^[[m
-
do path.to_c_str().with_ref |c_path| {^[[m Fd {^[[m contents: libc::open(c_path, fd_mode, 493),^[[m }^[[m
Should be fixed now.