You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add CodeExtent::Remainder variant to track a suffix of a block.
Added DestructionScope variant to CodeExtent, representing the area
immediately surrounding a node that is a terminating_scope
(e.g. statements, looping forms) during which the destructors run (the
destructors for temporaries from the execution of that node, that is).
insert DestructionScope and block Remainder into enclosing CodeExtents hierarchy.
Switch to constructing DestructionScope rather than Misc in a number
of places, mostly related to `ty::ReFree` creation, and use
destruction-scopes of node-ids at various calls to
liberate_late_bound_regions.
middle::resolve_lifetime: Map BlockScope to DestructionScope in `fn resolve_free_lifetime`.
add the InnermostDeclaringBlock and InnermostEnclosingExpr enums that
are my attempt to clarify the region::Context structure, and that
later commmts build upon.
Expanded region-inference graph with enclosing relationship as well as
the constraint edges.
improve the debug output for `CodeExtent` attached to `ty::Region::ReScope`.
loosened an assertion in `rustc_trans::trans::cleanup` to account for
`DestructionScope`. (Perhaps this should just be switched entirely
over to `DestructionScope`, rather than allowing for either `Misc` or
`DestructionScope`.)
----
The more fine-grained scopes introduced by this change break some code. A simple
example can be seen in libregex/vm.rs, where two references `clist` and `nlist`
need to have the same lifetime lead to this code breaking:
```rust
let mut clist = &mut Threads::new(self.which, ninsts, ncaps);
let mut nlist = &mut Threads::new(self.which, ninsts, ncaps);
...
mem::swap(&mut clist, &mut nlist);
```
The reason for the breakage is that the thread-value associated with
`nlist` has a strictly shorter lifetime than the `&mut`-reference for
`clist`, but the code in question needs both `clist` and `list` to be
assigned compatible lifetimes. The usual fix is to revise the code as
follows, moving *both* of the thread values up above the creation of
the `&mut`-references, like so:
```rust
let mut cthread = Threads::new(self.which, ninsts, ncaps);
let mut nthread = Threads::new(self.which, ninsts, ncaps);
let mut clist = &mut cthread;
let mut nlist = &mut nthread;
...
mem::swap(&mut clist, &mut nlist);
```
Likewise, there are other cases where the value needs to have a
strictly greater lifetime than the reference taken to that value, and
the typical solution is to create the value and bind it to a name in
statement preceding the creation of the reference.
----
Due to these (relatively rare) instances, this is a (wait for it)
[breaking-change]
0 commit comments