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
definitions: IndexVec<RegionVid, RegionDefinition<'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?
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.
liveness_constraints: LivenessValues<RegionVid>
🔬 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)
.
constraints: Rc<ConstraintSet>
🔬 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.
constraint_graph: Rc<ConstraintGraph>
🔬 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.
constraint_sccs: Rc<Sccs<RegionVid, ConstraintSccIndex>>
🔬 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.
scc_universes: IndexVec<ConstraintSccIndex, UniverseIndex>
🔬 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.
scc_values: RegionValues<ConstraintSccIndex>
🔬 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.
type_tests: Vec<TypeTest<'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?
Type constraints that we check after solving.
universal_regions: Rc<UniversalRegions<'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?
Information about the universally quantified regions in scope on this function.
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?
Information about how the universally quantified regions in scope on this function relate to one another.
Methods
impl<'tcx> RegionInferenceContext<'tcx>
[src]
impl<'tcx> RegionInferenceContext<'tcx>
pub(crate) fn annotate(&self, err: &mut DiagnosticBuilder)
[src]
pub(crate) fn annotate(&self, err: &mut DiagnosticBuilder)
🔬 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]
impl<'tcx> RegionInferenceContext<'tcx>
pub(crate) fn dump_mir(&self, out: &mut Write) -> Result<()>
[src]
pub(crate) fn dump_mir(&self, out: &mut Write) -> Result<()>
🔬 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.
fn for_each_constraint(
&self,
with_msg: &mut FnMut(&str) -> Result<()>
) -> Result<()>
[src]
fn for_each_constraint(
&self,
with_msg: &mut FnMut(&str) -> Result<()>
) -> Result<()>
🔬 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]
impl<'tcx> RegionInferenceContext<'tcx>
pub(crate) fn give_region_a_name(
&self,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
fr: RegionVid,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> InternedString
[src]
pub(crate) fn give_region_a_name(
&self,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
fr: RegionVid,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> InternedString
🔬 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.
fn give_name_from_error_region(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
mir_def_id: DefId,
fr: RegionVid,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
[src]
fn give_name_from_error_region(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
mir_def_id: DefId,
fr: RegionVid,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
🔬 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.
fn give_name_if_anonymous_region_appears_in_arguments(
&self,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
fr: RegionVid,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
[src]
fn give_name_if_anonymous_region_appears_in_arguments(
&self,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
fr: RegionVid,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
🔬 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`
fn give_name_if_we_can_match_hir_ty_from_argument(
&self,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
needle_fr: RegionVid,
argument_ty: Ty<'tcx>,
argument_index: usize,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
[src]
fn give_name_if_we_can_match_hir_ty_from_argument(
&self,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
needle_fr: RegionVid,
argument_ty: Ty<'tcx>,
argument_index: usize,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
🔬 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?
fn give_name_if_we_cannot_match_hir_ty(
&self,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
needle_fr: RegionVid,
argument_ty: Ty<'tcx>,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
[src]
fn give_name_if_we_cannot_match_hir_ty(
&self,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
needle_fr: RegionVid,
argument_ty: Ty<'tcx>,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
🔬 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`
fn give_name_if_we_can_match_hir_ty(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
needle_fr: RegionVid,
argument_ty: Ty<'tcx>,
argument_hir_ty: &Ty,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
[src]
fn give_name_if_we_can_match_hir_ty(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
needle_fr: RegionVid,
argument_ty: Ty<'tcx>,
argument_hir_ty: &Ty,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
🔬 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.
fn match_adt_and_segment<'hir>(
&self,
substs: &'tcx Substs<'tcx>,
needle_fr: RegionVid,
last_segment: &'hir PathSegment,
counter: &mut usize,
diag: &mut DiagnosticBuilder,
search_stack: &mut Vec<(Ty<'tcx>, &'hir Ty)>
) -> Option<InternedString>
[src]
fn match_adt_and_segment<'hir>(
&self,
substs: &'tcx Substs<'tcx>,
needle_fr: RegionVid,
last_segment: &'hir PathSegment,
counter: &mut usize,
diag: &mut DiagnosticBuilder,
search_stack: &mut Vec<(Ty<'tcx>, &'hir Ty)>
) -> Option<InternedString>
🔬 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).
fn try_match_adt_and_generic_args<'hir>(
&self,
substs: &'tcx Substs<'tcx>,
needle_fr: RegionVid,
args: &'hir GenericArgs,
search_stack: &mut Vec<(Ty<'tcx>, &'hir Ty)>
) -> Option<&'hir Lifetime>
[src]
fn try_match_adt_and_generic_args<'hir>(
&self,
substs: &'tcx Substs<'tcx>,
needle_fr: RegionVid,
args: &'hir GenericArgs,
search_stack: &mut Vec<(Ty<'tcx>, &'hir Ty)>
) -> Option<&'hir Lifetime>
🔬 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.
fn give_name_if_anonymous_region_appears_in_upvars(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
fr: RegionVid,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
[src]
fn give_name_if_anonymous_region_appears_in_upvars(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
fr: RegionVid,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
🔬 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>`
fn give_name_if_anonymous_region_appears_in_output(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
fr: RegionVid,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
[src]
fn give_name_if_anonymous_region_appears_in_output(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
fr: RegionVid,
counter: &mut usize,
diag: &mut DiagnosticBuilder
) -> Option<InternedString>
🔬 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).
fn synthesize_region_name(&self, counter: &mut usize) -> InternedString
[src]
fn synthesize_region_name(&self, counter: &mut usize) -> InternedString
🔬 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]
impl<'tcx> RegionInferenceContext<'tcx>
pub(crate) fn get_var_name_and_span_for_region(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
fr: RegionVid
) -> Option<(Option<Symbol>, Span)>
[src]
pub(crate) fn get_var_name_and_span_for_region(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
fr: RegionVid
) -> Option<(Option<Symbol>, Span)>
🔬 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?
pub(crate) fn get_upvar_index_for_region(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
fr: RegionVid
) -> Option<usize>
[src]
pub(crate) fn get_upvar_index_for_region(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
fr: RegionVid
) -> Option<usize>
🔬 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.
pub(crate) fn get_upvar_name_and_span_for_region(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
upvar_index: usize
) -> (Symbol, Span)
[src]
pub(crate) fn get_upvar_name_and_span_for_region(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
upvar_index: usize
) -> (Symbol, Span)
🔬 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.
pub(crate) fn get_argument_index_for_region(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
fr: RegionVid
) -> Option<usize>
[src]
pub(crate) fn get_argument_index_for_region(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
fr: RegionVid
) -> Option<usize>
🔬 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.
pub(crate) fn get_argument_name_and_span_for_region(
&self,
mir: &Mir<'tcx>,
argument_index: usize
) -> (Option<Symbol>, Span)
[src]
pub(crate) fn get_argument_name_and_span_for_region(
&self,
mir: &Mir<'tcx>,
argument_index: usize
) -> (Option<Symbol>, Span)
🔬 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]
impl<'tcx> RegionInferenceContext<'tcx>
fn best_blame_constraint(
&self,
mir: &Mir<'tcx>,
from_region: RegionVid,
target_test: impl Fn(RegionVid) -> bool
) -> (ConstraintCategory, Span, RegionVid)
[src]
fn best_blame_constraint(
&self,
mir: &Mir<'tcx>,
from_region: RegionVid,
target_test: impl Fn(RegionVid) -> bool
) -> (ConstraintCategory, Span, RegionVid)
🔬 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.
fn find_constraint_paths_between_regions(
&self,
from_region: RegionVid,
target_test: impl Fn(RegionVid) -> bool
) -> Option<(Vec<ConstraintIndex>, RegionVid)>
[src]
fn find_constraint_paths_between_regions(
&self,
from_region: RegionVid,
target_test: impl Fn(RegionVid) -> bool
) -> Option<(Vec<ConstraintIndex>, RegionVid)>
🔬 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.
fn constraint_is_interesting(&self, index: ConstraintIndex) -> bool
[src]
fn constraint_is_interesting(&self, index: ConstraintIndex) -> bool
🔬 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.
fn classify_constraint(
&self,
index: ConstraintIndex,
mir: &Mir<'tcx>
) -> (ConstraintCategory, Span)
[src]
fn classify_constraint(
&self,
index: ConstraintIndex,
mir: &Mir<'tcx>
) -> (ConstraintCategory, Span)
🔬 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.
pub(super) fn report_error(
&self,
mir: &Mir<'tcx>,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir_def_id: DefId,
fr: RegionVid,
outlived_fr: RegionVid,
errors_buffer: &mut Vec<Diagnostic>
)
[src]
pub(super) fn report_error(
&self,
mir: &Mir<'tcx>,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir_def_id: DefId,
fr: RegionVid,
outlived_fr: RegionVid,
errors_buffer: &mut Vec<Diagnostic>
)
🔬 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`.
fn report_escaping_data_error(
&self,
mir: &Mir<'tcx>,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir_def_id: DefId,
fr: RegionVid,
outlived_fr: RegionVid,
category: ConstraintCategory,
span: Span,
errors_buffer: &mut Vec<Diagnostic>
)
[src]
fn report_escaping_data_error(
&self,
mir: &Mir<'tcx>,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir_def_id: DefId,
fr: RegionVid,
outlived_fr: RegionVid,
category: ConstraintCategory,
span: Span,
errors_buffer: &mut Vec<Diagnostic>
)
🔬 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?
fn report_general_error(
&self,
mir: &Mir<'tcx>,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir_def_id: DefId,
fr: RegionVid,
fr_is_local: bool,
outlived_fr: RegionVid,
outlived_fr_is_local: bool,
category: ConstraintCategory,
span: Span,
errors_buffer: &mut Vec<Diagnostic>
)
[src]
fn report_general_error(
&self,
mir: &Mir<'tcx>,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir_def_id: DefId,
fr: RegionVid,
fr_is_local: bool,
outlived_fr: RegionVid,
outlived_fr_is_local: bool,
category: ConstraintCategory,
span: Span,
errors_buffer: &mut Vec<Diagnostic>
)
🔬 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?
pub(crate) fn find_sub_region_live_at(
&self,
fr1: RegionVid,
elem: Location
) -> RegionVid
[src]
pub(crate) fn find_sub_region_live_at(
&self,
fr1: RegionVid,
elem: Location
) -> RegionVid
🔬 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?
pub(crate) fn find_outlives_blame_span(
&self,
mir: &Mir<'tcx>,
fr1: RegionVid,
fr2: RegionVid
) -> Span
[src]
pub(crate) fn find_outlives_blame_span(
&self,
mir: &Mir<'tcx>,
fr1: RegionVid,
fr2: RegionVid
) -> Span
🔬 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]
impl<'tcx> RegionInferenceContext<'tcx>
pub(crate) fn dump_graphviz_raw_constraints(&self, w: &mut Write) -> Result<()>
[src]
pub(crate) fn dump_graphviz_raw_constraints(&self, w: &mut Write) -> Result<()>
🔬 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.
pub(crate) fn dump_graphviz_scc_constraints(&self, w: &mut Write) -> Result<()>
[src]
pub(crate) fn dump_graphviz_scc_constraints(&self, w: &mut Write) -> Result<()>
🔬 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]
impl<'tcx> RegionInferenceContext<'tcx>
pub(crate) fn new(
var_infos: VarInfos,
universal_regions: Rc<UniversalRegions<'tcx>>,
universal_region_relations: Rc<UniversalRegionRelations<'tcx>>,
_mir: &Mir<'tcx>,
outlives_constraints: ConstraintSet,
type_tests: Vec<TypeTest<'tcx>>,
liveness_constraints: LivenessValues<RegionVid>,
elements: &Rc<RegionValueElements>
) -> Self
[src]
pub(crate) fn new(
var_infos: VarInfos,
universal_regions: Rc<UniversalRegions<'tcx>>,
universal_region_relations: Rc<UniversalRegionRelations<'tcx>>,
_mir: &Mir<'tcx>,
outlives_constraints: ConstraintSet,
type_tests: Vec<TypeTest<'tcx>>,
liveness_constraints: LivenessValues<RegionVid>,
elements: &Rc<RegionValueElements>
) -> Self
🔬 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.
fn compute_scc_universes(
constraints_scc: &Sccs<RegionVid, ConstraintSccIndex>,
definitions: &IndexVec<RegionVid, RegionDefinition<'tcx>>
) -> IndexVec<ConstraintSccIndex, UniverseIndex>
[src]
fn compute_scc_universes(
constraints_scc: &Sccs<RegionVid, ConstraintSccIndex>,
definitions: &IndexVec<RegionVid, RegionDefinition<'tcx>>
) -> IndexVec<ConstraintSccIndex, UniverseIndex>
🔬 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.
fn init_free_and_bound_regions(&mut self)
[src]
fn init_free_and_bound_regions(&mut self)
🔬 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.
pub fn regions(&self) ->
[src]
pub fn regions(&self) ->
🔬 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.
pub fn to_region_vid(&self, r: Region<'tcx>) -> RegionVid
[src]
pub fn to_region_vid(&self, r: Region<'tcx>) -> RegionVid
🔬 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.)
pub(crate) fn region_contains(
&self,
r: impl ToRegionVid,
p: impl ToElementIndex
) -> bool
[src]
pub(crate) fn region_contains(
&self,
r: impl ToRegionVid,
p: impl ToElementIndex
) -> bool
🔬 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,
pub(crate) fn region_value_str(&self, r: RegionVid) -> String
[src]
pub(crate) fn region_value_str(&self, r: RegionVid) -> String
🔬 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.
pub(crate) fn region_universe(&self, r: RegionVid) -> UniverseIndex
[src]
pub(crate) fn region_universe(&self, r: RegionVid) -> UniverseIndex
🔬 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.
fn add_element_to_scc_of(
&mut self,
v: RegionVid,
elem: impl ToElementIndex
)
[src]
fn add_element_to_scc_of(
&mut self,
v: RegionVid,
elem: impl ToElementIndex
)
🔬 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.
pub(super) fn solve<'gcx>(
&mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
errors_buffer: &mut Vec<Diagnostic>
) -> Option<ClosureRegionRequirements<'gcx>>
[src]
pub(super) fn solve<'gcx>(
&mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
errors_buffer: &mut Vec<Diagnostic>
) -> Option<ClosureRegionRequirements<'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?
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.
fn solve_inner<'gcx>(
&mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
errors_buffer: &mut Vec<Diagnostic>
) -> Option<ClosureRegionRequirements<'gcx>>
[src]
fn solve_inner<'gcx>(
&mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
errors_buffer: &mut Vec<Diagnostic>
) -> Option<ClosureRegionRequirements<'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?
fn propagate_constraints(&mut self, _mir: &Mir<'tcx>)
[src]
fn propagate_constraints(&mut self, _mir: &Mir<'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?
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.
fn propagate_constraint_sccs_if_new(
&mut self,
scc_a: ConstraintSccIndex,
visited: &mut IdxSet<ConstraintSccIndex>
)
[src]
fn propagate_constraint_sccs_if_new(
&mut self,
scc_a: ConstraintSccIndex,
visited: &mut IdxSet<ConstraintSccIndex>
)
🔬 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?
fn propagate_constraint_sccs_new(
&mut self,
scc_a: ConstraintSccIndex,
visited: &mut IdxSet<ConstraintSccIndex>
)
[src]
fn propagate_constraint_sccs_new(
&mut self,
scc_a: ConstraintSccIndex,
visited: &mut IdxSet<ConstraintSccIndex>
)
🔬 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?
fn universe_compatible(
&self,
scc_b: ConstraintSccIndex,
scc_a: ConstraintSccIndex
) -> bool
[src]
fn universe_compatible(
&self,
scc_b: ConstraintSccIndex,
scc_a: ConstraintSccIndex
) -> bool
🔬 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.
fn check_type_tests<'gcx>(
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
errors_buffer: &mut Vec<Diagnostic>
)
[src]
fn check_type_tests<'gcx>(
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
errors_buffer: &mut Vec<Diagnostic>
)
🔬 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.
pub fn to_error_region(&self, r: RegionVid) -> Option<Region<'tcx>>
[src]
pub fn to_error_region(&self, r: RegionVid) -> Option<Region<'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?
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).
fn try_promote_type_test<'gcx>(
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
type_test: &TypeTest<'tcx>,
propagated_outlives_requirements: &mut Vec<ClosureOutlivesRequirement<'gcx>>
) -> bool
[src]
fn try_promote_type_test<'gcx>(
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
type_test: &TypeTest<'tcx>,
propagated_outlives_requirements: &mut Vec<ClosureOutlivesRequirement<'gcx>>
) -> bool
🔬 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?
fn try_promote_type_test_subject<'gcx>(
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
ty: Ty<'tcx>
) -> Option<ClosureOutlivesSubject<'gcx>>
[src]
fn try_promote_type_test_subject<'gcx>(
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
ty: Ty<'tcx>
) -> Option<ClosureOutlivesSubject<'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?
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.
fn non_local_universal_upper_bound(&self, r: RegionVid) -> RegionVid
[src]
fn non_local_universal_upper_bound(&self, r: RegionVid) -> RegionVid
🔬 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.
fn universal_upper_bound(&self, r: RegionVid) -> RegionVid
[src]
fn universal_upper_bound(&self, r: RegionVid) -> RegionVid
🔬 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
.
fn eval_region_test(
&self,
mir: &Mir<'tcx>,
lower_bound: RegionVid,
test: &RegionTest
) -> bool
[src]
fn eval_region_test(
&self,
mir: &Mir<'tcx>,
lower_bound: RegionVid,
test: &RegionTest
) -> bool
🔬 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.
fn eval_outlives(
&self,
_mir: &Mir<'tcx>,
sup_region: RegionVid,
sub_region: RegionVid
) -> bool
[src]
fn eval_outlives(
&self,
_mir: &Mir<'tcx>,
sup_region: RegionVid,
sub_region: RegionVid
) -> bool
🔬 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?
fn check_universal_regions<'gcx>(
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
errors_buffer: &mut Vec<Diagnostic>
)
[src]
fn check_universal_regions<'gcx>(
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
errors_buffer: &mut Vec<Diagnostic>
)
🔬 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.
fn check_universal_region<'gcx>(
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
longer_fr: RegionVid,
propagated_outlives_requirements: &mut Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
errors_buffer: &mut Vec<Diagnostic>
)
[src]
fn check_universal_region<'gcx>(
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
longer_fr: RegionVid,
propagated_outlives_requirements: &mut Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
errors_buffer: &mut Vec<Diagnostic>
)
🔬 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.
fn check_bound_universal_region<'gcx>(
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
_mir_def_id: DefId,
longer_fr: RegionVid,
universe: UniverseIndex
)
[src]
fn check_bound_universal_region<'gcx>(
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
_mir_def_id: DefId,
longer_fr: RegionVid,
universe: UniverseIndex
)
🔬 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> !Send for RegionInferenceContext<'tcx>
impl<'tcx> !Sync for RegionInferenceContext<'tcx>
impl<'tcx> !Sync for RegionInferenceContext<'tcx>