Skip to content

Commit

Permalink
Address code review comments on the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
amandasystems committed Jun 12, 2024
1 parent 2e1e119 commit d63708b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 30 deletions.
58 changes: 29 additions & 29 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,35 +492,35 @@ impl<'tcx> RegionInferenceContext<'tcx> {
/// This bit of logic also handles invalid universe relations
/// for higher-kinded types.
///
// We Walk each SCC `A` and `B` such that `A: B`
// and ensure that universe(A) can see universe(B).
//
// This serves to enforce the 'empty/placeholder' hierarchy
// (described in more detail on `RegionKind`):
//
// ```
// static -----+
// | |
// empty(U0) placeholder(U1)
// | /
// empty(U1)
// ```
//
// In particular, imagine we have variables R0 in U0 and R1
// created in U1, and constraints like this;
//
// ```
// R1: !1 // R1 outlives the placeholder in U1
// R1: R0 // R1 outlives R0
// ```
//
// Here, we wish for R1 to be `'static`, because it
// cannot outlive `placeholder(U1)` and `empty(U0)` any other way.
//
// Thanks to this loop, what happens is that the `R1: R0`
// constraint has lowered the universe of `R1` to `U0`, which in turn
// means that the `R1: !1` constraint here will cause
// `R1` to become `'static`.
/// We Walk each SCC `A` and `B` such that `A: B`
/// and ensure that universe(A) can see universe(B).
///
/// This serves to enforce the 'empty/placeholder' hierarchy
/// (described in more detail on `RegionKind`):
///
/// ```ignore (illustrative)
/// static -----+
/// | |
/// empty(U0) placeholder(U1)
/// | /
/// empty(U1)
/// ```
///
/// In particular, imagine we have variables R0 in U0 and R1
/// created in U1, and constraints like this;
///
/// ```ignore (illustrative)
/// R1: !1 // R1 outlives the placeholder in U1
/// R1: R0 // R1 outlives R0
/// ```
///
/// Here, we wish for R1 to be `'static`, because it
/// cannot outlive `placeholder(U1)` and `empty(U0)` any other way.
///
/// Thanks to this loop, what happens is that the `R1: R0`
/// constraint has lowered the universe of `R1` to `U0`, which in turn
/// means that the `R1: !1` constraint here will cause
/// `R1` to become `'static`.
fn init_free_and_bound_regions(&mut self) {
// Update the names (if any)
// This iterator has unstable order but we collect it all into an IndexVec
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_data_structures/src/graph/scc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ struct SccDetails<A: Annotation> {

// The name of this struct should discourage you from making it public and leaking
// its representation. This message was left here by one who came before you,
// who learnt the hard way that making even small changes in representation is difficult when it's publicly inspectable. Obey the law of Demeter!
// who learnt the hard way that making even small changes in representation
// is difficult when it's publicly inspectable.
//
// Obey the law of Demeter!
struct SccData<S: Idx, A: Annotation> {
/// Maps SCC indices to their metadata, including
/// offsets into `all_successors`.
Expand Down

0 comments on commit d63708b

Please sign in to comment.