about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-02-23 09:25:30 +0100
committerGitHub <noreply@github.com>2019-02-23 09:25:30 +0100
commit8ccda2438ea093291501d59ef24ddd8936e1dc16 (patch)
tree94a336216a4151d4868fcb23dc9cd5f423da0f97 /src/liballoc
parent73e661a0a5acf98ae932cceca00212578aeeea33 (diff)
parente5d1fa58f2dd5e86dd91f370313a4be85a39917a (diff)
downloadrust-8ccda2438ea093291501d59ef24ddd8936e1dc16.tar.gz
rust-8ccda2438ea093291501d59ef24ddd8936e1dc16.zip
Rollup merge of #58609 - gabi-250:mutable-refs, r=oli-obk
Allow Self::Module to be mutated.

This only changes `&Self::Module` to `&mut Self::Module` in a couple of places.

`codegen_allocator` and `write_metadata` from `ExtraBackendMethods` mutate the underlying LLVM module. As such, it makes sense for these two functions to receive a mutable reference to the module (as opposed to an immutable one).

I am trying to implement `codegen_allocator` for my backend, and I need to be able to mutate `Self::Module`:
https://github.com/rust-lang/rust/blob/f66e4697ae286985ddefc53c3a047614568458bb/src/librustc_codegen_ssa/traits/backend.rs#L41
Modifying the module in `codegen_allocator`/`write_metadata` is not a problem for the LLVM backend, because [ModuleLlvm](https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/lib.rs#L357) contains a raw pointer to the underlying LLVM module, so it can easily be mutated through FFI calls.

I am trying to avoid interior mutability and `unsafe` as much as I can. What do you think? Does this change make sense, or is there a reason why this should stay the way it is?
Diffstat (limited to 'src/liballoc')
0 files changed, 0 insertions, 0 deletions