Skip to content

Commit d63708b

Browse files
committed
Address code review comments on the comments
1 parent 2e1e119 commit d63708b

File tree

2 files changed

+33
-30
lines changed
  • compiler
    • rustc_borrowck/src/region_infer
    • rustc_data_structures/src/graph/scc

2 files changed

+33
-30
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

+29-29
Original file line numberDiff line numberDiff line change
@@ -492,35 +492,35 @@ impl<'tcx> RegionInferenceContext<'tcx> {
492492
/// This bit of logic also handles invalid universe relations
493493
/// for higher-kinded types.
494494
///
495-
// We Walk each SCC `A` and `B` such that `A: B`
496-
// and ensure that universe(A) can see universe(B).
497-
//
498-
// This serves to enforce the 'empty/placeholder' hierarchy
499-
// (described in more detail on `RegionKind`):
500-
//
501-
// ```
502-
// static -----+
503-
// | |
504-
// empty(U0) placeholder(U1)
505-
// | /
506-
// empty(U1)
507-
// ```
508-
//
509-
// In particular, imagine we have variables R0 in U0 and R1
510-
// created in U1, and constraints like this;
511-
//
512-
// ```
513-
// R1: !1 // R1 outlives the placeholder in U1
514-
// R1: R0 // R1 outlives R0
515-
// ```
516-
//
517-
// Here, we wish for R1 to be `'static`, because it
518-
// cannot outlive `placeholder(U1)` and `empty(U0)` any other way.
519-
//
520-
// Thanks to this loop, what happens is that the `R1: R0`
521-
// constraint has lowered the universe of `R1` to `U0`, which in turn
522-
// means that the `R1: !1` constraint here will cause
523-
// `R1` to become `'static`.
495+
/// We Walk each SCC `A` and `B` such that `A: B`
496+
/// and ensure that universe(A) can see universe(B).
497+
///
498+
/// This serves to enforce the 'empty/placeholder' hierarchy
499+
/// (described in more detail on `RegionKind`):
500+
///
501+
/// ```ignore (illustrative)
502+
/// static -----+
503+
/// | |
504+
/// empty(U0) placeholder(U1)
505+
/// | /
506+
/// empty(U1)
507+
/// ```
508+
///
509+
/// In particular, imagine we have variables R0 in U0 and R1
510+
/// created in U1, and constraints like this;
511+
///
512+
/// ```ignore (illustrative)
513+
/// R1: !1 // R1 outlives the placeholder in U1
514+
/// R1: R0 // R1 outlives R0
515+
/// ```
516+
///
517+
/// Here, we wish for R1 to be `'static`, because it
518+
/// cannot outlive `placeholder(U1)` and `empty(U0)` any other way.
519+
///
520+
/// Thanks to this loop, what happens is that the `R1: R0`
521+
/// constraint has lowered the universe of `R1` to `U0`, which in turn
522+
/// means that the `R1: !1` constraint here will cause
523+
/// `R1` to become `'static`.
524524
fn init_free_and_bound_regions(&mut self) {
525525
// Update the names (if any)
526526
// This iterator has unstable order but we collect it all into an IndexVec

compiler/rustc_data_structures/src/graph/scc/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ struct SccDetails<A: Annotation> {
8080

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

0 commit comments

Comments
 (0)