Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mem.rs:104 error: cannot borrow immutable dereference of & pointer as mutable #3

Closed
glycerine opened this issue Aug 31, 2013 · 1 comment

Comments

@glycerine
Copy link

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
    
@pcwalton
Copy link
Owner

pcwalton commented Sep 4, 2013

Should be fixed now.

@pcwalton pcwalton closed this as completed Sep 4, 2013
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

No branches or pull requests

2 participants