Skip to content

Commit

Permalink
Clean up trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
traviscross committed Jun 18, 2024
1 parent 3efb695 commit 519aeb6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions text/3467-unsafe-pinned.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl S {
pub fn new() -> Self {
S { data: 42, ptr_to_data: ptr::null_mut() }
}

pub fn get_data(self: Pin<&mut Self>) -> i32 {
// SAFETY: We're not moving anything.
let this = unsafe { Pin::get_unchecked_mut(self) };
Expand All @@ -46,7 +46,7 @@ impl S {
// SAFETY: if the pointer is non-null, then we are pinned and it points to the `data` field.
unsafe { this.ptr_to_data.read() }
}

pub fn set_data(self: Pin<&mut Self>, data: i32) {
// SAFETY: We're not moving anything.
let this = unsafe { Pin::get_unchecked_mut(self) };
Expand Down Expand Up @@ -147,7 +147,7 @@ fn main() {
</details>

<br>

Beyond self-referential types, a similar problem also comes up with intrusive linked lists: the nodes of such a list often live on the stack frames of the functions participating in the list, but also have incoming pointers from other list elements.
When a function takes a mutable reference to its stack-allocated node, that will alias the pointers from the neighboring elements.
[This](https://github.com/rust-lang/rust/issues/114581) is an example of an intrusive list in the standard library that is breaking Rust's aliasing rules.
Expand Down

0 comments on commit 519aeb6

Please sign in to comment.