diff options
| author | bors <bors@rust-lang.org> | 2024-05-04 09:52:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-04 09:52:39 +0000 |
| commit | 7b57f122b93f3eb37b6dd8db2fc1bf2ae621c393 (patch) | |
| tree | a23f8cf9fe432bafd6cea2c6da5c31e036b839cc /compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp | |
| parent | 705d48cff9b18daaf506297b05ae8c2e4577411b (diff) | |
| parent | 459c6ce944ccef19f5da60d8ee1fbdccf685e2b3 (diff) | |
| download | rust-7b57f122b93f3eb37b6dd8db2fc1bf2ae621c393.tar.gz rust-7b57f122b93f3eb37b6dd8db2fc1bf2ae621c393.zip | |
Auto merge of #3533 - Luv-Ray:file-descriptors-to-refcount-references, r=RalfJung
Make file descriptors into refcount references
fixes #3525
Remove `fn dup` in `trait FileDescription`, define `struct FileDescriptor(Rc<RefCell<dyn FileDescription>>)`, and use `BTreeMap<i32, FileDescriptor>` in `FdTable`.
---
There are some refactors similar to the following form:
```rust
{ // origin:
if let Some(file_descriptor) = this.machine.fds.get_mut(fd) {
// write file_descriptor
this.try_unwrap_io_result(result)
} else {
this.fd_not_found()
}
}
{ // now:
let Some(mut file_descriptor) = this.machine.fds.get_mut(fd) else {
return this.fd_not_found();
};
// write file_descriptor
drop(file_descriptor);
this.try_unwrap_io_result(result)
}
```
The origin form can't compile because as using `RefCell` to get interior mutability, `fn get_mut` return `Option<std::cell::RefMut<'_, dyn FileDescription>>` instead of `Option<&mut dyn FileDescription>` now, and the `deref_mut` on `file_descriptor: RefMut` will cause borrow `this` as mutable more than once at a time.
So this form of refactors and manual drops are are implemented to avoid borrowing `this` at the same time.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
