Skip to content

Commit d28f052

Browse files
committed
fix markdown quirks
1 parent f0b49f0 commit d28f052

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

text/0000-maybe-dangling.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Sometimes one has to work with references or boxes that either are already deall
1919
This comes up particularly often with `ManuallyDrop`.
2020
For example, the following code is UB at the time of writing this RFC:
2121

22-
```rust=
22+
```rust
2323
fn id<T>(x: T) -> T { x }
2424

2525
fn unsound(x: Box<i32>)
@@ -40,7 +40,7 @@ There exist more complex versions of this problem, relating to a subtle aspect o
4040
when a reference is passed to a function as an argument (including nested in a struct), then that reference must remain live throughout the function.
4141
(In LLVM terms: we are annotating that reference with `dereferenceable`, which means "dereferenceable for the entire duration of this function call"). In [issue #101983](https://github.com/rust-lang/rust/issues/101983), this leads to a bug in `scoped_thread`.
4242
There we have a function that invokes a user-supplied `impl FnOnce` closure, roughly like this:
43-
```rust=
43+
```rust
4444
// Not showing all the `'lifetime` tracking, the point is that
4545
// this closure might live shorter than `thread`.
4646
fn thread(control: ..., closure: impl FnOnce() + 'lifetime) {
@@ -64,7 +64,7 @@ However, note that `thread` continues to run even after `signal_done`! Now consi
6464

6565
As a third example, consider a type that wants to store a "pointer together with some data borrowed from that pointer", like the `owning_ref` crate. This will usually boil down to something like this:
6666

67-
```rust=
67+
```rust
6868
unsafe trait StableDeref: Deref {}
6969

7070
struct OwningRef<U, T: StableDeref<Target=U>> {
@@ -98,7 +98,7 @@ This means that the first example is actually fine:
9898
the dangling `Box` was passed inside a `ManuallyDrop`, so there is no UB.
9999

100100
The 2nd example can be fixed by passing the closure in a `MaybeDangling`:
101-
```rust=
101+
```rust
102102
// Argument is passed as `MaybeDangling` since we might actually keep
103103
// it around after its lifetime ends (at which point the caller can
104104
// start dropping memory it points to).
@@ -111,7 +111,7 @@ fn thread(control: ..., closure: MaybeDangling<impl FnOnce() + 'lifetime>) {
111111

112112
The 3rd example can be fixed by storing the `buffer` inside a `MaybeDangling`, which disables its aliasing requirements:
113113

114-
```rust=
114+
```rust
115115
struct OwningRef<U, T: StableDeref<Target=U>> {
116116
buffer: MaybeDangling<T>,
117117
ref_: NonNull<U>, // conceptually borrows from `buffer`.

0 commit comments

Comments
 (0)