fix mdbook test
This commit is contained in:
parent
b32b9ae934
commit
53b84f92f4
|
|
@ -88,7 +88,7 @@ have to compute `Values(R1) = Values(R1) union Values(R2)`.
|
||||||
One observation that follows from this is that if you have `R1: R2`
|
One observation that follows from this is that if you have `R1: R2`
|
||||||
and `R2: R1`, then `R1 = R2` must be true. Similarly, if you have:
|
and `R2: R1`, then `R1 = R2` must be true. Similarly, if you have:
|
||||||
|
|
||||||
```
|
```txt
|
||||||
R1: R2
|
R1: R2
|
||||||
R2: R3
|
R2: R3
|
||||||
R3: R4
|
R3: R4
|
||||||
|
|
@ -119,7 +119,7 @@ context.
|
||||||
When using a graph representation, we can detect regions that must be equal
|
When using a graph representation, we can detect regions that must be equal
|
||||||
by looking for cycles. That is, if you have a constraint like
|
by looking for cycles. That is, if you have a constraint like
|
||||||
|
|
||||||
```
|
```txt
|
||||||
'a: 'b
|
'a: 'b
|
||||||
'b: 'c
|
'b: 'c
|
||||||
'c: 'd
|
'c: 'd
|
||||||
|
|
@ -153,7 +153,7 @@ When we compute SCCs, we not only figure out which regions are a
|
||||||
member of each SCC, we also figure out the edges between them. So for example
|
member of each SCC, we also figure out the edges between them. So for example
|
||||||
consider this set of outlives constraints:
|
consider this set of outlives constraints:
|
||||||
|
|
||||||
```
|
```txt
|
||||||
'a: 'b
|
'a: 'b
|
||||||
'b: 'a
|
'b: 'a
|
||||||
|
|
||||||
|
|
@ -178,7 +178,7 @@ expressed in terms of regions -- that is, we have a map like
|
||||||
in terms of SCCs -- we can integrate these liveness constraints very
|
in terms of SCCs -- we can integrate these liveness constraints very
|
||||||
easily just by taking the union:
|
easily just by taking the union:
|
||||||
|
|
||||||
```
|
```txt
|
||||||
for each region R:
|
for each region R:
|
||||||
let S be the SCC that contains R
|
let S be the SCC that contains R
|
||||||
Values(S) = Values(S) union Liveness(R)
|
Values(S) = Values(S) union Liveness(R)
|
||||||
|
|
@ -195,7 +195,7 @@ the value of `S1`, we first compute the values of each successor `S2`.
|
||||||
Then we simply union all of those values together. To use a
|
Then we simply union all of those values together. To use a
|
||||||
quasi-iterator-like notation:
|
quasi-iterator-like notation:
|
||||||
|
|
||||||
```
|
```txt
|
||||||
Values(S1) =
|
Values(S1) =
|
||||||
s1.successors()
|
s1.successors()
|
||||||
.map(|s2| Values(s2))
|
.map(|s2| Values(s2))
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ derives from the fact that such lifetimes are "universally quantified"
|
||||||
lifetimes). It is worth spending a bit of discussing how lifetime
|
lifetimes). It is worth spending a bit of discussing how lifetime
|
||||||
parameters are handled during region inference. Consider this example:
|
parameters are handled during region inference. Consider this example:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 {
|
fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 {
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +92,7 @@ itself). In the code, these liveness constraints are setup in
|
||||||
|
|
||||||
So, consider the first example of this section:
|
So, consider the first example of this section:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 {
|
fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 {
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +102,7 @@ Here, returning `x` requires that `&'a u32 <: &'b u32`, which gives
|
||||||
rise to an outlives constraint `'a: 'b`. Combined with our default liveness
|
rise to an outlives constraint `'a: 'b`. Combined with our default liveness
|
||||||
constraints we get:
|
constraints we get:
|
||||||
|
|
||||||
```
|
```txt
|
||||||
'a live at {B, end('a)} // B represents the "function body"
|
'a live at {B, end('a)} // B represents the "function body"
|
||||||
'b live at {B, end('b)}
|
'b live at {B, end('b)}
|
||||||
'a: 'b
|
'a: 'b
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ some `i`). These constraints cannot be expressed by users, but they
|
||||||
arise from `impl Trait` due to its lifetime capture rules. Consider a
|
arise from `impl Trait` due to its lifetime capture rules. Consider a
|
||||||
function such as the following:
|
function such as the following:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
fn make(a: &'a u32, b: &'b u32) -> impl Trait<'a, 'b> { .. }
|
fn make(a: &'a u32, b: &'b u32) -> impl Trait<'a, 'b> { .. }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@ permitted to capture the lifetimes `'a` or `'b`. You can kind of see
|
||||||
this more clearly by desugaring that `impl Trait` return type into its
|
this more clearly by desugaring that `impl Trait` return type into its
|
||||||
more explicit form:
|
more explicit form:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
type MakeReturn<'x, 'y> = impl Trait<'x, 'y>;
|
type MakeReturn<'x, 'y> = impl Trait<'x, 'y>;
|
||||||
fn make(a: &'a u32, b: &'b u32) -> MakeReturn<'a, 'b> { .. }
|
fn make(a: &'a u32, b: &'b u32) -> MakeReturn<'a, 'b> { .. }
|
||||||
```
|
```
|
||||||
|
|
@ -34,14 +34,14 @@ To help us explain member constraints in more detail, let's spell out
|
||||||
the `make` example in a bit more detail. First off, let's assume that
|
the `make` example in a bit more detail. First off, let's assume that
|
||||||
you have some dummy trait:
|
you have some dummy trait:
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
trait Trait<'a, 'b> { }
|
trait Trait<'a, 'b> { }
|
||||||
impl<T> Trait<'_, '_> for T { }
|
impl<T> Trait<'_, '_> for T { }
|
||||||
```
|
```
|
||||||
|
|
||||||
and this is the `make` function (in desugared form):
|
and this is the `make` function (in desugared form):
|
||||||
|
|
||||||
```rust
|
```rust,ignore
|
||||||
type MakeReturn<'x, 'y> = impl Trait<'x, 'y>;
|
type MakeReturn<'x, 'y> = impl Trait<'x, 'y>;
|
||||||
fn make(a: &'a u32, b: &'b u32) -> MakeReturn<'a, 'b> {
|
fn make(a: &'a u32, b: &'b u32) -> MakeReturn<'a, 'b> {
|
||||||
(a, b)
|
(a, b)
|
||||||
|
|
@ -52,7 +52,7 @@ What happens in this case is that the return type will be `(&'0 u32, &'1 u32)`,
|
||||||
where `'0` and `'1` are fresh region variables. We will have the following
|
where `'0` and `'1` are fresh region variables. We will have the following
|
||||||
region constraints:
|
region constraints:
|
||||||
|
|
||||||
```
|
```txt
|
||||||
'0 live at {L}
|
'0 live at {L}
|
||||||
'1 live at {L}
|
'1 live at {L}
|
||||||
'a: '0
|
'a: '0
|
||||||
|
|
@ -73,7 +73,7 @@ u32)` -- the region variables reflect that the lifetimes of these
|
||||||
references could be made smaller. For this value to be created from
|
references could be made smaller. For this value to be created from
|
||||||
`a` and `b`, however, we do require that:
|
`a` and `b`, however, we do require that:
|
||||||
|
|
||||||
```
|
```txt
|
||||||
(&'a u32, &'b u32) <: (&'0 u32, &'1 u32)
|
(&'a u32, &'b u32) <: (&'0 u32, &'1 u32)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue