Struct rustc_mir::borrow_check::nll::region_infer::RegionInferenceContext[][src]

pub struct RegionInferenceContext<'tcx> {
    definitions: IndexVec<RegionVid, RegionDefinition<'tcx>>,
    liveness_constraints: LivenessValues<RegionVid>,
    constraints: Rc<ConstraintSet>,
    constraint_graph: Rc<ConstraintGraph>,
    constraint_sccs: Rc<Sccs<RegionVid, ConstraintSccIndex>>,
    scc_universes: IndexVec<ConstraintSccIndex, UniverseIndex>,
    scc_values: RegionValues<ConstraintSccIndex>,
    type_tests: Vec<TypeTest<'tcx>>,
    universal_regions: Rc<UniversalRegions<'tcx>>,
    universal_region_relations: Rc<UniversalRegionRelations<'tcx>>,
}
🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Fields

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Contains the definition for every region variable. Region variables are identified by their index (RegionVid). The definition contains information about where the region came from as well as its final inferred value.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

The liveness constraints added to each region. For most regions, these start out empty and steadily grow, though for each universally quantified region R they start out containing the entire CFG and end(R).

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

The outlives constraints computed by the type-check.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

The constraint-set, but in graph form, making it easy to traverse the constraints adjacent to a particular region. Used to construct the SCC (see constraint_sccs) and for error reporting.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

The SCC computed from constraints and the constraint graph. Used to compute the values of each region.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Contains the minimum universe of any variable within the same SCC. We will ensure that no SCC contains values that are not visible from this index.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

The final inferred values of the region variables; we compute one value per SCC. To get the value for any given region, you first find which scc it is a part of.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Type constraints that we check after solving.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Information about the universally quantified regions in scope on this function.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Information about how the universally quantified regions in scope on this function relate to one another.

Methods

impl<'tcx> RegionInferenceContext<'tcx>
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Write out our state into the .mir files.

impl<'tcx> RegionInferenceContext<'tcx>
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Write out our state into the .mir files.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Debugging aid: Invokes the with_msg callback repeatedly with our internal region constraints. These are dumped into the -Zdump-mir file so that we can figure out why the region inference resulted in the values that it did when debugging.

impl<'tcx> RegionInferenceContext<'tcx>
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Maps from an internal MIR region vid to something that we can report to the user. In some cases, the region vids will map directly to lifetimes that the user has a name for (e.g., 'static). But frequently they will not, in which case we have to find some way to identify the lifetime to the user. To that end, this function takes a "diagnostic" so that it can create auxiliary notes as needed.

Example (function arguments):

Suppose we are trying to give a name to the lifetime of the reference x:

fn foo(x: &u32) { .. }

This function would create a label like this:

 | fn foo(x: &u32) { .. }
          ------- fully elaborated type of `x` is `&'1 u32`

and then return the name '1 for us to use.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Check for the case where fr maps to something that the user has a name for. In that case, we'll be able to map fr to a Region<'tcx>, and that region will be one of named variants.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Find an argument that contains fr and label it with a fully elaborated type, returning something like '1. Result looks like:

 | fn foo(x: &u32) { .. }
          ------- fully elaborated type of `x` is `&'1 u32`

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Attempts to highlight the specific part of a type in an argument that has no type annotation. For example, we might produce an annotation like this:

 |     foo(|a, b| b)
 |          -  -
 |          |  |
 |          |  has type `&'1 u32`
 |          has type `&'2 u32`

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Attempts to highlight the specific part of a type annotation that contains the anonymous reference we want to give a name to. For example, we might produce an annotation like this:

 | fn a(items: &[T]) -> Box> {
 |                - let's call the lifetime of this reference `'1`

the way this works is that we match up argument_ty, which is a Ty<'tcx> (the internal form of the type) with argument_hir_ty, a hir::Ty (the syntax of the type annotation). We are descending through the types stepwise, looking in to find the region needle_fr in the internal type. Once we find that, we can use the span of the hir::Ty to add the highlight.

This is a somewhat imperfect process, so long the way we also keep track of the closest type we've found. If we fail to find the exact & or '_ to highlight, then we may fall back to highlighting that closest type instead.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

We've found an enum/struct/union type with the substitutions substs and -- in the HIR -- a path type with the final segment last_segment. Try to find a '_ to highlight in the generic args (or, if not, to produce new zipped pairs of types+hir to search through).

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

We've found an enum/struct/union type with the substitutions substs and -- in the HIR -- a path with the generic arguments args. If needle_fr appears in the args, return the hir::Lifetime that corresponds to it. If not, push onto search_stack the types+hir to search through.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Find a closure upvar that contains fr and label it with a fully elaborated type, returning something like '1. Result looks like:

 | let x = Some(&22);
       - fully elaborated type of `x` is `Option<&'1 u32>`

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Check for arguments appearing in the (closure) return type. It must be a closure since, in a free fn, such an argument would have to either also appear in an argument (if using elision) or be early bound (named, not in argument).

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Create a synthetic region named '1, incrementing the counter.

impl<'tcx> RegionInferenceContext<'tcx>
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Search the upvars (if any) to find one that references fr. Return its index.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Given the index of an upvar, finds its name and the span from where it was declared.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Search the argument types for one that references fr (which should be a free region). Returns Some(_) with the index of the input if one is found.

NB: In the case of a closure, the index is indexing into the signature as seen by the user - in particular, index 0 is not the implicit self parameter.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Given the index of an argument, finds its name (if any) and the span from where it was declared.

impl<'tcx> RegionInferenceContext<'tcx>
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Tries to find the best constraint to blame for the fact that R: from_region, where R is some region that meets target_test. This works by following the constraint graph, creating a constraint path that forces R to outlive from_region, and then finding the best choices within that path to blame.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Walks the graph of constraints (where 'a: 'b is considered an edge 'a -> 'b) to find all paths from from_region to to_region. The paths are accumulated into the vector results. The paths are stored as a series of ConstraintIndex values -- in other words, a list of edges.

Returns: a series of constraints as well as the region R that passed the target test.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

This function will return true if a constraint is interesting and false if a constraint is not. It is useful in filtering constraint paths to only interesting points.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

This function classifies a constraint from a location.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Report an error because the universal region fr was required to outlive outlived_fr but it is not known to do so. For example:

fn foo<'a, 'b>(x: &'a u32) -> &'b u32 { x }

Here we would be invoked with fr = 'a and outlived_fr ='b`.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

impl<'tcx> RegionInferenceContext<'tcx>
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Write out the region constraint graph.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Write out the region constraint graph.

impl<'tcx> RegionInferenceContext<'tcx>
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Creates a new region inference context with a total of num_region_variables valid inference variables; the first N of those will be constant regions representing the free regions defined in universal_regions.

The outlives_constraints and type_tests are an initial set of constraints produced by the MIR type check.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Each SCC is the combination of many region variables which have been equated. Therefore, we can associate a universe with each SCC which is minimum of all the universes of its constituent regions -- this is because whatever value the SCC takes on must be a value that each of the regions within the SCC could have as well. This implies that the SCC must have the minimum, or narrowest, universe.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Initializes the region variables for each universally quantified region (lifetime parameter). The first N variables always correspond to the regions appearing in the function signature (both named and anonymous) and where clauses. This function iterates over those regions and initializes them with minimum values.

For example:

fn foo<'a, 'b>(..) where 'a: 'b

would initialize two variables like so:

R0 = { CFG, R0 } // 'a
R1 = { CFG, R0, R1 } // 'b

Here, R0 represents 'a, and it contains (a) the entire CFG and (b) any universally quantified regions that it outlives, which in this case is just itself. R1 ('b) in contrast also outlives 'a and hence contains R0 and R1.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Returns an iterator over all the region indices.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Given a universal region in scope on the MIR, returns the corresponding index.

(Panics if r is not a registered universal region.)

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Returns true if the region r contains the point p.

Panics if called before solve() executes,

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Returns access to the value of r for debugging purposes.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Returns access to the value of r for debugging purposes.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Adds elem to the value of the SCC in which v appears.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Perform region inference and report errors if we see any unsatisfiable constraints. If this is a closure, returns the region requirements to propagate to our creator, if any.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Propagate the region constraints: this will grow the values for each region variable until all the constraints are satisfied. Note that some values may grow too large to be feasible, but we check this later.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

True if all the elements in the value of scc_b are nameable in scc_a. Used during constraint propagation, and only once the value of scc_b has been computed.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Once regions have been propagated, this method is used to see whether the "type tests" produced by typeck were satisfied; type tests encode type-outlives relationships like T: 'a. See TypeTest for more details.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Converts a region inference variable into a ty::Region that we can use for error reporting. If r is universally bound, then we use the name that we have on record for it. If r is existentially bound, then we check its inferred value and try to find a good name from that. Returns None if we can't find one (e.g., this is just some random part of the CFG).

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

When we promote a type test T: 'r, we have to convert the type T into something we can store in a query result (so something allocated for 'gcx). This is problematic if ty contains regions. During the course of NLL region checking, we will have replaced all of those regions with fresh inference variables. To create a test subject, we want to replace those inference variables with some region from the closure signature -- this is not always possible, so this is a fallible process. Presuming we do find a suitable region, we will represent it with a ReClosureBound, which is a RegionKind variant that can be allocated in the gcx.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Given some universal or existential region r, finds a non-local, universal region r+ that outlives r at entry to (and exit from) the closure. In the worst case, this will be 'static.

This is used for two purposes. First, if we are propagated some requirement T: r, we can use this method to enlarge r to something we can encode for our creator (which only knows about non-local, universal regions). It is also used when encoding T as part of try_promote_type_test_subject (see that fn for details).

This is based on the result 'y of universal_upper_bound, except that it converts further takes the non-local upper bound of 'y, so that the final result is non-local.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Returns a universally quantified region that outlives the value of r (r may be existentially or universally quantified).

Since r is (potentially) an existential region, it has some value which may include (a) any number of points in the CFG and (b) any number of end('x) elements of universally quantified regions. To convert this into a single universal region we do as follows:

  • Ignore the CFG points in 'r. All universally quantified regions include the CFG anyhow.
  • For each end('x) element in 'r, compute the mutual LUB, yielding a result 'y.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Test if test is true when applied to lower_bound at point, and returns true or false.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Once regions have been propagated, this method is used to see whether any of the constraints were too strong. In particular, we want to check for a case where a universally quantified region exceeded its bounds. Consider:

fn foo<'a, 'b>(x: &'a u32) -> &'b u32 { x }

In this case, returning x requires &'a u32 <: &'b u32 and hence we establish (transitively) a constraint that 'a: 'b. The propagate_constraints code above will therefore add end('a) into the region for 'b -- but we have no evidence that 'b outlives 'a, so we want to report an error.

If propagated_outlives_requirements is Some, then we will push unsatisfied obligations into there. Otherwise, we'll report them as errors.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Check the final value for the free region fr to see if it grew too large. In particular, examine what end(X) points wound up in fr's final value; for each end(X) where X != fr, we want to check that fr: X. If not, that's either an error, or something we have to propagate to our creator.

Things that are to be propagated are accumulated into the outlives_requirements vector.

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Auto Trait Implementations

impl<'tcx> !Send for RegionInferenceContext<'tcx>

impl<'tcx> !Sync for RegionInferenceContext<'tcx>