mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Remove TypeckResults from InferCtxt
This commit is contained in:
parent
4a68373217
commit
349415d1c6
@ -14,8 +14,8 @@ use crate::{
|
|||||||
places_conflict, region_infer::values::LivenessValues,
|
places_conflict, region_infer::values::LivenessValues,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(super) fn generate_constraints<'cx, 'tcx>(
|
pub(super) fn generate_constraints<'tcx>(
|
||||||
infcx: &InferCtxt<'cx, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
liveness_constraints: &mut LivenessValues<RegionVid>,
|
liveness_constraints: &mut LivenessValues<RegionVid>,
|
||||||
all_facts: &mut Option<AllFacts>,
|
all_facts: &mut Option<AllFacts>,
|
||||||
location_table: &LocationTable,
|
location_table: &LocationTable,
|
||||||
@ -37,8 +37,8 @@ pub(super) fn generate_constraints<'cx, 'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 'cg = the duration of the constraint generation process itself.
|
/// 'cg = the duration of the constraint generation process itself.
|
||||||
struct ConstraintGeneration<'cg, 'cx, 'tcx> {
|
struct ConstraintGeneration<'cg, 'tcx> {
|
||||||
infcx: &'cg InferCtxt<'cx, 'tcx>,
|
infcx: &'cg InferCtxt<'tcx>,
|
||||||
all_facts: &'cg mut Option<AllFacts>,
|
all_facts: &'cg mut Option<AllFacts>,
|
||||||
location_table: &'cg LocationTable,
|
location_table: &'cg LocationTable,
|
||||||
liveness_constraints: &'cg mut LivenessValues<RegionVid>,
|
liveness_constraints: &'cg mut LivenessValues<RegionVid>,
|
||||||
@ -46,7 +46,7 @@ struct ConstraintGeneration<'cg, 'cx, 'tcx> {
|
|||||||
body: &'cg Body<'tcx>,
|
body: &'cg Body<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'cg, 'cx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'tcx> {
|
impl<'cg, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'tcx> {
|
||||||
fn visit_basic_block_data(&mut self, bb: BasicBlock, data: &BasicBlockData<'tcx>) {
|
fn visit_basic_block_data(&mut self, bb: BasicBlock, data: &BasicBlockData<'tcx>) {
|
||||||
self.super_basic_block_data(bb, data);
|
self.super_basic_block_data(bb, data);
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ impl<'cg, 'cx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'cx, 'cg, 'tcx> ConstraintGeneration<'cx, 'cg, 'tcx> {
|
impl<'cx, 'tcx> ConstraintGeneration<'cx, 'tcx> {
|
||||||
/// Some variable with type `live_ty` is "regular live" at
|
/// Some variable with type `live_ty` is "regular live" at
|
||||||
/// `location` -- i.e., it may be used later. This means that all
|
/// `location` -- i.e., it may be used later. This means that all
|
||||||
/// regions appearing in the type `live_ty` must be live at
|
/// regions appearing in the type `live_ty` must be live at
|
||||||
|
@ -407,7 +407,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
|
|||||||
#[instrument(skip(fulfill_cx, infcx), level = "debug")]
|
#[instrument(skip(fulfill_cx, infcx), level = "debug")]
|
||||||
fn try_extract_error_from_fulfill_cx<'tcx>(
|
fn try_extract_error_from_fulfill_cx<'tcx>(
|
||||||
mut fulfill_cx: Box<dyn TraitEngine<'tcx> + 'tcx>,
|
mut fulfill_cx: Box<dyn TraitEngine<'tcx> + 'tcx>,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
placeholder_region: ty::Region<'tcx>,
|
placeholder_region: ty::Region<'tcx>,
|
||||||
error_region: Option<ty::Region<'tcx>>,
|
error_region: Option<ty::Region<'tcx>>,
|
||||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||||
@ -427,7 +427,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn try_extract_error_from_region_constraints<'tcx>(
|
fn try_extract_error_from_region_constraints<'tcx>(
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
placeholder_region: ty::Region<'tcx>,
|
placeholder_region: ty::Region<'tcx>,
|
||||||
error_region: Option<ty::Region<'tcx>>,
|
error_region: Option<ty::Region<'tcx>>,
|
||||||
region_constraints: &RegionConstraintData<'tcx>,
|
region_constraints: &RegionConstraintData<'tcx>,
|
||||||
|
@ -150,8 +150,8 @@ fn mir_borrowck<'tcx>(
|
|||||||
/// region ids on which the borrow checking was performed together with Polonius
|
/// region ids on which the borrow checking was performed together with Polonius
|
||||||
/// facts.
|
/// facts.
|
||||||
#[instrument(skip(infcx, input_body, input_promoted), fields(id=?input_body.source.with_opt_param().as_local().unwrap()), level = "debug")]
|
#[instrument(skip(infcx, input_body, input_promoted), fields(id=?input_body.source.with_opt_param().as_local().unwrap()), level = "debug")]
|
||||||
fn do_mir_borrowck<'a, 'tcx>(
|
fn do_mir_borrowck<'tcx>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
input_body: &Body<'tcx>,
|
input_body: &Body<'tcx>,
|
||||||
input_promoted: &IndexVec<Promoted, Body<'tcx>>,
|
input_promoted: &IndexVec<Promoted, Body<'tcx>>,
|
||||||
return_body_with_facts: bool,
|
return_body_with_facts: bool,
|
||||||
@ -474,7 +474,7 @@ pub struct BodyWithBorrowckFacts<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct MirBorrowckCtxt<'cx, 'tcx> {
|
struct MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
infcx: &'cx InferCtxt<'tcx>,
|
||||||
param_env: ParamEnv<'tcx>,
|
param_env: ParamEnv<'tcx>,
|
||||||
body: &'cx Body<'tcx>,
|
body: &'cx Body<'tcx>,
|
||||||
move_data: &'cx MoveData<'tcx>,
|
move_data: &'cx MoveData<'tcx>,
|
||||||
|
@ -55,8 +55,8 @@ pub(crate) struct NllOutput<'tcx> {
|
|||||||
/// regions (e.g., region parameters) declared on the function. That set will need to be given to
|
/// regions (e.g., region parameters) declared on the function. That set will need to be given to
|
||||||
/// `compute_regions`.
|
/// `compute_regions`.
|
||||||
#[instrument(skip(infcx, param_env, body, promoted), level = "debug")]
|
#[instrument(skip(infcx, param_env, body, promoted), level = "debug")]
|
||||||
pub(crate) fn replace_regions_in_mir<'cx, 'tcx>(
|
pub(crate) fn replace_regions_in_mir<'tcx>(
|
||||||
infcx: &InferCtxt<'cx, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body: &mut Body<'tcx>,
|
body: &mut Body<'tcx>,
|
||||||
promoted: &mut IndexVec<Promoted, Body<'tcx>>,
|
promoted: &mut IndexVec<Promoted, Body<'tcx>>,
|
||||||
@ -155,7 +155,7 @@ fn populate_polonius_move_facts(
|
|||||||
///
|
///
|
||||||
/// This may result in errors being reported.
|
/// This may result in errors being reported.
|
||||||
pub(crate) fn compute_regions<'cx, 'tcx>(
|
pub(crate) fn compute_regions<'cx, 'tcx>(
|
||||||
infcx: &InferCtxt<'cx, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
universal_regions: UniversalRegions<'tcx>,
|
universal_regions: UniversalRegions<'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
promoted: &IndexVec<Promoted, Body<'tcx>>,
|
promoted: &IndexVec<Promoted, Body<'tcx>>,
|
||||||
@ -318,8 +318,8 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn dump_mir_results<'a, 'tcx>(
|
pub(super) fn dump_mir_results<'tcx>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
regioncx: &RegionInferenceContext<'tcx>,
|
regioncx: &RegionInferenceContext<'tcx>,
|
||||||
closure_region_requirements: &Option<ClosureRegionRequirements<'_>>,
|
closure_region_requirements: &Option<ClosureRegionRequirements<'_>>,
|
||||||
@ -368,8 +368,8 @@ pub(super) fn dump_mir_results<'a, 'tcx>(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn dump_annotation<'a, 'tcx>(
|
pub(super) fn dump_annotation<'tcx>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
regioncx: &RegionInferenceContext<'tcx>,
|
regioncx: &RegionInferenceContext<'tcx>,
|
||||||
closure_region_requirements: &Option<ClosureRegionRequirements<'_>>,
|
closure_region_requirements: &Option<ClosureRegionRequirements<'_>>,
|
||||||
|
@ -565,7 +565,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
#[instrument(skip(self, infcx, body, polonius_output), level = "debug")]
|
#[instrument(skip(self, infcx, body, polonius_output), level = "debug")]
|
||||||
pub(super) fn solve(
|
pub(super) fn solve(
|
||||||
&mut self,
|
&mut self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
polonius_output: Option<Rc<PoloniusOutput>>,
|
polonius_output: Option<Rc<PoloniusOutput>>,
|
||||||
@ -835,7 +835,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
/// 'a`. See `TypeTest` for more details.
|
/// 'a`. See `TypeTest` for more details.
|
||||||
fn check_type_tests(
|
fn check_type_tests(
|
||||||
&self,
|
&self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'tcx>>>,
|
mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'tcx>>>,
|
||||||
@ -923,7 +923,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
#[instrument(level = "debug", skip(self, infcx, propagated_outlives_requirements))]
|
#[instrument(level = "debug", skip(self, infcx, propagated_outlives_requirements))]
|
||||||
fn try_promote_type_test(
|
fn try_promote_type_test(
|
||||||
&self,
|
&self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
type_test: &TypeTest<'tcx>,
|
type_test: &TypeTest<'tcx>,
|
||||||
@ -1036,7 +1036,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
#[instrument(level = "debug", skip(self, infcx))]
|
#[instrument(level = "debug", skip(self, infcx))]
|
||||||
fn try_promote_type_test_subject(
|
fn try_promote_type_test_subject(
|
||||||
&self,
|
&self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
) -> Option<ClosureOutlivesSubject<'tcx>> {
|
) -> Option<ClosureOutlivesSubject<'tcx>> {
|
||||||
let tcx = infcx.tcx;
|
let tcx = infcx.tcx;
|
||||||
@ -1212,7 +1212,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
/// `point`.
|
/// `point`.
|
||||||
fn eval_verify_bound(
|
fn eval_verify_bound(
|
||||||
&self,
|
&self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
generic_ty: Ty<'tcx>,
|
generic_ty: Ty<'tcx>,
|
||||||
@ -1262,7 +1262,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
|
|
||||||
fn eval_if_eq(
|
fn eval_if_eq(
|
||||||
&self,
|
&self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
generic_ty: Ty<'tcx>,
|
generic_ty: Ty<'tcx>,
|
||||||
lower_bound: RegionVid,
|
lower_bound: RegionVid,
|
||||||
@ -1718,7 +1718,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
|
|
||||||
fn check_member_constraints(
|
fn check_member_constraints(
|
||||||
&self,
|
&self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
errors_buffer: &mut RegionErrors<'tcx>,
|
errors_buffer: &mut RegionErrors<'tcx>,
|
||||||
) {
|
) {
|
||||||
let member_constraints = self.member_constraints.clone();
|
let member_constraints = self.member_constraints.clone();
|
||||||
|
@ -63,7 +63,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
#[instrument(level = "debug", skip(self, infcx), ret)]
|
#[instrument(level = "debug", skip(self, infcx), ret)]
|
||||||
pub(crate) fn infer_opaque_types(
|
pub(crate) fn infer_opaque_types(
|
||||||
&self,
|
&self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
opaque_ty_decls: VecMap<OpaqueTypeKey<'tcx>, (OpaqueHiddenType<'tcx>, OpaqueTyOrigin)>,
|
opaque_ty_decls: VecMap<OpaqueTypeKey<'tcx>, (OpaqueHiddenType<'tcx>, OpaqueTyOrigin)>,
|
||||||
) -> VecMap<LocalDefId, OpaqueHiddenType<'tcx>> {
|
) -> VecMap<LocalDefId, OpaqueHiddenType<'tcx>> {
|
||||||
let mut result: VecMap<LocalDefId, OpaqueHiddenType<'tcx>> = VecMap::new();
|
let mut result: VecMap<LocalDefId, OpaqueHiddenType<'tcx>> = VecMap::new();
|
||||||
@ -194,7 +194,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||||||
) -> Ty<'tcx>;
|
) -> Ty<'tcx>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||||
/// Given the fully resolved, instantiated type for an opaque
|
/// Given the fully resolved, instantiated type for an opaque
|
||||||
/// type, i.e., the value of an inference variable like C1 or C2
|
/// type, i.e., the value of an inference variable like C1 or C2
|
||||||
/// (*), computes the "definition type" for an opaque type
|
/// (*), computes the "definition type" for an opaque type
|
||||||
|
@ -10,7 +10,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
|
|||||||
/// inference variables, returning the number of variables created.
|
/// inference variables, returning the number of variables created.
|
||||||
#[instrument(skip(infcx, body, promoted), level = "debug")]
|
#[instrument(skip(infcx, body, promoted), level = "debug")]
|
||||||
pub fn renumber_mir<'tcx>(
|
pub fn renumber_mir<'tcx>(
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
body: &mut Body<'tcx>,
|
body: &mut Body<'tcx>,
|
||||||
promoted: &mut IndexVec<Promoted, Body<'tcx>>,
|
promoted: &mut IndexVec<Promoted, Body<'tcx>>,
|
||||||
) {
|
) {
|
||||||
@ -28,7 +28,7 @@ pub fn renumber_mir<'tcx>(
|
|||||||
/// Replaces all regions appearing in `value` with fresh inference
|
/// Replaces all regions appearing in `value` with fresh inference
|
||||||
/// variables.
|
/// variables.
|
||||||
#[instrument(skip(infcx), level = "debug")]
|
#[instrument(skip(infcx), level = "debug")]
|
||||||
pub fn renumber_regions<'tcx, T>(infcx: &InferCtxt<'_, 'tcx>, value: T) -> T
|
pub fn renumber_regions<'tcx, T>(infcx: &InferCtxt<'tcx>, value: T) -> T
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -44,7 +44,7 @@ where
|
|||||||
// Once `visit_mir_constant` is removed we can also remove this function
|
// Once `visit_mir_constant` is removed we can also remove this function
|
||||||
// and just use `renumber_regions`.
|
// and just use `renumber_regions`.
|
||||||
fn renumber_regions_in_mir_constant<'tcx>(
|
fn renumber_regions_in_mir_constant<'tcx>(
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
value: ConstantKind<'tcx>,
|
value: ConstantKind<'tcx>,
|
||||||
) -> ConstantKind<'tcx> {
|
) -> ConstantKind<'tcx> {
|
||||||
infcx.tcx.super_fold_regions(value, |_region, _depth| {
|
infcx.tcx.super_fold_regions(value, |_region, _depth| {
|
||||||
@ -54,7 +54,7 @@ fn renumber_regions_in_mir_constant<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct NllVisitor<'a, 'tcx> {
|
struct NllVisitor<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> NllVisitor<'a, 'tcx> {
|
impl<'a, 'tcx> NllVisitor<'a, 'tcx> {
|
||||||
|
@ -19,7 +19,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) struct ConstraintConversion<'a, 'tcx> {
|
pub(crate) struct ConstraintConversion<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
universal_regions: &'a UniversalRegions<'tcx>,
|
universal_regions: &'a UniversalRegions<'tcx>,
|
||||||
/// Each RBP `GK: 'a` is assumed to be true. These encode
|
/// Each RBP `GK: 'a` is assumed to be true. These encode
|
||||||
@ -43,7 +43,7 @@ pub(crate) struct ConstraintConversion<'a, 'tcx> {
|
|||||||
|
|
||||||
impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
|
impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
universal_regions: &'a UniversalRegions<'tcx>,
|
universal_regions: &'a UniversalRegions<'tcx>,
|
||||||
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
|
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
|
||||||
implicit_region_bound: ty::Region<'tcx>,
|
implicit_region_bound: ty::Region<'tcx>,
|
||||||
|
@ -48,7 +48,7 @@ pub(crate) struct CreateResult<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn create<'tcx>(
|
pub(crate) fn create<'tcx>(
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
implicit_region_bound: ty::Region<'tcx>,
|
implicit_region_bound: ty::Region<'tcx>,
|
||||||
universal_regions: &Rc<UniversalRegions<'tcx>>,
|
universal_regions: &Rc<UniversalRegions<'tcx>>,
|
||||||
@ -197,7 +197,7 @@ impl UniversalRegionRelations<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct UniversalRegionRelationsBuilder<'this, 'tcx> {
|
struct UniversalRegionRelationsBuilder<'this, 'tcx> {
|
||||||
infcx: &'this InferCtxt<'this, 'tcx>,
|
infcx: &'this InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
universal_regions: Rc<UniversalRegions<'tcx>>,
|
universal_regions: Rc<UniversalRegions<'tcx>>,
|
||||||
implicit_region_bound: ty::Region<'tcx>,
|
implicit_region_bound: ty::Region<'tcx>,
|
||||||
|
@ -123,7 +123,7 @@ mod relate_tys;
|
|||||||
/// - `move_data` -- move-data constructed when performing the maybe-init dataflow analysis
|
/// - `move_data` -- move-data constructed when performing the maybe-init dataflow analysis
|
||||||
/// - `elements` -- MIR region map
|
/// - `elements` -- MIR region map
|
||||||
pub(crate) fn type_check<'mir, 'tcx>(
|
pub(crate) fn type_check<'mir, 'tcx>(
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
promoted: &IndexVec<Promoted, Body<'tcx>>,
|
promoted: &IndexVec<Promoted, Body<'tcx>>,
|
||||||
@ -876,7 +876,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
|
|||||||
/// way, it accrues region constraints -- these can later be used by
|
/// way, it accrues region constraints -- these can later be used by
|
||||||
/// NLL region checking.
|
/// NLL region checking.
|
||||||
struct TypeChecker<'a, 'tcx> {
|
struct TypeChecker<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
last_span: Span,
|
last_span: Span,
|
||||||
body: &'a Body<'tcx>,
|
body: &'a Body<'tcx>,
|
||||||
@ -946,7 +946,7 @@ pub(crate) struct MirTypeckRegionConstraints<'tcx> {
|
|||||||
impl<'tcx> MirTypeckRegionConstraints<'tcx> {
|
impl<'tcx> MirTypeckRegionConstraints<'tcx> {
|
||||||
fn placeholder_region(
|
fn placeholder_region(
|
||||||
&mut self,
|
&mut self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
placeholder: ty::PlaceholderRegion,
|
placeholder: ty::PlaceholderRegion,
|
||||||
) -> ty::Region<'tcx> {
|
) -> ty::Region<'tcx> {
|
||||||
let placeholder_index = self.placeholder_indices.insert(placeholder);
|
let placeholder_index = self.placeholder_indices.insert(placeholder);
|
||||||
@ -1030,7 +1030,7 @@ impl Locations {
|
|||||||
|
|
||||||
impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
fn new(
|
fn new(
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
body: &'a Body<'tcx>,
|
body: &'a Body<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
|
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
|
||||||
@ -2744,7 +2744,7 @@ impl<'tcx> TypeOp<'tcx> for InstantiateOpaqueType<'tcx> {
|
|||||||
/// constraints in our `InferCtxt`
|
/// constraints in our `InferCtxt`
|
||||||
type ErrorInfo = InstantiateOpaqueType<'tcx>;
|
type ErrorInfo = InstantiateOpaqueType<'tcx>;
|
||||||
|
|
||||||
fn fully_perform(mut self, infcx: &InferCtxt<'_, 'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
|
fn fully_perform(mut self, infcx: &InferCtxt<'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
|
||||||
let (mut output, region_constraints) = scrape_region_constraints(infcx, || {
|
let (mut output, region_constraints) = scrape_region_constraints(infcx, || {
|
||||||
Ok(InferOk { value: (), obligations: self.obligations.clone() })
|
Ok(InferOk { value: (), obligations: self.obligations.clone() })
|
||||||
})?;
|
})?;
|
||||||
|
@ -219,7 +219,7 @@ impl<'tcx> UniversalRegions<'tcx> {
|
|||||||
/// signature. This will also compute the relationships that are
|
/// signature. This will also compute the relationships that are
|
||||||
/// known between those regions.
|
/// known between those regions.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
mir_def: ty::WithOptConstParam<LocalDefId>,
|
mir_def: ty::WithOptConstParam<LocalDefId>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@ -382,7 +382,7 @@ impl<'tcx> UniversalRegions<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct UniversalRegionsBuilder<'cx, 'tcx> {
|
struct UniversalRegionsBuilder<'cx, 'tcx> {
|
||||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
infcx: &'cx InferCtxt<'tcx>,
|
||||||
mir_def: ty::WithOptConstParam<LocalDefId>,
|
mir_def: ty::WithOptConstParam<LocalDefId>,
|
||||||
mir_hir_id: HirId,
|
mir_hir_id: HirId,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
@ -699,7 +699,7 @@ trait InferCtxtExt<'tcx> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
|
impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||||
fn replace_free_regions_with_nll_infer_vars<T>(
|
fn replace_free_regions_with_nll_infer_vars<T>(
|
||||||
&self,
|
&self,
|
||||||
origin: NllRegionVariableOrigin,
|
origin: NllRegionVariableOrigin,
|
||||||
|
@ -712,8 +712,8 @@ fn check_region_bounds_on_impl_item<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(infcx))]
|
#[instrument(level = "debug", skip(infcx))]
|
||||||
fn extract_spans_for_error_reporting<'a, 'tcx>(
|
fn extract_spans_for_error_reporting<'tcx>(
|
||||||
infcx: &infer::InferCtxt<'a, 'tcx>,
|
infcx: &infer::InferCtxt<'tcx>,
|
||||||
terr: TypeError<'_>,
|
terr: TypeError<'_>,
|
||||||
cause: &ObligationCause<'tcx>,
|
cause: &ObligationCause<'tcx>,
|
||||||
impl_m: &ty::AssocItem,
|
impl_m: &ty::AssocItem,
|
||||||
|
@ -6,7 +6,7 @@ use rustc_hir as hir;
|
|||||||
use rustc_hir::def_id::LocalDefId;
|
use rustc_hir::def_id::LocalDefId;
|
||||||
use rustc_hir::HirIdMap;
|
use rustc_hir::HirIdMap;
|
||||||
use rustc_infer::infer;
|
use rustc_infer::infer;
|
||||||
use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt};
|
use rustc_infer::infer::{DefiningAnchor, InferCtxt, InferOk, TyCtxtInferExt};
|
||||||
use rustc_middle::ty::fold::TypeFoldable;
|
use rustc_middle::ty::fold::TypeFoldable;
|
||||||
use rustc_middle::ty::visit::TypeVisitable;
|
use rustc_middle::ty::visit::TypeVisitable;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
@ -30,7 +30,7 @@ use std::ops::Deref;
|
|||||||
/// `bar()` will each have their own `FnCtxt`, but they will
|
/// `bar()` will each have their own `FnCtxt`, but they will
|
||||||
/// share the inherited fields.
|
/// share the inherited fields.
|
||||||
pub struct Inherited<'a, 'tcx> {
|
pub struct Inherited<'a, 'tcx> {
|
||||||
pub(super) infcx: InferCtxt<'a, 'tcx>,
|
pub(super) infcx: InferCtxt<'tcx>,
|
||||||
|
|
||||||
pub(super) typeck_results: &'a RefCell<ty::TypeckResults<'tcx>>,
|
pub(super) typeck_results: &'a RefCell<ty::TypeckResults<'tcx>>,
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ pub struct Inherited<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> Deref for Inherited<'a, 'tcx> {
|
impl<'a, 'tcx> Deref for Inherited<'a, 'tcx> {
|
||||||
type Target = InferCtxt<'a, 'tcx>;
|
type Target = InferCtxt<'tcx>;
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.infcx
|
&self.infcx
|
||||||
}
|
}
|
||||||
@ -83,6 +83,7 @@ impl<'a, 'tcx> Deref for Inherited<'a, 'tcx> {
|
|||||||
pub struct InheritedBuilder<'tcx> {
|
pub struct InheritedBuilder<'tcx> {
|
||||||
infcx: infer::InferCtxtBuilder<'tcx>,
|
infcx: infer::InferCtxtBuilder<'tcx>,
|
||||||
def_id: LocalDefId,
|
def_id: LocalDefId,
|
||||||
|
typeck_results: RefCell<ty::TypeckResults<'tcx>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Inherited<'_, 'tcx> {
|
impl<'tcx> Inherited<'_, 'tcx> {
|
||||||
@ -93,7 +94,7 @@ impl<'tcx> Inherited<'_, 'tcx> {
|
|||||||
infcx: tcx
|
infcx: tcx
|
||||||
.infer_ctxt()
|
.infer_ctxt()
|
||||||
.ignoring_regions()
|
.ignoring_regions()
|
||||||
.with_fresh_in_progress_typeck_results(hir_owner)
|
.with_opaque_type_inference(DefiningAnchor::Bind(hir_owner.def_id))
|
||||||
.with_normalize_fn_sig_for_diagnostic(Lrc::new(move |infcx, fn_sig| {
|
.with_normalize_fn_sig_for_diagnostic(Lrc::new(move |infcx, fn_sig| {
|
||||||
if fn_sig.has_escaping_bound_vars() {
|
if fn_sig.has_escaping_bound_vars() {
|
||||||
return fn_sig;
|
return fn_sig;
|
||||||
@ -117,6 +118,7 @@ impl<'tcx> Inherited<'_, 'tcx> {
|
|||||||
})
|
})
|
||||||
})),
|
})),
|
||||||
def_id,
|
def_id,
|
||||||
|
typeck_results: RefCell::new(ty::TypeckResults::new(hir_owner)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,16 +129,18 @@ impl<'tcx> InheritedBuilder<'tcx> {
|
|||||||
F: for<'a> FnOnce(Inherited<'a, 'tcx>) -> R,
|
F: for<'a> FnOnce(Inherited<'a, 'tcx>) -> R,
|
||||||
{
|
{
|
||||||
let def_id = self.def_id;
|
let def_id = self.def_id;
|
||||||
self.infcx.enter(|infcx| f(Inherited::new(infcx, def_id)))
|
self.infcx.enter(|infcx| f(Inherited::new(infcx, def_id, &self.typeck_results)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> Inherited<'a, 'tcx> {
|
impl<'a, 'tcx> Inherited<'a, 'tcx> {
|
||||||
fn new(infcx: InferCtxt<'a, 'tcx>, def_id: LocalDefId) -> Self {
|
fn new(
|
||||||
|
infcx: InferCtxt<'tcx>,
|
||||||
|
def_id: LocalDefId,
|
||||||
|
typeck_results: &'a RefCell<ty::TypeckResults<'tcx>>,
|
||||||
|
) -> Self {
|
||||||
let tcx = infcx.tcx;
|
let tcx = infcx.tcx;
|
||||||
let body_id = tcx.hir().maybe_body_owned_by(def_id);
|
let body_id = tcx.hir().maybe_body_owned_by(def_id);
|
||||||
let typeck_results =
|
|
||||||
infcx.in_progress_typeck_results.expect("building `FnCtxt` without typeck results");
|
|
||||||
|
|
||||||
Inherited {
|
Inherited {
|
||||||
typeck_results,
|
typeck_results,
|
||||||
|
@ -699,7 +699,7 @@ fn resolve_regions_with_wf_tys<'tcx>(
|
|||||||
id: hir::HirId,
|
id: hir::HirId,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
wf_tys: &FxHashSet<Ty<'tcx>>,
|
wf_tys: &FxHashSet<Ty<'tcx>>,
|
||||||
add_constraints: impl for<'a> FnOnce(&'a InferCtxt<'a, 'tcx>, &'a RegionBoundPairs<'tcx>),
|
add_constraints: impl for<'a> FnOnce(&'a InferCtxt<'tcx>, &'a RegionBoundPairs<'tcx>),
|
||||||
) -> bool {
|
) -> bool {
|
||||||
// Unfortunately, we have to use a new `InferCtxt` each call, because
|
// Unfortunately, we have to use a new `InferCtxt` each call, because
|
||||||
// region constraints get added and solved there and we need to test each
|
// region constraints get added and solved there and we need to test each
|
||||||
|
@ -700,7 +700,7 @@ impl Locatable for hir::HirId {
|
|||||||
/// unresolved types and so forth.
|
/// unresolved types and so forth.
|
||||||
struct Resolver<'cx, 'tcx> {
|
struct Resolver<'cx, 'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
infcx: &'cx InferCtxt<'tcx>,
|
||||||
span: &'cx dyn Locatable,
|
span: &'cx dyn Locatable,
|
||||||
body: &'tcx hir::Body<'tcx>,
|
body: &'tcx hir::Body<'tcx>,
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||||||
/// - `typeck_results` --- typeck results for the code being analyzed
|
/// - `typeck_results` --- typeck results for the code being analyzed
|
||||||
pub fn new(
|
pub fn new(
|
||||||
delegate: &'a mut (dyn Delegate<'tcx> + 'a),
|
delegate: &'a mut (dyn Delegate<'tcx> + 'a),
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
body_owner: LocalDefId,
|
body_owner: LocalDefId,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
typeck_results: &'a ty::TypeckResults<'tcx>,
|
typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||||
|
@ -92,7 +92,7 @@ impl HirNode for hir::Pat<'_> {
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct MemCategorizationContext<'a, 'tcx> {
|
pub(crate) struct MemCategorizationContext<'a, 'tcx> {
|
||||||
pub(crate) typeck_results: &'a ty::TypeckResults<'tcx>,
|
pub(crate) typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body_owner: LocalDefId,
|
body_owner: LocalDefId,
|
||||||
upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>,
|
upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>,
|
||||||
@ -103,7 +103,7 @@ pub(crate) type McResult<T> = Result<T, ()>;
|
|||||||
impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||||
/// Creates a `MemCategorizationContext`.
|
/// Creates a `MemCategorizationContext`.
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body_owner: LocalDefId,
|
body_owner: LocalDefId,
|
||||||
typeck_results: &'a ty::TypeckResults<'tcx>,
|
typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||||
|
@ -31,7 +31,7 @@ use rustc_middle::ty::relate::{Relate, TypeRelation};
|
|||||||
use rustc_middle::ty::{Const, ImplSubject};
|
use rustc_middle::ty::{Const, ImplSubject};
|
||||||
|
|
||||||
pub struct At<'a, 'tcx> {
|
pub struct At<'a, 'tcx> {
|
||||||
pub infcx: &'a InferCtxt<'a, 'tcx>,
|
pub infcx: &'a InferCtxt<'tcx>,
|
||||||
pub cause: &'a ObligationCause<'tcx>,
|
pub cause: &'a ObligationCause<'tcx>,
|
||||||
pub param_env: ty::ParamEnv<'tcx>,
|
pub param_env: ty::ParamEnv<'tcx>,
|
||||||
/// Whether we should define opaque types
|
/// Whether we should define opaque types
|
||||||
@ -48,9 +48,9 @@ pub struct Trace<'a, 'tcx> {
|
|||||||
trace: TypeTrace<'tcx>,
|
trace: TypeTrace<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn at(
|
pub fn at<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
cause: &'a ObligationCause<'tcx>,
|
cause: &'a ObligationCause<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
@ -66,7 +66,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
tcx: self.tcx,
|
tcx: self.tcx,
|
||||||
defining_use_anchor: self.defining_use_anchor,
|
defining_use_anchor: self.defining_use_anchor,
|
||||||
considering_regions: self.considering_regions,
|
considering_regions: self.considering_regions,
|
||||||
in_progress_typeck_results: self.in_progress_typeck_results,
|
|
||||||
inner: self.inner.clone(),
|
inner: self.inner.clone(),
|
||||||
skip_leak_check: self.skip_leak_check.clone(),
|
skip_leak_check: self.skip_leak_check.clone(),
|
||||||
lexical_region_resolutions: self.lexical_region_resolutions.clone(),
|
lexical_region_resolutions: self.lexical_region_resolutions.clone(),
|
||||||
|
@ -20,7 +20,7 @@ use rustc_data_structures::fx::FxHashMap;
|
|||||||
use rustc_index::vec::Idx;
|
use rustc_index::vec::Idx;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// Canonicalizes a query value `V`. When we canonicalize a query,
|
/// Canonicalizes a query value `V`. When we canonicalize a query,
|
||||||
/// we not only canonicalize unbound inference variables, but we
|
/// we not only canonicalize unbound inference variables, but we
|
||||||
/// *also* replace all free regions whatsoever. So for example a
|
/// *also* replace all free regions whatsoever. So for example a
|
||||||
@ -316,7 +316,7 @@ impl CanonicalizeMode for CanonicalizeFreeRegionsOtherThanStatic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct Canonicalizer<'cx, 'tcx> {
|
struct Canonicalizer<'cx, 'tcx> {
|
||||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
infcx: &'cx InferCtxt<'tcx>,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
variables: SmallVec<[CanonicalVarInfo<'tcx>; 8]>,
|
variables: SmallVec<[CanonicalVarInfo<'tcx>; 8]>,
|
||||||
query_state: &'cx mut OriginalQueryValues<'tcx>,
|
query_state: &'cx mut OriginalQueryValues<'tcx>,
|
||||||
@ -521,7 +521,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
|||||||
/// `canonicalize_query` and `canonicalize_response`.
|
/// `canonicalize_query` and `canonicalize_response`.
|
||||||
fn canonicalize<V>(
|
fn canonicalize<V>(
|
||||||
value: V,
|
value: V,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
canonicalize_region_mode: &dyn CanonicalizeMode,
|
canonicalize_region_mode: &dyn CanonicalizeMode,
|
||||||
query_state: &mut OriginalQueryValues<'tcx>,
|
query_state: &mut OriginalQueryValues<'tcx>,
|
||||||
|
@ -36,7 +36,7 @@ mod canonicalizer;
|
|||||||
pub mod query_response;
|
pub mod query_response;
|
||||||
mod substitute;
|
mod substitute;
|
||||||
|
|
||||||
impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// Creates a substitution S for the canonical value with fresh
|
/// Creates a substitution S for the canonical value with fresh
|
||||||
/// inference variables and applies it to the canonical value.
|
/// inference variables and applies it to the canonical value.
|
||||||
/// Returns both the instantiated result *and* the substitution S.
|
/// Returns both the instantiated result *and* the substitution S.
|
||||||
|
@ -32,7 +32,7 @@ use rustc_span::Span;
|
|||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// This method is meant to be invoked as the final step of a canonical query
|
/// This method is meant to be invoked as the final step of a canonical query
|
||||||
/// implementation. It is given:
|
/// implementation. It is given:
|
||||||
///
|
///
|
||||||
@ -677,7 +677,7 @@ pub fn make_query_region_constraints<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct QueryTypeRelatingDelegate<'a, 'tcx> {
|
struct QueryTypeRelatingDelegate<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
obligations: &'a mut Vec<PredicateObligation<'tcx>>,
|
obligations: &'a mut Vec<PredicateObligation<'tcx>>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
cause: &'a ObligationCause<'tcx>,
|
cause: &'a ObligationCause<'tcx>,
|
||||||
|
@ -43,7 +43,7 @@ use rustc_span::{Span, DUMMY_SP};
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct CombineFields<'infcx, 'tcx> {
|
pub struct CombineFields<'infcx, 'tcx> {
|
||||||
pub infcx: &'infcx InferCtxt<'infcx, 'tcx>,
|
pub infcx: &'infcx InferCtxt<'tcx>,
|
||||||
pub trace: TypeTrace<'tcx>,
|
pub trace: TypeTrace<'tcx>,
|
||||||
pub cause: Option<ty::relate::Cause>,
|
pub cause: Option<ty::relate::Cause>,
|
||||||
pub param_env: ty::ParamEnv<'tcx>,
|
pub param_env: ty::ParamEnv<'tcx>,
|
||||||
@ -63,7 +63,7 @@ pub enum RelationDir {
|
|||||||
EqTo,
|
EqTo,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
pub fn super_combine_tys<R>(
|
pub fn super_combine_tys<R>(
|
||||||
&self,
|
&self,
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
@ -452,7 +452,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct Generalizer<'cx, 'tcx> {
|
struct Generalizer<'cx, 'tcx> {
|
||||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
infcx: &'cx InferCtxt<'tcx>,
|
||||||
|
|
||||||
/// The span, used when creating new type variables and things.
|
/// The span, used when creating new type variables and things.
|
||||||
cause: &'cx ObligationCause<'tcx>,
|
cause: &'cx ObligationCause<'tcx>,
|
||||||
@ -775,7 +775,7 @@ fn float_unification_error<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ConstInferUnifier<'cx, 'tcx> {
|
struct ConstInferUnifier<'cx, 'tcx> {
|
||||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
infcx: &'cx InferCtxt<'tcx>,
|
||||||
|
|
||||||
span: Span,
|
span: Span,
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ pub mod nice_region_error;
|
|||||||
/// field is only populated during an in-progress typeck.
|
/// field is only populated during an in-progress typeck.
|
||||||
/// Get an instance by calling `InferCtxt::err` or `FnCtxt::infer_err`.
|
/// Get an instance by calling `InferCtxt::err` or `FnCtxt::infer_err`.
|
||||||
pub struct TypeErrCtxt<'a, 'tcx> {
|
pub struct TypeErrCtxt<'a, 'tcx> {
|
||||||
pub infcx: &'a InferCtxt<'a, 'tcx>,
|
pub infcx: &'a InferCtxt<'tcx>,
|
||||||
pub typeck_results: Option<std::cell::Ref<'a, ty::TypeckResults<'tcx>>>,
|
pub typeck_results: Option<std::cell::Ref<'a, ty::TypeckResults<'tcx>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,9 +103,9 @@ impl TypeErrCtxt<'_, '_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> Deref for TypeErrCtxt<'a, 'tcx> {
|
impl<'tcx> Deref for TypeErrCtxt<'_, 'tcx> {
|
||||||
type Target = InferCtxt<'a, 'tcx>;
|
type Target = InferCtxt<'tcx>;
|
||||||
fn deref(&self) -> &InferCtxt<'a, 'tcx> {
|
fn deref(&self) -> &InferCtxt<'tcx> {
|
||||||
&self.infcx
|
&self.infcx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
|
|||||||
err
|
err
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> InferCtxt<'_, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Binder<'tcx, Ty<'tcx>>> {
|
pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Binder<'tcx, Ty<'tcx>>> {
|
||||||
if let ty::Opaque(def_id, substs) = ty.kind() {
|
if let ty::Opaque(def_id, substs) = ty.kind() {
|
||||||
let future_trait = self.tcx.require_lang_item(LangItem::Future, None);
|
let future_trait = self.tcx.require_lang_item(LangItem::Future, None);
|
||||||
@ -2837,7 +2837,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SameTypeModuloInfer<'a, 'tcx>(&'a InferCtxt<'a, 'tcx>);
|
struct SameTypeModuloInfer<'a, 'tcx>(&'a InferCtxt<'tcx>);
|
||||||
|
|
||||||
impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
|
impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
|
||||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||||
@ -2924,7 +2924,7 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
fn report_inference_failure(
|
fn report_inference_failure(
|
||||||
&self,
|
&self,
|
||||||
var_origin: RegionVariableOrigin,
|
var_origin: RegionVariableOrigin,
|
||||||
@ -3112,7 +3112,7 @@ impl TyCategory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> InferCtxt<'_, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// Given a [`hir::Block`], get the span of its last expression or
|
/// Given a [`hir::Block`], get the span of its last expression or
|
||||||
/// statement, peeling off any inner blocks.
|
/// statement, peeling off any inner blocks.
|
||||||
pub fn find_block_span(&self, block: &'tcx hir::Block<'tcx>) -> Span {
|
pub fn find_block_span(&self, block: &'tcx hir::Block<'tcx>) -> Span {
|
||||||
|
@ -152,7 +152,7 @@ impl UnderspecifiedArgKind {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_printer<'a, 'tcx>(infcx: &'a InferCtxt<'_, 'tcx>, ns: Namespace) -> FmtPrinter<'a, 'tcx> {
|
fn fmt_printer<'a, 'tcx>(infcx: &'a InferCtxt<'tcx>, ns: Namespace) -> FmtPrinter<'a, 'tcx> {
|
||||||
let mut printer = FmtPrinter::new(infcx.tcx, ns);
|
let mut printer = FmtPrinter::new(infcx.tcx, ns);
|
||||||
let ty_getter = move |ty_vid| {
|
let ty_getter = move |ty_vid| {
|
||||||
if infcx.probe_ty_var(ty_vid).is_ok() {
|
if infcx.probe_ty_var(ty_vid).is_ok() {
|
||||||
@ -183,7 +183,7 @@ fn fmt_printer<'a, 'tcx>(infcx: &'a InferCtxt<'_, 'tcx>, ns: Namespace) -> FmtPr
|
|||||||
printer
|
printer
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_to_string<'tcx>(infcx: &InferCtxt<'_, 'tcx>, ty: Ty<'tcx>) -> String {
|
fn ty_to_string<'tcx>(infcx: &InferCtxt<'tcx>, ty: Ty<'tcx>) -> String {
|
||||||
let printer = fmt_printer(infcx, Namespace::TypeNS);
|
let printer = fmt_printer(infcx, Namespace::TypeNS);
|
||||||
let ty = infcx.resolve_vars_if_possible(ty);
|
let ty = infcx.resolve_vars_if_possible(ty);
|
||||||
match ty.kind() {
|
match ty.kind() {
|
||||||
@ -202,7 +202,7 @@ fn ty_to_string<'tcx>(infcx: &InferCtxt<'_, 'tcx>, ty: Ty<'tcx>) -> String {
|
|||||||
/// We don't want to directly use `ty_to_string` for closures as their type isn't really
|
/// We don't want to directly use `ty_to_string` for closures as their type isn't really
|
||||||
/// something users are familiar with. Directly printing the `fn_sig` of closures also
|
/// something users are familiar with. Directly printing the `fn_sig` of closures also
|
||||||
/// doesn't work as they actually use the "rust-call" API.
|
/// doesn't work as they actually use the "rust-call" API.
|
||||||
fn closure_as_fn_str<'tcx>(infcx: &InferCtxt<'_, 'tcx>, ty: Ty<'tcx>) -> String {
|
fn closure_as_fn_str<'tcx>(infcx: &InferCtxt<'tcx>, ty: Ty<'tcx>) -> String {
|
||||||
let ty::Closure(_, substs) = ty.kind() else { unreachable!() };
|
let ty::Closure(_, substs) = ty.kind() else { unreachable!() };
|
||||||
let fn_sig = substs.as_closure().sig();
|
let fn_sig = substs.as_closure().sig();
|
||||||
let args = fn_sig
|
let args = fn_sig
|
||||||
@ -226,7 +226,7 @@ fn closure_as_fn_str<'tcx>(infcx: &InferCtxt<'_, 'tcx>, ty: Ty<'tcx>) -> String
|
|||||||
format!("fn({}){}", args, ret)
|
format!("fn({}){}", args, ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// Extracts data used by diagnostic for either types or constants
|
/// Extracts data used by diagnostic for either types or constants
|
||||||
/// which were stuck during inference.
|
/// which were stuck during inference.
|
||||||
pub fn extract_inference_diagnostics_data(
|
pub fn extract_inference_diagnostics_data(
|
||||||
@ -566,7 +566,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> InferCtxt<'_, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
pub fn need_type_info_err_in_generator(
|
pub fn need_type_info_err_in_generator(
|
||||||
&self,
|
&self,
|
||||||
kind: hir::GeneratorKind,
|
kind: hir::GeneratorKind,
|
||||||
@ -657,7 +657,7 @@ impl<'tcx> InferSource<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> InferSourceKind<'tcx> {
|
impl<'tcx> InferSourceKind<'tcx> {
|
||||||
fn ty_localized_msg(&self, infcx: &InferCtxt<'_, 'tcx>) -> (&'static str, String) {
|
fn ty_localized_msg(&self, infcx: &InferCtxt<'tcx>) -> (&'static str, String) {
|
||||||
match *self {
|
match *self {
|
||||||
InferSourceKind::LetBinding { ty, .. }
|
InferSourceKind::LetBinding { ty, .. }
|
||||||
| InferSourceKind::ClosureArg { ty, .. }
|
| InferSourceKind::ClosureArg { ty, .. }
|
||||||
@ -694,7 +694,7 @@ struct InsertableGenericArgs<'tcx> {
|
|||||||
/// While doing so, the currently best spot is stored in `infer_source`.
|
/// While doing so, the currently best spot is stored in `infer_source`.
|
||||||
/// For details on how we rank spots, see [Self::source_cost]
|
/// For details on how we rank spots, see [Self::source_cost]
|
||||||
struct FindInferSourceVisitor<'a, 'tcx> {
|
struct FindInferSourceVisitor<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
typeck_results: &'a TypeckResults<'tcx>,
|
typeck_results: &'a TypeckResults<'tcx>,
|
||||||
|
|
||||||
target: GenericArg<'tcx>,
|
target: GenericArg<'tcx>,
|
||||||
@ -706,7 +706,7 @@ struct FindInferSourceVisitor<'a, 'tcx> {
|
|||||||
|
|
||||||
impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
||||||
fn new(
|
fn new(
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
typeck_results: &'a TypeckResults<'tcx>,
|
typeck_results: &'a TypeckResults<'tcx>,
|
||||||
target: GenericArg<'tcx>,
|
target: GenericArg<'tcx>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -38,7 +38,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeVi
|
|||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
|
|
||||||
pub struct TypeFreshener<'a, 'tcx> {
|
pub struct TypeFreshener<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
ty_freshen_count: u32,
|
ty_freshen_count: u32,
|
||||||
const_freshen_count: u32,
|
const_freshen_count: u32,
|
||||||
ty_freshen_map: FxHashMap<ty::InferTy, Ty<'tcx>>,
|
ty_freshen_map: FxHashMap<ty::InferTy, Ty<'tcx>>,
|
||||||
@ -47,7 +47,7 @@ pub struct TypeFreshener<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
|
impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
|
||||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>, keep_static: bool) -> TypeFreshener<'a, 'tcx> {
|
pub fn new(infcx: &'a InferCtxt<'tcx>, keep_static: bool) -> TypeFreshener<'a, 'tcx> {
|
||||||
TypeFreshener {
|
TypeFreshener {
|
||||||
infcx,
|
infcx,
|
||||||
ty_freshen_count: 0,
|
ty_freshen_count: 0,
|
||||||
|
@ -43,7 +43,7 @@ struct VariableLengths {
|
|||||||
region_constraints_len: usize,
|
region_constraints_len: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
fn variable_lengths(&self) -> VariableLengths {
|
fn variable_lengths(&self) -> VariableLengths {
|
||||||
let mut inner = self.inner.borrow_mut();
|
let mut inner = self.inner.borrow_mut();
|
||||||
VariableLengths {
|
VariableLengths {
|
||||||
@ -167,7 +167,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct InferenceFudger<'a, 'tcx> {
|
pub struct InferenceFudger<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
type_vars: (Range<TyVid>, Vec<TypeVariableOrigin>),
|
type_vars: (Range<TyVid>, Vec<TypeVariableOrigin>),
|
||||||
int_vars: Range<IntVid>,
|
int_vars: Range<IntVid>,
|
||||||
float_vars: Range<FloatVid>,
|
float_vars: Range<FloatVid>,
|
||||||
|
@ -113,7 +113,7 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Glb<'combine, 'infcx, 'tcx> {
|
impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Glb<'combine, 'infcx, 'tcx> {
|
||||||
fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'tcx> {
|
fn infcx(&self) -> &'infcx InferCtxt<'tcx> {
|
||||||
self.fields.infcx
|
self.fields.infcx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// Replaces all bound variables (lifetimes, types, and constants) bound by
|
/// Replaces all bound variables (lifetimes, types, and constants) bound by
|
||||||
/// `binder` with placeholder variables in a new universe. This means that the
|
/// `binder` with placeholder variables in a new universe. This means that the
|
||||||
/// new placeholders can only be named by inference variables created after
|
/// new placeholders can only be named by inference variables created after
|
||||||
@ -114,7 +114,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
pub fn leak_check(
|
pub fn leak_check(
|
||||||
&self,
|
&self,
|
||||||
overly_polymorphic: bool,
|
overly_polymorphic: bool,
|
||||||
snapshot: &CombinedSnapshot<'_, 'tcx>,
|
snapshot: &CombinedSnapshot<'tcx>,
|
||||||
) -> RelateResult<'tcx, ()> {
|
) -> RelateResult<'tcx, ()> {
|
||||||
// If the user gave `-Zno-leak-check`, or we have been
|
// If the user gave `-Zno-leak-check`, or we have been
|
||||||
// configured to skip the leak check, then skip the leak check
|
// configured to skip the leak check, then skip the leak check
|
||||||
|
@ -31,7 +31,7 @@ use rustc_middle::ty::{self, Ty};
|
|||||||
/// GLB moves "down" the lattice (to smaller values); LUB moves
|
/// GLB moves "down" the lattice (to smaller values); LUB moves
|
||||||
/// "up" the lattice (to bigger values).
|
/// "up" the lattice (to bigger values).
|
||||||
pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> {
|
pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> {
|
||||||
fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>;
|
fn infcx(&self) -> &'f InferCtxt<'tcx>;
|
||||||
|
|
||||||
fn cause(&self) -> &ObligationCause<'tcx>;
|
fn cause(&self) -> &ObligationCause<'tcx>;
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ impl<'tcx> ConstEquateRelation<'tcx> for Lub<'_, '_, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Lub<'combine, 'infcx, 'tcx> {
|
impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Lub<'combine, 'infcx, 'tcx> {
|
||||||
fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'tcx> {
|
fn infcx(&self) -> &'infcx InferCtxt<'tcx> {
|
||||||
self.fields.infcx
|
self.fields.infcx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ use rustc_data_structures::undo_log::Rollback;
|
|||||||
use rustc_data_structures::unify as ut;
|
use rustc_data_structures::unify as ut;
|
||||||
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
use rustc_hir::hir_id::OwnerId;
|
|
||||||
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
|
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
|
||||||
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue};
|
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue};
|
||||||
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind, ToType};
|
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind, ToType};
|
||||||
@ -36,7 +35,7 @@ use rustc_middle::ty::{ConstVid, FloatVid, IntVid, TyVid};
|
|||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
|
|
||||||
use std::cell::{Cell, Ref, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use self::combine::CombineFields;
|
use self::combine::CombineFields;
|
||||||
@ -254,7 +253,7 @@ pub enum DefiningAnchor {
|
|||||||
Error,
|
Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct InferCtxt<'a, 'tcx> {
|
pub struct InferCtxt<'tcx> {
|
||||||
pub tcx: TyCtxt<'tcx>,
|
pub tcx: TyCtxt<'tcx>,
|
||||||
|
|
||||||
/// The `DefId` of the item in whose context we are performing inference or typeck.
|
/// The `DefId` of the item in whose context we are performing inference or typeck.
|
||||||
@ -274,12 +273,6 @@ pub struct InferCtxt<'a, 'tcx> {
|
|||||||
/// solving is left to borrowck instead.
|
/// solving is left to borrowck instead.
|
||||||
pub considering_regions: bool,
|
pub considering_regions: bool,
|
||||||
|
|
||||||
/// During type-checking/inference of a body, `in_progress_typeck_results`
|
|
||||||
/// contains a reference to the typeck results being built up, which are
|
|
||||||
/// used for reading closure kinds/signatures as they are inferred,
|
|
||||||
/// and for error reporting logic to read arbitrary node types.
|
|
||||||
pub in_progress_typeck_results: Option<&'a RefCell<ty::TypeckResults<'tcx>>>,
|
|
||||||
|
|
||||||
pub inner: RefCell<InferCtxtInner<'tcx>>,
|
pub inner: RefCell<InferCtxtInner<'tcx>>,
|
||||||
|
|
||||||
/// If set, this flag causes us to skip the 'leak check' during
|
/// If set, this flag causes us to skip the 'leak check' during
|
||||||
@ -342,7 +335,7 @@ pub struct InferCtxt<'a, 'tcx> {
|
|||||||
universe: Cell<ty::UniverseIndex>,
|
universe: Cell<ty::UniverseIndex>,
|
||||||
|
|
||||||
normalize_fn_sig_for_diagnostic:
|
normalize_fn_sig_for_diagnostic:
|
||||||
Option<Lrc<dyn Fn(&InferCtxt<'_, 'tcx>, ty::PolyFnSig<'tcx>) -> ty::PolyFnSig<'tcx>>>,
|
Option<Lrc<dyn Fn(&InferCtxt<'tcx>, ty::PolyFnSig<'tcx>) -> ty::PolyFnSig<'tcx>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the `error_reporting` module for more details.
|
/// See the `error_reporting` module for more details.
|
||||||
@ -553,16 +546,13 @@ impl<'tcx> fmt::Display for FixupError<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A temporary returned by `tcx.infer_ctxt()`. This is necessary
|
/// Used to configure inference contexts before their creation
|
||||||
/// for multiple `InferCtxt` to share the same `in_progress_typeck_results`
|
|
||||||
/// without using `Rc` or something similar.
|
|
||||||
pub struct InferCtxtBuilder<'tcx> {
|
pub struct InferCtxtBuilder<'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
defining_use_anchor: DefiningAnchor,
|
defining_use_anchor: DefiningAnchor,
|
||||||
considering_regions: bool,
|
considering_regions: bool,
|
||||||
fresh_typeck_results: Option<RefCell<ty::TypeckResults<'tcx>>>,
|
|
||||||
normalize_fn_sig_for_diagnostic:
|
normalize_fn_sig_for_diagnostic:
|
||||||
Option<Lrc<dyn Fn(&InferCtxt<'_, 'tcx>, ty::PolyFnSig<'tcx>) -> ty::PolyFnSig<'tcx>>>,
|
Option<Lrc<dyn Fn(&InferCtxt<'tcx>, ty::PolyFnSig<'tcx>) -> ty::PolyFnSig<'tcx>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait TyCtxtInferExt<'tcx> {
|
pub trait TyCtxtInferExt<'tcx> {
|
||||||
@ -575,26 +565,17 @@ impl<'tcx> TyCtxtInferExt<'tcx> for TyCtxt<'tcx> {
|
|||||||
tcx: self,
|
tcx: self,
|
||||||
defining_use_anchor: DefiningAnchor::Error,
|
defining_use_anchor: DefiningAnchor::Error,
|
||||||
considering_regions: true,
|
considering_regions: true,
|
||||||
fresh_typeck_results: None,
|
|
||||||
normalize_fn_sig_for_diagnostic: None,
|
normalize_fn_sig_for_diagnostic: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> InferCtxtBuilder<'tcx> {
|
impl<'tcx> InferCtxtBuilder<'tcx> {
|
||||||
/// Used only by `rustc_hir_analysis` during body type-checking/inference,
|
|
||||||
/// will initialize `in_progress_typeck_results` with fresh `TypeckResults`.
|
|
||||||
/// Will also change the scope for opaque type defining use checks to the given owner.
|
|
||||||
pub fn with_fresh_in_progress_typeck_results(mut self, table_owner: OwnerId) -> Self {
|
|
||||||
self.fresh_typeck_results = Some(RefCell::new(ty::TypeckResults::new(table_owner)));
|
|
||||||
self.with_opaque_type_inference(DefiningAnchor::Bind(table_owner.def_id))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Whenever the `InferCtxt` should be able to handle defining uses of opaque types,
|
/// Whenever the `InferCtxt` should be able to handle defining uses of opaque types,
|
||||||
/// you need to call this function. Otherwise the opaque type will be treated opaquely.
|
/// you need to call this function. Otherwise the opaque type will be treated opaquely.
|
||||||
///
|
///
|
||||||
/// It is only meant to be called in two places, for typeck
|
/// It is only meant to be called in two places, for typeck
|
||||||
/// (via `with_fresh_in_progress_typeck_results`) and for the inference context used
|
/// (via `Inherited::build`) and for the inference context used
|
||||||
/// in mir borrowck.
|
/// in mir borrowck.
|
||||||
pub fn with_opaque_type_inference(mut self, defining_use_anchor: DefiningAnchor) -> Self {
|
pub fn with_opaque_type_inference(mut self, defining_use_anchor: DefiningAnchor) -> Self {
|
||||||
self.defining_use_anchor = defining_use_anchor;
|
self.defining_use_anchor = defining_use_anchor;
|
||||||
@ -608,7 +589,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
|
|||||||
|
|
||||||
pub fn with_normalize_fn_sig_for_diagnostic(
|
pub fn with_normalize_fn_sig_for_diagnostic(
|
||||||
mut self,
|
mut self,
|
||||||
fun: Lrc<dyn Fn(&InferCtxt<'_, 'tcx>, ty::PolyFnSig<'tcx>) -> ty::PolyFnSig<'tcx>>,
|
fun: Lrc<dyn Fn(&InferCtxt<'tcx>, ty::PolyFnSig<'tcx>) -> ty::PolyFnSig<'tcx>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.normalize_fn_sig_for_diagnostic = Some(fun);
|
self.normalize_fn_sig_for_diagnostic = Some(fun);
|
||||||
self
|
self
|
||||||
@ -625,7 +606,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
span: Span,
|
span: Span,
|
||||||
canonical: &Canonical<'tcx, T>,
|
canonical: &Canonical<'tcx, T>,
|
||||||
f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>, T, CanonicalVarValues<'tcx>) -> R,
|
f: impl FnOnce(InferCtxt<'tcx>, T, CanonicalVarValues<'tcx>) -> R,
|
||||||
) -> R
|
) -> R
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
@ -637,20 +618,17 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn enter<R>(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>) -> R) -> R {
|
pub fn enter<R>(&mut self, f: impl FnOnce(InferCtxt<'tcx>) -> R) -> R {
|
||||||
let InferCtxtBuilder {
|
let InferCtxtBuilder {
|
||||||
tcx,
|
tcx,
|
||||||
defining_use_anchor,
|
defining_use_anchor,
|
||||||
considering_regions,
|
considering_regions,
|
||||||
ref fresh_typeck_results,
|
|
||||||
ref normalize_fn_sig_for_diagnostic,
|
ref normalize_fn_sig_for_diagnostic,
|
||||||
} = *self;
|
} = *self;
|
||||||
let in_progress_typeck_results = fresh_typeck_results.as_ref();
|
|
||||||
f(InferCtxt {
|
f(InferCtxt {
|
||||||
tcx,
|
tcx,
|
||||||
defining_use_anchor,
|
defining_use_anchor,
|
||||||
considering_regions,
|
considering_regions,
|
||||||
in_progress_typeck_results,
|
|
||||||
inner: RefCell::new(InferCtxtInner::new()),
|
inner: RefCell::new(InferCtxtInner::new()),
|
||||||
lexical_region_resolutions: RefCell::new(None),
|
lexical_region_resolutions: RefCell::new(None),
|
||||||
selection_cache: Default::default(),
|
selection_cache: Default::default(),
|
||||||
@ -677,7 +655,7 @@ impl<'tcx, T> InferOk<'tcx, T> {
|
|||||||
/// Extracts `value`, registering any obligations into `fulfill_cx`.
|
/// Extracts `value`, registering any obligations into `fulfill_cx`.
|
||||||
pub fn into_value_registering_obligations(
|
pub fn into_value_registering_obligations(
|
||||||
self,
|
self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
fulfill_cx: &mut dyn TraitEngine<'tcx>,
|
fulfill_cx: &mut dyn TraitEngine<'tcx>,
|
||||||
) -> T {
|
) -> T {
|
||||||
let InferOk { value, obligations } = self;
|
let InferOk { value, obligations } = self;
|
||||||
@ -693,18 +671,17 @@ impl<'tcx> InferOk<'tcx, ()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use = "once you start a snapshot, you should always consume it"]
|
#[must_use = "once you start a snapshot, you should always consume it"]
|
||||||
pub struct CombinedSnapshot<'a, 'tcx> {
|
pub struct CombinedSnapshot<'tcx> {
|
||||||
undo_snapshot: Snapshot<'tcx>,
|
undo_snapshot: Snapshot<'tcx>,
|
||||||
region_constraints_snapshot: RegionSnapshot,
|
region_constraints_snapshot: RegionSnapshot,
|
||||||
universe: ty::UniverseIndex,
|
universe: ty::UniverseIndex,
|
||||||
was_in_snapshot: bool,
|
was_in_snapshot: bool,
|
||||||
_in_progress_typeck_results: Option<Ref<'a, ty::TypeckResults<'tcx>>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// Creates a `TypeErrCtxt` for emitting various inference errors.
|
/// Creates a `TypeErrCtxt` for emitting various inference errors.
|
||||||
/// During typeck, use `FnCtxt::infer_err` instead.
|
/// During typeck, use `FnCtxt::infer_err` instead.
|
||||||
pub fn err_ctxt(&'a self) -> TypeErrCtxt<'a, 'tcx> {
|
pub fn err_ctxt(&self) -> TypeErrCtxt<'_, 'tcx> {
|
||||||
TypeErrCtxt { infcx: self, typeck_results: None }
|
TypeErrCtxt { infcx: self, typeck_results: None }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,7 +723,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
/// if this is not a type variable.
|
/// if this is not a type variable.
|
||||||
///
|
///
|
||||||
/// No attempt is made to resolve `ty`.
|
/// No attempt is made to resolve `ty`.
|
||||||
pub fn type_var_origin(&'a self, ty: Ty<'tcx>) -> Option<TypeVariableOrigin> {
|
pub fn type_var_origin(&self, ty: Ty<'tcx>) -> Option<TypeVariableOrigin> {
|
||||||
match *ty.kind() {
|
match *ty.kind() {
|
||||||
ty::Infer(ty::TyVar(vid)) => {
|
ty::Infer(ty::TyVar(vid)) => {
|
||||||
Some(*self.inner.borrow_mut().type_variables().var_origin(vid))
|
Some(*self.inner.borrow_mut().type_variables().var_origin(vid))
|
||||||
@ -787,7 +764,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
vars
|
vars
|
||||||
}
|
}
|
||||||
|
|
||||||
fn combine_fields(
|
fn combine_fields<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
trace: TypeTrace<'tcx>,
|
trace: TypeTrace<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
@ -829,7 +806,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start_snapshot(&self) -> CombinedSnapshot<'a, 'tcx> {
|
fn start_snapshot(&self) -> CombinedSnapshot<'tcx> {
|
||||||
debug!("start_snapshot()");
|
debug!("start_snapshot()");
|
||||||
|
|
||||||
let in_snapshot = self.in_snapshot.replace(true);
|
let in_snapshot = self.in_snapshot.replace(true);
|
||||||
@ -841,22 +818,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
region_constraints_snapshot: inner.unwrap_region_constraints().start_snapshot(),
|
region_constraints_snapshot: inner.unwrap_region_constraints().start_snapshot(),
|
||||||
universe: self.universe(),
|
universe: self.universe(),
|
||||||
was_in_snapshot: in_snapshot,
|
was_in_snapshot: in_snapshot,
|
||||||
// Borrow typeck results "in progress" (i.e., during typeck)
|
|
||||||
// to ban writes from within a snapshot to them.
|
|
||||||
_in_progress_typeck_results: self
|
|
||||||
.in_progress_typeck_results
|
|
||||||
.map(|typeck_results| typeck_results.borrow()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(self, snapshot), level = "debug")]
|
#[instrument(skip(self, snapshot), level = "debug")]
|
||||||
fn rollback_to(&self, cause: &str, snapshot: CombinedSnapshot<'a, 'tcx>) {
|
fn rollback_to(&self, cause: &str, snapshot: CombinedSnapshot<'tcx>) {
|
||||||
let CombinedSnapshot {
|
let CombinedSnapshot {
|
||||||
undo_snapshot,
|
undo_snapshot,
|
||||||
region_constraints_snapshot,
|
region_constraints_snapshot,
|
||||||
universe,
|
universe,
|
||||||
was_in_snapshot,
|
was_in_snapshot,
|
||||||
_in_progress_typeck_results,
|
|
||||||
} = snapshot;
|
} = snapshot;
|
||||||
|
|
||||||
self.in_snapshot.set(was_in_snapshot);
|
self.in_snapshot.set(was_in_snapshot);
|
||||||
@ -868,13 +839,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(self, snapshot), level = "debug")]
|
#[instrument(skip(self, snapshot), level = "debug")]
|
||||||
fn commit_from(&self, snapshot: CombinedSnapshot<'a, 'tcx>) {
|
fn commit_from(&self, snapshot: CombinedSnapshot<'tcx>) {
|
||||||
let CombinedSnapshot {
|
let CombinedSnapshot {
|
||||||
undo_snapshot,
|
undo_snapshot,
|
||||||
region_constraints_snapshot: _,
|
region_constraints_snapshot: _,
|
||||||
universe: _,
|
universe: _,
|
||||||
was_in_snapshot,
|
was_in_snapshot,
|
||||||
_in_progress_typeck_results,
|
|
||||||
} = snapshot;
|
} = snapshot;
|
||||||
|
|
||||||
self.in_snapshot.set(was_in_snapshot);
|
self.in_snapshot.set(was_in_snapshot);
|
||||||
@ -886,7 +856,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
#[instrument(skip(self, f), level = "debug")]
|
#[instrument(skip(self, f), level = "debug")]
|
||||||
pub fn commit_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
|
pub fn commit_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
|
||||||
where
|
where
|
||||||
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> Result<T, E>,
|
F: FnOnce(&CombinedSnapshot<'tcx>) -> Result<T, E>,
|
||||||
{
|
{
|
||||||
let snapshot = self.start_snapshot();
|
let snapshot = self.start_snapshot();
|
||||||
let r = f(&snapshot);
|
let r = f(&snapshot);
|
||||||
@ -906,7 +876,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
#[instrument(skip(self, f), level = "debug")]
|
#[instrument(skip(self, f), level = "debug")]
|
||||||
pub fn probe<R, F>(&self, f: F) -> R
|
pub fn probe<R, F>(&self, f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> R,
|
F: FnOnce(&CombinedSnapshot<'tcx>) -> R,
|
||||||
{
|
{
|
||||||
let snapshot = self.start_snapshot();
|
let snapshot = self.start_snapshot();
|
||||||
let r = f(&snapshot);
|
let r = f(&snapshot);
|
||||||
@ -918,7 +888,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
#[instrument(skip(self, f), level = "debug")]
|
#[instrument(skip(self, f), level = "debug")]
|
||||||
pub fn probe_maybe_skip_leak_check<R, F>(&self, should_skip: bool, f: F) -> R
|
pub fn probe_maybe_skip_leak_check<R, F>(&self, should_skip: bool, f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> R,
|
F: FnOnce(&CombinedSnapshot<'tcx>) -> R,
|
||||||
{
|
{
|
||||||
let snapshot = self.start_snapshot();
|
let snapshot = self.start_snapshot();
|
||||||
let was_skip_leak_check = self.skip_leak_check.get();
|
let was_skip_leak_check = self.skip_leak_check.get();
|
||||||
@ -938,7 +908,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
/// - `Some(false)` -- if there are `'a: 'b` constraints but none involve placeholders
|
/// - `Some(false)` -- if there are `'a: 'b` constraints but none involve placeholders
|
||||||
pub fn region_constraints_added_in_snapshot(
|
pub fn region_constraints_added_in_snapshot(
|
||||||
&self,
|
&self,
|
||||||
snapshot: &CombinedSnapshot<'a, 'tcx>,
|
snapshot: &CombinedSnapshot<'tcx>,
|
||||||
) -> Option<bool> {
|
) -> Option<bool> {
|
||||||
self.inner
|
self.inner
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
@ -946,7 +916,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
.region_constraints_added_in_snapshot(&snapshot.undo_snapshot)
|
.region_constraints_added_in_snapshot(&snapshot.undo_snapshot)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opaque_types_added_in_snapshot(&self, snapshot: &CombinedSnapshot<'a, 'tcx>) -> bool {
|
pub fn opaque_types_added_in_snapshot(&self, snapshot: &CombinedSnapshot<'tcx>) -> bool {
|
||||||
self.inner.borrow().undo_log.opaque_types_in_snapshot(&snapshot.undo_snapshot)
|
self.inner.borrow().undo_log.opaque_types_in_snapshot(&snapshot.undo_snapshot)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1519,7 +1489,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ToFreshVars<'a, 'tcx> {
|
struct ToFreshVars<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
lbrct: LateBoundRegionConversionTime,
|
lbrct: LateBoundRegionConversionTime,
|
||||||
map: FxHashMap<ty::BoundVar, ty::GenericArg<'tcx>>,
|
map: FxHashMap<ty::BoundVar, ty::GenericArg<'tcx>>,
|
||||||
@ -1893,7 +1863,7 @@ impl<'tcx> TypeFolder<'tcx> for InferenceLiteralEraser<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ShallowResolver<'a, 'tcx> {
|
struct ShallowResolver<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> TypeFolder<'tcx> for ShallowResolver<'a, 'tcx> {
|
impl<'a, 'tcx> TypeFolder<'tcx> for ShallowResolver<'a, 'tcx> {
|
||||||
|
@ -44,7 +44,7 @@ pub struct TypeRelating<'me, 'tcx, D>
|
|||||||
where
|
where
|
||||||
D: TypeRelatingDelegate<'tcx>,
|
D: TypeRelatingDelegate<'tcx>,
|
||||||
{
|
{
|
||||||
infcx: &'me InferCtxt<'me, 'tcx>,
|
infcx: &'me InferCtxt<'tcx>,
|
||||||
|
|
||||||
/// Callback to use when we deduce an outlives relationship.
|
/// Callback to use when we deduce an outlives relationship.
|
||||||
delegate: D,
|
delegate: D,
|
||||||
@ -149,11 +149,7 @@ impl<'me, 'tcx, D> TypeRelating<'me, 'tcx, D>
|
|||||||
where
|
where
|
||||||
D: TypeRelatingDelegate<'tcx>,
|
D: TypeRelatingDelegate<'tcx>,
|
||||||
{
|
{
|
||||||
pub fn new(
|
pub fn new(infcx: &'me InferCtxt<'tcx>, delegate: D, ambient_variance: ty::Variance) -> Self {
|
||||||
infcx: &'me InferCtxt<'me, 'tcx>,
|
|
||||||
delegate: D,
|
|
||||||
ambient_variance: ty::Variance,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
Self {
|
||||||
infcx,
|
infcx,
|
||||||
delegate,
|
delegate,
|
||||||
@ -867,7 +863,7 @@ struct TypeGeneralizer<'me, 'tcx, D>
|
|||||||
where
|
where
|
||||||
D: TypeRelatingDelegate<'tcx>,
|
D: TypeRelatingDelegate<'tcx>,
|
||||||
{
|
{
|
||||||
infcx: &'me InferCtxt<'me, 'tcx>,
|
infcx: &'me InferCtxt<'tcx>,
|
||||||
|
|
||||||
delegate: &'me mut D,
|
delegate: &'me mut D,
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ pub struct OpaqueTypeDecl<'tcx> {
|
|||||||
pub origin: hir::OpaqueTyOrigin,
|
pub origin: hir::OpaqueTyOrigin,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// This is a backwards compatibility hack to prevent breaking changes from
|
/// This is a backwards compatibility hack to prevent breaking changes from
|
||||||
/// lazy TAIT around RPIT handling.
|
/// lazy TAIT around RPIT handling.
|
||||||
pub fn replace_opaque_types_with_inference_vars<T: TypeFoldable<'tcx>>(
|
pub fn replace_opaque_types_with_inference_vars<T: TypeFoldable<'tcx>>(
|
||||||
@ -511,7 +511,7 @@ impl UseKind {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
#[instrument(skip(self), level = "debug")]
|
#[instrument(skip(self), level = "debug")]
|
||||||
pub fn register_hidden_type(
|
pub fn register_hidden_type(
|
||||||
&self,
|
&self,
|
||||||
|
@ -87,9 +87,9 @@ impl<'tcx> OutlivesEnvironment<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new `OutlivesEnvironment` with extra outlives bounds.
|
/// Create a new `OutlivesEnvironment` with extra outlives bounds.
|
||||||
pub fn with_bounds<'a>(
|
pub fn with_bounds(
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
infcx: Option<&InferCtxt<'a, 'tcx>>,
|
infcx: Option<&InferCtxt<'tcx>>,
|
||||||
extra_bounds: impl IntoIterator<Item = OutlivesBound<'tcx>>,
|
extra_bounds: impl IntoIterator<Item = OutlivesBound<'tcx>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut builder = Self::builder(param_env);
|
let mut builder = Self::builder(param_env);
|
||||||
@ -108,7 +108,7 @@ impl<'tcx> OutlivesEnvironment<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> OutlivesEnvironmentBuilder<'tcx> {
|
impl<'tcx> OutlivesEnvironmentBuilder<'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[instrument(level = "debug")]
|
#[instrument(level = "debug")]
|
||||||
fn build(self) -> OutlivesEnvironment<'tcx> {
|
fn build(self) -> OutlivesEnvironment<'tcx> {
|
||||||
@ -125,7 +125,7 @@ impl<'a, 'tcx> OutlivesEnvironmentBuilder<'tcx> {
|
|||||||
/// contain inference variables, it must be supplied, in which
|
/// contain inference variables, it must be supplied, in which
|
||||||
/// case we will register "givens" on the inference context. (See
|
/// case we will register "givens" on the inference context. (See
|
||||||
/// `RegionConstraintData`.)
|
/// `RegionConstraintData`.)
|
||||||
fn add_outlives_bounds<I>(&mut self, infcx: Option<&InferCtxt<'a, 'tcx>>, outlives_bounds: I)
|
fn add_outlives_bounds<I>(&mut self, infcx: Option<&InferCtxt<'tcx>>, outlives_bounds: I)
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = OutlivesBound<'tcx>>,
|
I: IntoIterator<Item = OutlivesBound<'tcx>>,
|
||||||
{
|
{
|
||||||
|
@ -75,7 +75,7 @@ use rustc_middle::ty::subst::GenericArgKind;
|
|||||||
use rustc_middle::ty::{self, Region, SubstsRef, Ty, TyCtxt, TypeVisitable};
|
use rustc_middle::ty::{self, Region, SubstsRef, Ty, TyCtxt, TypeVisitable};
|
||||||
use smallvec::smallvec;
|
use smallvec::smallvec;
|
||||||
|
|
||||||
impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// Registers that the given region obligation must be resolved
|
/// Registers that the given region obligation must be resolved
|
||||||
/// from within the scope of `body_id`. These regions are enqueued
|
/// from within the scope of `body_id`. These regions are enqueued
|
||||||
/// and later processed by regionck, when full type information is
|
/// and later processed by regionck, when full type information is
|
||||||
@ -523,7 +523,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'cx, 'tcx> {
|
impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'tcx> {
|
||||||
fn push_sub_region_constraint(
|
fn push_sub_region_constraint(
|
||||||
&mut self,
|
&mut self,
|
||||||
origin: SubregionOrigin<'tcx>,
|
origin: SubregionOrigin<'tcx>,
|
||||||
|
@ -6,7 +6,7 @@ use crate::traits::{Obligation, PredicateObligation};
|
|||||||
use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||||
use super::InferCtxt;
|
use super::InferCtxt;
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// Instead of normalizing an associated type projection,
|
/// Instead of normalizing an associated type projection,
|
||||||
/// this function generates an inference variable and registers
|
/// this function generates an inference variable and registers
|
||||||
/// an obligation that this inference variable must be the result
|
/// an obligation that this inference variable must be the result
|
||||||
|
@ -66,7 +66,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
|
|||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
overly_polymorphic: bool,
|
overly_polymorphic: bool,
|
||||||
max_universe: ty::UniverseIndex,
|
max_universe: ty::UniverseIndex,
|
||||||
snapshot: &CombinedSnapshot<'_, 'tcx>,
|
snapshot: &CombinedSnapshot<'tcx>,
|
||||||
) -> RelateResult<'tcx, ()> {
|
) -> RelateResult<'tcx, ()> {
|
||||||
debug!(
|
debug!(
|
||||||
"leak_check(max_universe={:?}, snapshot.universe={:?}, overly_polymorphic={:?})",
|
"leak_check(max_universe={:?}, snapshot.universe={:?}, overly_polymorphic={:?})",
|
||||||
|
@ -16,12 +16,12 @@ use std::ops::ControlFlow;
|
|||||||
/// useful for printing messages etc but also required at various
|
/// useful for printing messages etc but also required at various
|
||||||
/// points for correctness.
|
/// points for correctness.
|
||||||
pub struct OpportunisticVarResolver<'a, 'tcx> {
|
pub struct OpportunisticVarResolver<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> {
|
impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
|
pub fn new(infcx: &'a InferCtxt<'tcx>) -> Self {
|
||||||
OpportunisticVarResolver { infcx }
|
OpportunisticVarResolver { infcx }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,11 +62,11 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> {
|
|||||||
/// If you want to resolve type and const variables as well, call
|
/// If you want to resolve type and const variables as well, call
|
||||||
/// [InferCtxt::resolve_vars_if_possible] first.
|
/// [InferCtxt::resolve_vars_if_possible] first.
|
||||||
pub struct OpportunisticRegionResolver<'a, 'tcx> {
|
pub struct OpportunisticRegionResolver<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> OpportunisticRegionResolver<'a, 'tcx> {
|
impl<'a, 'tcx> OpportunisticRegionResolver<'a, 'tcx> {
|
||||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
|
pub fn new(infcx: &'a InferCtxt<'tcx>) -> Self {
|
||||||
OpportunisticRegionResolver { infcx }
|
OpportunisticRegionResolver { infcx }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,11 +116,11 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticRegionResolver<'a, 'tcx> {
|
|||||||
/// It does not construct the fully resolved type (which might
|
/// It does not construct the fully resolved type (which might
|
||||||
/// involve some hashing and so forth).
|
/// involve some hashing and so forth).
|
||||||
pub struct UnresolvedTypeFinder<'a, 'tcx> {
|
pub struct UnresolvedTypeFinder<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> {
|
impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> {
|
||||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
|
pub fn new(infcx: &'a InferCtxt<'tcx>) -> Self {
|
||||||
UnresolvedTypeFinder { infcx }
|
UnresolvedTypeFinder { infcx }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
|
|||||||
/// Full type resolution replaces all type and region variables with
|
/// Full type resolution replaces all type and region variables with
|
||||||
/// their concrete results. If any variable cannot be replaced (never unified, etc)
|
/// their concrete results. If any variable cannot be replaced (never unified, etc)
|
||||||
/// then an `Err` result is returned.
|
/// then an `Err` result is returned.
|
||||||
pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, value: T) -> FixupResult<'tcx, T>
|
pub fn fully_resolve<'tcx, T>(infcx: &InferCtxt<'tcx>, value: T) -> FixupResult<'tcx, T>
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -177,7 +177,7 @@ where
|
|||||||
// N.B. This type is not public because the protocol around checking the
|
// N.B. This type is not public because the protocol around checking the
|
||||||
// `err` field is not enforceable otherwise.
|
// `err` field is not enforceable otherwise.
|
||||||
struct FullTypeResolver<'a, 'tcx> {
|
struct FullTypeResolver<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> FallibleTypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
|
impl<'a, 'tcx> FallibleTypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
|
||||||
|
@ -10,7 +10,7 @@ use super::{ObligationCause, PredicateObligation};
|
|||||||
pub trait TraitEngine<'tcx>: 'tcx {
|
pub trait TraitEngine<'tcx>: 'tcx {
|
||||||
fn normalize_projection_type(
|
fn normalize_projection_type(
|
||||||
&mut self,
|
&mut self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
projection_ty: ty::ProjectionTy<'tcx>,
|
projection_ty: ty::ProjectionTy<'tcx>,
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
@ -21,7 +21,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
|
|||||||
/// parameters (except for `Self`).
|
/// parameters (except for `Self`).
|
||||||
fn register_bound(
|
fn register_bound(
|
||||||
&mut self,
|
&mut self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
@ -41,14 +41,13 @@ pub trait TraitEngine<'tcx>: 'tcx {
|
|||||||
|
|
||||||
fn register_predicate_obligation(
|
fn register_predicate_obligation(
|
||||||
&mut self,
|
&mut self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
obligation: PredicateObligation<'tcx>,
|
obligation: PredicateObligation<'tcx>,
|
||||||
);
|
);
|
||||||
|
|
||||||
fn select_all_or_error(&mut self, infcx: &InferCtxt<'_, 'tcx>) -> Vec<FulfillmentError<'tcx>>;
|
fn select_all_or_error(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<FulfillmentError<'tcx>>;
|
||||||
|
|
||||||
fn select_where_possible(&mut self, infcx: &InferCtxt<'_, 'tcx>)
|
fn select_where_possible(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<FulfillmentError<'tcx>>;
|
||||||
-> Vec<FulfillmentError<'tcx>>;
|
|
||||||
|
|
||||||
fn pending_obligations(&self) -> Vec<PredicateObligation<'tcx>>;
|
fn pending_obligations(&self) -> Vec<PredicateObligation<'tcx>>;
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
|
|||||||
pub trait TraitEngineExt<'tcx> {
|
pub trait TraitEngineExt<'tcx> {
|
||||||
fn register_predicate_obligations(
|
fn register_predicate_obligations(
|
||||||
&mut self,
|
&mut self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>,
|
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -66,7 +65,7 @@ pub trait TraitEngineExt<'tcx> {
|
|||||||
impl<'tcx, T: ?Sized + TraitEngine<'tcx>> TraitEngineExt<'tcx> for T {
|
impl<'tcx, T: ?Sized + TraitEngine<'tcx>> TraitEngineExt<'tcx> for T {
|
||||||
fn register_predicate_obligations(
|
fn register_predicate_obligations(
|
||||||
&mut self,
|
&mut self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>,
|
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>,
|
||||||
) {
|
) {
|
||||||
for obligation in obligations {
|
for obligation in obligations {
|
||||||
|
@ -10,7 +10,7 @@ use rustc_span::Span;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
pub fn report_extra_impl_obligation(
|
pub fn report_extra_impl_obligation(
|
||||||
&self,
|
&self,
|
||||||
error_span: Span,
|
error_span: Span,
|
||||||
|
@ -157,7 +157,7 @@ struct BlockContext(Vec<BlockFrame>);
|
|||||||
|
|
||||||
struct Builder<'a, 'tcx> {
|
struct Builder<'a, 'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
infcx: InferCtxt<'a, 'tcx>,
|
infcx: InferCtxt<'tcx>,
|
||||||
typeck_results: &'tcx TypeckResults<'tcx>,
|
typeck_results: &'tcx TypeckResults<'tcx>,
|
||||||
region_scope_tree: &'tcx region::ScopeTree,
|
region_scope_tree: &'tcx region::ScopeTree,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
@ -683,7 +683,7 @@ fn construct_error<'tcx>(
|
|||||||
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
fn new(
|
fn new(
|
||||||
thir: &'a Thir<'tcx>,
|
thir: &'a Thir<'tcx>,
|
||||||
infcx: InferCtxt<'a, 'tcx>,
|
infcx: InferCtxt<'tcx>,
|
||||||
def: ty::WithOptConstParam<LocalDefId>,
|
def: ty::WithOptConstParam<LocalDefId>,
|
||||||
hir_id: hir::HirId,
|
hir_id: hir::HirId,
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -35,7 +35,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ConstToPat<'a, 'tcx> {
|
struct ConstToPat<'tcx> {
|
||||||
id: hir::HirId,
|
id: hir::HirId,
|
||||||
span: Span,
|
span: Span,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
@ -55,7 +55,7 @@ struct ConstToPat<'a, 'tcx> {
|
|||||||
behind_reference: Cell<bool>,
|
behind_reference: Cell<bool>,
|
||||||
|
|
||||||
// inference context used for checking `T: Structural` bounds.
|
// inference context used for checking `T: Structural` bounds.
|
||||||
infcx: InferCtxt<'a, 'tcx>,
|
infcx: InferCtxt<'tcx>,
|
||||||
|
|
||||||
include_lint_checks: bool,
|
include_lint_checks: bool,
|
||||||
|
|
||||||
@ -71,21 +71,19 @@ mod fallback_to_const_ref {
|
|||||||
/// hoops to get a reference to the value.
|
/// hoops to get a reference to the value.
|
||||||
pub(super) struct FallbackToConstRef(());
|
pub(super) struct FallbackToConstRef(());
|
||||||
|
|
||||||
pub(super) fn fallback_to_const_ref<'a, 'tcx>(
|
pub(super) fn fallback_to_const_ref<'tcx>(c2p: &super::ConstToPat<'tcx>) -> FallbackToConstRef {
|
||||||
c2p: &super::ConstToPat<'a, 'tcx>,
|
|
||||||
) -> FallbackToConstRef {
|
|
||||||
assert!(c2p.behind_reference.get());
|
assert!(c2p.behind_reference.get());
|
||||||
FallbackToConstRef(())
|
FallbackToConstRef(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
use fallback_to_const_ref::{fallback_to_const_ref, FallbackToConstRef};
|
use fallback_to_const_ref::{fallback_to_const_ref, FallbackToConstRef};
|
||||||
|
|
||||||
impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
|
impl<'tcx> ConstToPat<'tcx> {
|
||||||
fn new(
|
fn new(
|
||||||
pat_ctxt: &PatCtxt<'_, 'tcx>,
|
pat_ctxt: &PatCtxt<'_, 'tcx>,
|
||||||
id: hir::HirId,
|
id: hir::HirId,
|
||||||
span: Span,
|
span: Span,
|
||||||
infcx: InferCtxt<'a, 'tcx>,
|
infcx: InferCtxt<'tcx>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
trace!(?pat_ctxt.typeck_results.hir_owner);
|
trace!(?pat_ctxt.typeck_results.hir_owner);
|
||||||
ConstToPat {
|
ConstToPat {
|
||||||
|
@ -25,7 +25,7 @@ struct AutoderefSnapshot<'tcx> {
|
|||||||
|
|
||||||
pub struct Autoderef<'a, 'tcx> {
|
pub struct Autoderef<'a, 'tcx> {
|
||||||
// Meta infos:
|
// Meta infos:
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
overloaded_span: Span,
|
overloaded_span: Span,
|
||||||
body_id: hir::HirId,
|
body_id: hir::HirId,
|
||||||
@ -94,7 +94,7 @@ impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> {
|
|||||||
|
|
||||||
impl<'a, 'tcx> Autoderef<'a, 'tcx> {
|
impl<'a, 'tcx> Autoderef<'a, 'tcx> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body_id: hir::HirId,
|
body_id: hir::HirId,
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -59,7 +59,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
) -> traits::EvaluationResult;
|
) -> traits::EvaluationResult;
|
||||||
}
|
}
|
||||||
impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
|
impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||||
fn type_is_copy_modulo_regions(
|
fn type_is_copy_modulo_regions(
|
||||||
&self,
|
&self,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
@ -142,7 +142,7 @@ pub trait InferCtxtBuilderExt<'tcx> {
|
|||||||
fn enter_canonical_trait_query<K, R>(
|
fn enter_canonical_trait_query<K, R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
canonical_key: &Canonical<'tcx, K>,
|
canonical_key: &Canonical<'tcx, K>,
|
||||||
operation: impl FnOnce(&InferCtxt<'_, 'tcx>, &mut dyn TraitEngine<'tcx>, K) -> Fallible<R>,
|
operation: impl FnOnce(&InferCtxt<'tcx>, &mut dyn TraitEngine<'tcx>, K) -> Fallible<R>,
|
||||||
) -> Fallible<CanonicalizedQueryResponse<'tcx, R>>
|
) -> Fallible<CanonicalizedQueryResponse<'tcx, R>>
|
||||||
where
|
where
|
||||||
K: TypeFoldable<'tcx>,
|
K: TypeFoldable<'tcx>,
|
||||||
@ -170,7 +170,7 @@ impl<'tcx> InferCtxtBuilderExt<'tcx> for InferCtxtBuilder<'tcx> {
|
|||||||
fn enter_canonical_trait_query<K, R>(
|
fn enter_canonical_trait_query<K, R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
canonical_key: &Canonical<'tcx, K>,
|
canonical_key: &Canonical<'tcx, K>,
|
||||||
operation: impl FnOnce(&InferCtxt<'_, 'tcx>, &mut dyn TraitEngine<'tcx>, K) -> Fallible<R>,
|
operation: impl FnOnce(&InferCtxt<'tcx>, &mut dyn TraitEngine<'tcx>, K) -> Fallible<R>,
|
||||||
) -> Fallible<CanonicalizedQueryResponse<'tcx, R>>
|
) -> Fallible<CanonicalizedQueryResponse<'tcx, R>>
|
||||||
where
|
where
|
||||||
K: TypeFoldable<'tcx>,
|
K: TypeFoldable<'tcx>,
|
||||||
|
@ -272,7 +272,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||||||
/// user.
|
/// user.
|
||||||
fn evaluate_predicates(
|
fn evaluate_predicates(
|
||||||
&self,
|
&self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
trait_did: DefId,
|
trait_did: DefId,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
@ -877,7 +877,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||||||
|
|
||||||
pub fn clean_pred(
|
pub fn clean_pred(
|
||||||
&self,
|
&self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
p: ty::Predicate<'tcx>,
|
p: ty::Predicate<'tcx>,
|
||||||
) -> ty::Predicate<'tcx> {
|
) -> ty::Predicate<'tcx> {
|
||||||
infcx.freshen(p)
|
infcx.freshen(p)
|
||||||
|
@ -28,7 +28,7 @@ impl FulfillmentContext<'_> {
|
|||||||
impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
||||||
fn normalize_projection_type(
|
fn normalize_projection_type(
|
||||||
&mut self,
|
&mut self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
_param_env: ty::ParamEnv<'tcx>,
|
_param_env: ty::ParamEnv<'tcx>,
|
||||||
projection_ty: ty::ProjectionTy<'tcx>,
|
projection_ty: ty::ProjectionTy<'tcx>,
|
||||||
_cause: ObligationCause<'tcx>,
|
_cause: ObligationCause<'tcx>,
|
||||||
@ -38,7 +38,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
|||||||
|
|
||||||
fn register_predicate_obligation(
|
fn register_predicate_obligation(
|
||||||
&mut self,
|
&mut self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
obligation: PredicateObligation<'tcx>,
|
obligation: PredicateObligation<'tcx>,
|
||||||
) {
|
) {
|
||||||
assert!(!infcx.is_in_snapshot());
|
assert!(!infcx.is_in_snapshot());
|
||||||
@ -49,7 +49,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
|||||||
self.obligations.insert(obligation);
|
self.obligations.insert(obligation);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_all_or_error(&mut self, infcx: &InferCtxt<'_, 'tcx>) -> Vec<FulfillmentError<'tcx>> {
|
fn select_all_or_error(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<FulfillmentError<'tcx>> {
|
||||||
{
|
{
|
||||||
let errors = self.select_where_possible(infcx);
|
let errors = self.select_where_possible(infcx);
|
||||||
|
|
||||||
@ -71,10 +71,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_where_possible(
|
fn select_where_possible(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<FulfillmentError<'tcx>> {
|
||||||
&mut self,
|
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
|
||||||
) -> Vec<FulfillmentError<'tcx>> {
|
|
||||||
assert!(!infcx.is_in_snapshot());
|
assert!(!infcx.is_in_snapshot());
|
||||||
|
|
||||||
let mut errors = Vec::new();
|
let mut errors = Vec::new();
|
||||||
|
@ -167,7 +167,7 @@ fn overlap_within_probe<'cx, 'tcx>(
|
|||||||
impl1_def_id: DefId,
|
impl1_def_id: DefId,
|
||||||
impl2_def_id: DefId,
|
impl2_def_id: DefId,
|
||||||
overlap_mode: OverlapMode,
|
overlap_mode: OverlapMode,
|
||||||
snapshot: &CombinedSnapshot<'_, 'tcx>,
|
snapshot: &CombinedSnapshot<'tcx>,
|
||||||
) -> Option<OverlapResult<'tcx>> {
|
) -> Option<OverlapResult<'tcx>> {
|
||||||
let infcx = selcx.infcx();
|
let infcx = selcx.infcx();
|
||||||
|
|
||||||
@ -327,8 +327,8 @@ fn negative_impl<'cx, 'tcx>(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn equate<'cx, 'tcx>(
|
fn equate<'tcx>(
|
||||||
infcx: &InferCtxt<'cx, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
impl_env: ty::ParamEnv<'tcx>,
|
impl_env: ty::ParamEnv<'tcx>,
|
||||||
subject1: ImplSubject<'tcx>,
|
subject1: ImplSubject<'tcx>,
|
||||||
subject2: ImplSubject<'tcx>,
|
subject2: ImplSubject<'tcx>,
|
||||||
@ -379,8 +379,8 @@ fn negative_impl_exists<'cx, 'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(infcx))]
|
#[instrument(level = "debug", skip(infcx))]
|
||||||
fn resolve_negative_obligation<'cx, 'tcx>(
|
fn resolve_negative_obligation<'tcx>(
|
||||||
infcx: InferCtxt<'cx, 'tcx>,
|
infcx: InferCtxt<'tcx>,
|
||||||
o: &PredicateObligation<'tcx>,
|
o: &PredicateObligation<'tcx>,
|
||||||
body_def_id: DefId,
|
body_def_id: DefId,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
@ -159,8 +159,8 @@ pub fn try_unify_abstract_consts<'tcx>(
|
|||||||
|
|
||||||
/// Check if a given constant can be evaluated.
|
/// Check if a given constant can be evaluated.
|
||||||
#[instrument(skip(infcx), level = "debug")]
|
#[instrument(skip(infcx), level = "debug")]
|
||||||
pub fn is_const_evaluatable<'cx, 'tcx>(
|
pub fn is_const_evaluatable<'tcx>(
|
||||||
infcx: &InferCtxt<'cx, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
uv: ty::UnevaluatedConst<'tcx>,
|
uv: ty::UnevaluatedConst<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -41,16 +41,16 @@ impl<'tcx> TraitEngineExt<'tcx> for dyn TraitEngine<'tcx> {
|
|||||||
/// Used if you want to have pleasant experience when dealing
|
/// Used if you want to have pleasant experience when dealing
|
||||||
/// with obligations outside of hir or mir typeck.
|
/// with obligations outside of hir or mir typeck.
|
||||||
pub struct ObligationCtxt<'a, 'tcx> {
|
pub struct ObligationCtxt<'a, 'tcx> {
|
||||||
pub infcx: &'a InferCtxt<'a, 'tcx>,
|
pub infcx: &'a InferCtxt<'tcx>,
|
||||||
engine: RefCell<Box<dyn TraitEngine<'tcx>>>,
|
engine: RefCell<Box<dyn TraitEngine<'tcx>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
|
||||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
|
pub fn new(infcx: &'a InferCtxt<'tcx>) -> Self {
|
||||||
Self { infcx, engine: RefCell::new(<dyn TraitEngine<'_>>::new(infcx.tcx)) }
|
Self { infcx, engine: RefCell::new(<dyn TraitEngine<'_>>::new(infcx.tcx)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_in_snapshot(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
|
pub fn new_in_snapshot(infcx: &'a InferCtxt<'tcx>) -> Self {
|
||||||
Self { infcx, engine: RefCell::new(<dyn TraitEngine<'_>>::new_in_snapshot(infcx.tcx)) }
|
Self { infcx, engine: RefCell::new(<dyn TraitEngine<'_>>::new_in_snapshot(infcx.tcx)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ pub trait TypeErrCtxtExt<'tcx> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'_, 'tcx> {
|
impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||||
/// Given some node representing a fn-like thing in the HIR map,
|
/// Given some node representing a fn-like thing in the HIR map,
|
||||||
/// returns a span and `ArgKind` information that describes the
|
/// returns a span and `ArgKind` information that describes the
|
||||||
/// arguments it expects. This can be supplied to
|
/// arguments it expects. This can be supplied to
|
||||||
@ -2515,7 +2515,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
pred: ty::PolyTraitRef<'tcx>,
|
pred: ty::PolyTraitRef<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
struct ParamToVarFolder<'a, 'tcx> {
|
struct ParamToVarFolder<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>,
|
var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ impl<'tcx, 'a> GeneratorData<'tcx, 'a> {
|
|||||||
// meet an obligation
|
// meet an obligation
|
||||||
fn try_get_upvar_span<F>(
|
fn try_get_upvar_span<F>(
|
||||||
&self,
|
&self,
|
||||||
infer_context: &InferCtxt<'a, 'tcx>,
|
infer_context: &InferCtxt<'tcx>,
|
||||||
generator_did: DefId,
|
generator_did: DefId,
|
||||||
ty_matches: F,
|
ty_matches: F,
|
||||||
) -> Option<GeneratorInteriorOrUpvar>
|
) -> Option<GeneratorInteriorOrUpvar>
|
||||||
@ -1586,7 +1586,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
expected: ty::PolyTraitRef<'tcx>,
|
expected: ty::PolyTraitRef<'tcx>,
|
||||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||||
pub(crate) fn build_fn_sig_ty<'tcx>(
|
pub(crate) fn build_fn_sig_ty<'tcx>(
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
let inputs = trait_ref.skip_binder().substs.type_at(1);
|
let inputs = trait_ref.skip_binder().substs.type_at(1);
|
||||||
|
@ -137,7 +137,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
|||||||
#[instrument(level = "debug", skip(self, infcx, param_env, cause))]
|
#[instrument(level = "debug", skip(self, infcx, param_env, cause))]
|
||||||
fn normalize_projection_type(
|
fn normalize_projection_type(
|
||||||
&mut self,
|
&mut self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
projection_ty: ty::ProjectionTy<'tcx>,
|
projection_ty: ty::ProjectionTy<'tcx>,
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
@ -165,7 +165,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
|||||||
|
|
||||||
fn register_predicate_obligation(
|
fn register_predicate_obligation(
|
||||||
&mut self,
|
&mut self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
obligation: PredicateObligation<'tcx>,
|
obligation: PredicateObligation<'tcx>,
|
||||||
) {
|
) {
|
||||||
// this helps to reduce duplicate errors, as well as making
|
// this helps to reduce duplicate errors, as well as making
|
||||||
@ -182,7 +182,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
|||||||
.register_obligation(PendingPredicateObligation { obligation, stalled_on: vec![] });
|
.register_obligation(PendingPredicateObligation { obligation, stalled_on: vec![] });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_all_or_error(&mut self, infcx: &InferCtxt<'_, 'tcx>) -> Vec<FulfillmentError<'tcx>> {
|
fn select_all_or_error(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<FulfillmentError<'tcx>> {
|
||||||
{
|
{
|
||||||
let errors = self.select_where_possible(infcx);
|
let errors = self.select_where_possible(infcx);
|
||||||
if !errors.is_empty() {
|
if !errors.is_empty() {
|
||||||
@ -193,10 +193,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
|||||||
self.predicates.to_errors(CodeAmbiguity).into_iter().map(to_fulfillment_error).collect()
|
self.predicates.to_errors(CodeAmbiguity).into_iter().map(to_fulfillment_error).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_where_possible(
|
fn select_where_possible(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<FulfillmentError<'tcx>> {
|
||||||
&mut self,
|
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
|
||||||
) -> Vec<FulfillmentError<'tcx>> {
|
|
||||||
let selcx = SelectionContext::new(infcx);
|
let selcx = SelectionContext::new(infcx);
|
||||||
self.select(selcx)
|
self.select(selcx)
|
||||||
}
|
}
|
||||||
|
@ -140,8 +140,8 @@ pub fn predicates_for_generics<'tcx>(
|
|||||||
/// `bound` or is not known to meet bound (note that this is
|
/// `bound` or is not known to meet bound (note that this is
|
||||||
/// conservative towards *no impl*, which is the opposite of the
|
/// conservative towards *no impl*, which is the opposite of the
|
||||||
/// `evaluate` methods).
|
/// `evaluate` methods).
|
||||||
pub fn type_known_to_meet_bound_modulo_regions<'a, 'tcx>(
|
pub fn type_known_to_meet_bound_modulo_regions<'tcx>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
@ -393,8 +393,8 @@ pub fn normalize_param_env_or_error<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Normalize a type and process all resulting obligations, returning any errors
|
/// Normalize a type and process all resulting obligations, returning any errors
|
||||||
pub fn fully_normalize<'a, 'tcx, T>(
|
pub fn fully_normalize<'tcx, T>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
value: T,
|
value: T,
|
||||||
@ -429,8 +429,8 @@ where
|
|||||||
|
|
||||||
/// Process an obligation (and any nested obligations that come from it) to
|
/// Process an obligation (and any nested obligations that come from it) to
|
||||||
/// completion, returning any errors
|
/// completion, returning any errors
|
||||||
pub fn fully_solve_obligation<'a, 'tcx>(
|
pub fn fully_solve_obligation<'tcx>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
obligation: PredicateObligation<'tcx>,
|
obligation: PredicateObligation<'tcx>,
|
||||||
) -> Vec<FulfillmentError<'tcx>> {
|
) -> Vec<FulfillmentError<'tcx>> {
|
||||||
let mut engine = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
|
let mut engine = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
|
||||||
@ -440,8 +440,8 @@ pub fn fully_solve_obligation<'a, 'tcx>(
|
|||||||
|
|
||||||
/// Process a set of obligations (and any nested obligations that come from them)
|
/// Process a set of obligations (and any nested obligations that come from them)
|
||||||
/// to completion
|
/// to completion
|
||||||
pub fn fully_solve_obligations<'a, 'tcx>(
|
pub fn fully_solve_obligations<'tcx>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>,
|
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>,
|
||||||
) -> Vec<FulfillmentError<'tcx>> {
|
) -> Vec<FulfillmentError<'tcx>> {
|
||||||
let mut engine = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
|
let mut engine = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
|
||||||
@ -452,8 +452,8 @@ pub fn fully_solve_obligations<'a, 'tcx>(
|
|||||||
/// Process a bound (and any nested obligations that come from it) to completion.
|
/// Process a bound (and any nested obligations that come from it) to completion.
|
||||||
/// This is a convenience function for traits that have no generic arguments, such
|
/// This is a convenience function for traits that have no generic arguments, such
|
||||||
/// as auto traits, and builtin traits like Copy or Sized.
|
/// as auto traits, and builtin traits like Copy or Sized.
|
||||||
pub fn fully_solve_bound<'a, 'tcx>(
|
pub fn fully_solve_bound<'tcx>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
|
@ -26,7 +26,7 @@ pub trait InferCtxtExt<'a, 'tcx> {
|
|||||||
) -> Bounds<'a, 'tcx>;
|
) -> Bounds<'a, 'tcx>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'cx, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'cx, 'tcx> {
|
impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
|
||||||
/// Implied bounds are region relationships that we deduce
|
/// Implied bounds are region relationships that we deduce
|
||||||
/// automatically. The idea is that (e.g.) a caller must check that a
|
/// automatically. The idea is that (e.g.) a caller must check that a
|
||||||
/// function's argument types are well-formed immediately before
|
/// function's argument types are well-formed immediately before
|
||||||
|
@ -663,7 +663,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct BoundVarReplacer<'me, 'tcx> {
|
pub struct BoundVarReplacer<'me, 'tcx> {
|
||||||
infcx: &'me InferCtxt<'me, 'tcx>,
|
infcx: &'me InferCtxt<'tcx>,
|
||||||
// These three maps track the bound variable that were replaced by placeholders. It might be
|
// These three maps track the bound variable that were replaced by placeholders. It might be
|
||||||
// nice to remove these since we already have the `kind` in the placeholder; we really just need
|
// nice to remove these since we already have the `kind` in the placeholder; we really just need
|
||||||
// the `var` (but we *could* bring that into scope if we were to track them as we pass them).
|
// the `var` (but we *could* bring that into scope if we were to track them as we pass them).
|
||||||
@ -691,7 +691,7 @@ pub struct BoundVarReplacer<'me, 'tcx> {
|
|||||||
/// FIXME(@lcnr): We may even consider experimenting with eagerly replacing bound vars during
|
/// FIXME(@lcnr): We may even consider experimenting with eagerly replacing bound vars during
|
||||||
/// normalization as well, at which point this function will be unnecessary and can be removed.
|
/// normalization as well, at which point this function will be unnecessary and can be removed.
|
||||||
pub fn with_replaced_escaping_bound_vars<'a, 'tcx, T: TypeFoldable<'tcx>, R: TypeFoldable<'tcx>>(
|
pub fn with_replaced_escaping_bound_vars<'a, 'tcx, T: TypeFoldable<'tcx>, R: TypeFoldable<'tcx>>(
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
universe_indices: &'a mut Vec<Option<ty::UniverseIndex>>,
|
universe_indices: &'a mut Vec<Option<ty::UniverseIndex>>,
|
||||||
value: T,
|
value: T,
|
||||||
f: impl FnOnce(T) -> R,
|
f: impl FnOnce(T) -> R,
|
||||||
@ -717,7 +717,7 @@ impl<'me, 'tcx> BoundVarReplacer<'me, 'tcx> {
|
|||||||
/// Returns `Some` if we *were* able to replace bound vars. If there are any bound vars that
|
/// Returns `Some` if we *were* able to replace bound vars. If there are any bound vars that
|
||||||
/// use a binding level above `universe_indices.len()`, we fail.
|
/// use a binding level above `universe_indices.len()`, we fail.
|
||||||
pub fn replace_bound_vars<T: TypeFoldable<'tcx>>(
|
pub fn replace_bound_vars<T: TypeFoldable<'tcx>>(
|
||||||
infcx: &'me InferCtxt<'me, 'tcx>,
|
infcx: &'me InferCtxt<'tcx>,
|
||||||
universe_indices: &'me mut Vec<Option<ty::UniverseIndex>>,
|
universe_indices: &'me mut Vec<Option<ty::UniverseIndex>>,
|
||||||
value: T,
|
value: T,
|
||||||
) -> (
|
) -> (
|
||||||
@ -837,7 +837,7 @@ impl<'tcx> TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> {
|
|||||||
|
|
||||||
// The inverse of `BoundVarReplacer`: replaces placeholders with the bound vars from which they came.
|
// The inverse of `BoundVarReplacer`: replaces placeholders with the bound vars from which they came.
|
||||||
pub struct PlaceholderReplacer<'me, 'tcx> {
|
pub struct PlaceholderReplacer<'me, 'tcx> {
|
||||||
infcx: &'me InferCtxt<'me, 'tcx>,
|
infcx: &'me InferCtxt<'tcx>,
|
||||||
mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
||||||
mapped_types: BTreeMap<ty::PlaceholderType, ty::BoundTy>,
|
mapped_types: BTreeMap<ty::PlaceholderType, ty::BoundTy>,
|
||||||
mapped_consts: BTreeMap<ty::PlaceholderConst<'tcx>, ty::BoundVar>,
|
mapped_consts: BTreeMap<ty::PlaceholderConst<'tcx>, ty::BoundVar>,
|
||||||
@ -847,7 +847,7 @@ pub struct PlaceholderReplacer<'me, 'tcx> {
|
|||||||
|
|
||||||
impl<'me, 'tcx> PlaceholderReplacer<'me, 'tcx> {
|
impl<'me, 'tcx> PlaceholderReplacer<'me, 'tcx> {
|
||||||
pub fn replace_placeholders<T: TypeFoldable<'tcx>>(
|
pub fn replace_placeholders<T: TypeFoldable<'tcx>>(
|
||||||
infcx: &'me InferCtxt<'me, 'tcx>,
|
infcx: &'me InferCtxt<'tcx>,
|
||||||
mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
||||||
mapped_types: BTreeMap<ty::PlaceholderType, ty::BoundTy>,
|
mapped_types: BTreeMap<ty::PlaceholderType, ty::BoundTy>,
|
||||||
mapped_consts: BTreeMap<ty::PlaceholderConst<'tcx>, ty::BoundVar>,
|
mapped_consts: BTreeMap<ty::PlaceholderConst<'tcx>, ty::BoundVar>,
|
||||||
|
@ -31,7 +31,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||||||
) -> EvaluationResult;
|
) -> EvaluationResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
|
impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||||
/// Evaluates whether the predicate can be satisfied (by any means)
|
/// Evaluates whether the predicate can be satisfied (by any means)
|
||||||
/// in the given `ParamEnv`.
|
/// in the given `ParamEnv`.
|
||||||
fn predicate_may_hold(&self, obligation: &PredicateObligation<'tcx>) -> bool {
|
fn predicate_may_hold(&self, obligation: &PredicateObligation<'tcx>) -> bool {
|
||||||
|
@ -154,7 +154,7 @@ impl<'tcx> TypeVisitor<'tcx> for MaxEscapingBoundVarVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct QueryNormalizer<'cx, 'tcx> {
|
struct QueryNormalizer<'cx, 'tcx> {
|
||||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
infcx: &'cx InferCtxt<'tcx>,
|
||||||
cause: &'cx ObligationCause<'tcx>,
|
cause: &'cx ObligationCause<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
obligations: Vec<PredicateObligation<'tcx>>,
|
obligations: Vec<PredicateObligation<'tcx>>,
|
||||||
|
@ -16,7 +16,7 @@ pub struct CustomTypeOp<F, G> {
|
|||||||
impl<F, G> CustomTypeOp<F, G> {
|
impl<F, G> CustomTypeOp<F, G> {
|
||||||
pub fn new<'tcx, R>(closure: F, description: G) -> Self
|
pub fn new<'tcx, R>(closure: F, description: G) -> Self
|
||||||
where
|
where
|
||||||
F: FnOnce(&InferCtxt<'_, 'tcx>) -> Fallible<InferOk<'tcx, R>>,
|
F: FnOnce(&InferCtxt<'tcx>) -> Fallible<InferOk<'tcx, R>>,
|
||||||
G: Fn() -> String,
|
G: Fn() -> String,
|
||||||
{
|
{
|
||||||
CustomTypeOp { closure, description }
|
CustomTypeOp { closure, description }
|
||||||
@ -25,7 +25,7 @@ impl<F, G> CustomTypeOp<F, G> {
|
|||||||
|
|
||||||
impl<'tcx, F, R: fmt::Debug, G> super::TypeOp<'tcx> for CustomTypeOp<F, G>
|
impl<'tcx, F, R: fmt::Debug, G> super::TypeOp<'tcx> for CustomTypeOp<F, G>
|
||||||
where
|
where
|
||||||
F: for<'a, 'cx> FnOnce(&'a InferCtxt<'cx, 'tcx>) -> Fallible<InferOk<'tcx, R>>,
|
F: for<'a, 'cx> FnOnce(&'a InferCtxt<'tcx>) -> Fallible<InferOk<'tcx, R>>,
|
||||||
G: Fn() -> String,
|
G: Fn() -> String,
|
||||||
{
|
{
|
||||||
type Output = R;
|
type Output = R;
|
||||||
@ -36,7 +36,7 @@ where
|
|||||||
/// Processes the operation and all resulting obligations,
|
/// Processes the operation and all resulting obligations,
|
||||||
/// returning the final result along with any region constraints
|
/// returning the final result along with any region constraints
|
||||||
/// (they will be given over to the NLL region solver).
|
/// (they will be given over to the NLL region solver).
|
||||||
fn fully_perform(self, infcx: &InferCtxt<'_, 'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
|
fn fully_perform(self, infcx: &InferCtxt<'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
info!("fully_perform({:?})", self);
|
info!("fully_perform({:?})", self);
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ where
|
|||||||
/// Executes `op` and then scrapes out all the "old style" region
|
/// Executes `op` and then scrapes out all the "old style" region
|
||||||
/// constraints that result, creating query-region-constraints.
|
/// constraints that result, creating query-region-constraints.
|
||||||
pub fn scrape_region_constraints<'tcx, Op: super::TypeOp<'tcx, Output = R>, R>(
|
pub fn scrape_region_constraints<'tcx, Op: super::TypeOp<'tcx, Output = R>, R>(
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
op: impl FnOnce() -> Fallible<InferOk<'tcx, R>>,
|
op: impl FnOnce() -> Fallible<InferOk<'tcx, R>>,
|
||||||
) -> Fallible<(TypeOpOutput<'tcx, Op>, RegionConstraintData<'tcx>)> {
|
) -> Fallible<(TypeOpOutput<'tcx, Op>, RegionConstraintData<'tcx>)> {
|
||||||
// During NLL, we expect that nobody will register region
|
// During NLL, we expect that nobody will register region
|
||||||
|
@ -32,7 +32,7 @@ pub trait TypeOp<'tcx>: Sized + fmt::Debug {
|
|||||||
/// Processes the operation and all resulting obligations,
|
/// Processes the operation and all resulting obligations,
|
||||||
/// returning the final result along with any region constraints
|
/// returning the final result along with any region constraints
|
||||||
/// (they will be given over to the NLL region solver).
|
/// (they will be given over to the NLL region solver).
|
||||||
fn fully_perform(self, infcx: &InferCtxt<'_, 'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>>;
|
fn fully_perform(self, infcx: &InferCtxt<'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The output from performing a type op
|
/// The output from performing a type op
|
||||||
@ -78,7 +78,7 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<'tcx> + 'tcx {
|
|||||||
|
|
||||||
fn fully_perform_into(
|
fn fully_perform_into(
|
||||||
query_key: ParamEnvAnd<'tcx, Self>,
|
query_key: ParamEnvAnd<'tcx, Self>,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
output_query_region_constraints: &mut QueryRegionConstraints<'tcx>,
|
output_query_region_constraints: &mut QueryRegionConstraints<'tcx>,
|
||||||
) -> Fallible<(
|
) -> Fallible<(
|
||||||
Self::QueryResponse,
|
Self::QueryResponse,
|
||||||
@ -120,7 +120,7 @@ where
|
|||||||
type Output = Q::QueryResponse;
|
type Output = Q::QueryResponse;
|
||||||
type ErrorInfo = Canonical<'tcx, ParamEnvAnd<'tcx, Q>>;
|
type ErrorInfo = Canonical<'tcx, ParamEnvAnd<'tcx, Q>>;
|
||||||
|
|
||||||
fn fully_perform(self, infcx: &InferCtxt<'_, 'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
|
fn fully_perform(self, infcx: &InferCtxt<'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
|
||||||
let mut region_constraints = QueryRegionConstraints::default();
|
let mut region_constraints = QueryRegionConstraints::default();
|
||||||
let (output, error_info, mut obligations, _) =
|
let (output, error_info, mut obligations, _) =
|
||||||
Q::fully_perform_into(self, infcx, &mut region_constraints)?;
|
Q::fully_perform_into(self, infcx, &mut region_constraints)?;
|
||||||
|
@ -6,7 +6,7 @@ use rustc_middle::ty::{self, ToPredicate};
|
|||||||
|
|
||||||
pub(crate) fn update<'tcx, T>(
|
pub(crate) fn update<'tcx, T>(
|
||||||
engine: &mut T,
|
engine: &mut T,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
) where
|
) where
|
||||||
T: TraitEngine<'tcx>,
|
T: TraitEngine<'tcx>,
|
||||||
|
@ -93,7 +93,7 @@ impl IntercrateAmbiguityCause {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct SelectionContext<'cx, 'tcx> {
|
pub struct SelectionContext<'cx, 'tcx> {
|
||||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
infcx: &'cx InferCtxt<'tcx>,
|
||||||
|
|
||||||
/// Freshener used specifically for entries on the obligation
|
/// Freshener used specifically for entries on the obligation
|
||||||
/// stack. This ensures that all entries on the stack at one time
|
/// stack. This ensures that all entries on the stack at one time
|
||||||
@ -214,7 +214,7 @@ enum BuiltinImplConditions<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
pub fn new(infcx: &'cx InferCtxt<'cx, 'tcx>) -> SelectionContext<'cx, 'tcx> {
|
pub fn new(infcx: &'cx InferCtxt<'tcx>) -> SelectionContext<'cx, 'tcx> {
|
||||||
SelectionContext {
|
SelectionContext {
|
||||||
infcx,
|
infcx,
|
||||||
freshener: infcx.freshener_keep_static(),
|
freshener: infcx.freshener_keep_static(),
|
||||||
@ -224,12 +224,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn intercrate(infcx: &'cx InferCtxt<'cx, 'tcx>) -> SelectionContext<'cx, 'tcx> {
|
pub fn intercrate(infcx: &'cx InferCtxt<'tcx>) -> SelectionContext<'cx, 'tcx> {
|
||||||
SelectionContext { intercrate: true, ..SelectionContext::new(infcx) }
|
SelectionContext { intercrate: true, ..SelectionContext::new(infcx) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_query_mode(
|
pub fn with_query_mode(
|
||||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
infcx: &'cx InferCtxt<'tcx>,
|
||||||
query_mode: TraitQueryMode,
|
query_mode: TraitQueryMode,
|
||||||
) -> SelectionContext<'cx, 'tcx> {
|
) -> SelectionContext<'cx, 'tcx> {
|
||||||
debug!(?query_mode, "with_query_mode");
|
debug!(?query_mode, "with_query_mode");
|
||||||
@ -253,7 +253,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
self.intercrate_ambiguity_causes.take().unwrap_or_default()
|
self.intercrate_ambiguity_causes.take().unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn infcx(&self) -> &'cx InferCtxt<'cx, 'tcx> {
|
pub fn infcx(&self) -> &'cx InferCtxt<'tcx> {
|
||||||
self.infcx
|
self.infcx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ pub struct OverlapError {
|
|||||||
/// through associated type projection. We deal with such cases by using
|
/// through associated type projection. We deal with such cases by using
|
||||||
/// *fulfillment* to relate the two impls, requiring that all projections are
|
/// *fulfillment* to relate the two impls, requiring that all projections are
|
||||||
/// resolved.
|
/// resolved.
|
||||||
pub fn translate_substs<'a, 'tcx>(
|
pub fn translate_substs<'tcx>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
source_impl: DefId,
|
source_impl: DefId,
|
||||||
source_substs: SubstsRef<'tcx>,
|
source_substs: SubstsRef<'tcx>,
|
||||||
@ -176,8 +176,8 @@ pub(super) fn specializes(tcx: TyCtxt<'_>, (impl1_def_id, impl2_def_id): (DefId,
|
|||||||
/// generics of `target_impl`, including both those needed to unify with
|
/// generics of `target_impl`, including both those needed to unify with
|
||||||
/// `source_trait_ref` and those whose identity is determined via a where
|
/// `source_trait_ref` and those whose identity is determined via a where
|
||||||
/// clause in the impl.
|
/// clause in the impl.
|
||||||
fn fulfill_implication<'a, 'tcx>(
|
fn fulfill_implication<'tcx>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
source_trait_ref: ty::TraitRef<'tcx>,
|
source_trait_ref: ty::TraitRef<'tcx>,
|
||||||
target_impl: DefId,
|
target_impl: DefId,
|
||||||
|
@ -68,7 +68,7 @@ pub fn search_for_adt_const_param_violation<'tcx>(
|
|||||||
/// Note that this does *not* recursively check if the substructure of `adt_ty`
|
/// Note that this does *not* recursively check if the substructure of `adt_ty`
|
||||||
/// implements the traits.
|
/// implements the traits.
|
||||||
fn type_marked_structural<'tcx>(
|
fn type_marked_structural<'tcx>(
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
adt_ty: Ty<'tcx>,
|
adt_ty: Ty<'tcx>,
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
@ -14,8 +14,8 @@ use std::iter;
|
|||||||
/// inference variable, returns `None`, because we are not able to
|
/// inference variable, returns `None`, because we are not able to
|
||||||
/// make any progress at all. This is to prevent "livelock" where we
|
/// make any progress at all. This is to prevent "livelock" where we
|
||||||
/// say "$0 is WF if $0 is WF".
|
/// say "$0 is WF if $0 is WF".
|
||||||
pub fn obligations<'a, 'tcx>(
|
pub fn obligations<'tcx>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body_id: hir::HirId,
|
body_id: hir::HirId,
|
||||||
recursion_depth: usize,
|
recursion_depth: usize,
|
||||||
@ -79,8 +79,8 @@ pub fn obligations<'a, 'tcx>(
|
|||||||
/// well-formed. For example, if there is a trait `Set` defined like
|
/// well-formed. For example, if there is a trait `Set` defined like
|
||||||
/// `trait Set<K:Eq>`, then the trait reference `Foo: Set<Bar>` is WF
|
/// `trait Set<K:Eq>`, then the trait reference `Foo: Set<Bar>` is WF
|
||||||
/// if `Bar: Eq`.
|
/// if `Bar: Eq`.
|
||||||
pub fn trait_obligations<'a, 'tcx>(
|
pub fn trait_obligations<'tcx>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body_id: hir::HirId,
|
body_id: hir::HirId,
|
||||||
trait_pred: &ty::TraitPredicate<'tcx>,
|
trait_pred: &ty::TraitPredicate<'tcx>,
|
||||||
@ -102,8 +102,8 @@ pub fn trait_obligations<'a, 'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(infcx), ret)]
|
#[instrument(skip(infcx), ret)]
|
||||||
pub fn predicate_obligations<'a, 'tcx>(
|
pub fn predicate_obligations<'tcx>(
|
||||||
infcx: &InferCtxt<'a, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body_id: hir::HirId,
|
body_id: hir::HirId,
|
||||||
predicate: ty::Predicate<'tcx>,
|
predicate: ty::Predicate<'tcx>,
|
||||||
@ -275,7 +275,7 @@ impl<'tcx> WfPredicates<'tcx> {
|
|||||||
traits::ObligationCause::new(self.span, self.body_id, code)
|
traits::ObligationCause::new(self.span, self.body_id, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn normalize(self, infcx: &InferCtxt<'_, 'tcx>) -> Vec<traits::PredicateObligation<'tcx>> {
|
fn normalize(self, infcx: &InferCtxt<'tcx>) -> Vec<traits::PredicateObligation<'tcx>> {
|
||||||
let cause = self.cause(traits::WellFormed(None));
|
let cause = self.cause(traits::WellFormed(None));
|
||||||
let param_env = self.param_env;
|
let param_env = self.param_env;
|
||||||
let mut obligations = Vec::with_capacity(self.out.len());
|
let mut obligations = Vec::with_capacity(self.out.len());
|
||||||
|
@ -35,7 +35,7 @@ fn implied_outlives_bounds<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compute_implied_outlives_bounds<'tcx>(
|
fn compute_implied_outlives_bounds<'tcx>(
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
) -> Fallible<Vec<OutlivesBound<'tcx>>> {
|
) -> Fallible<Vec<OutlivesBound<'tcx>>> {
|
||||||
|
@ -51,7 +51,7 @@ fn type_op_ascribe_user_type<'tcx>(
|
|||||||
/// this query can be re-run to better track the span of the obligation cause, and improve the error
|
/// this query can be re-run to better track the span of the obligation cause, and improve the error
|
||||||
/// message. Do not call directly unless you're in that very specific context.
|
/// message. Do not call directly unless you're in that very specific context.
|
||||||
pub fn type_op_ascribe_user_type_with_span<'a, 'tcx: 'a>(
|
pub fn type_op_ascribe_user_type_with_span<'a, 'tcx: 'a>(
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
fulfill_cx: &'a mut dyn TraitEngine<'tcx>,
|
fulfill_cx: &'a mut dyn TraitEngine<'tcx>,
|
||||||
key: ParamEnvAnd<'tcx, AscribeUserType<'tcx>>,
|
key: ParamEnvAnd<'tcx, AscribeUserType<'tcx>>,
|
||||||
span: Option<Span>,
|
span: Option<Span>,
|
||||||
@ -68,7 +68,7 @@ pub fn type_op_ascribe_user_type_with_span<'a, 'tcx: 'a>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct AscribeUserTypeCx<'me, 'tcx> {
|
struct AscribeUserTypeCx<'me, 'tcx> {
|
||||||
infcx: &'me InferCtxt<'me, 'tcx>,
|
infcx: &'me InferCtxt<'tcx>,
|
||||||
param_env: ParamEnv<'tcx>,
|
param_env: ParamEnv<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
fulfill_cx: &'me mut dyn TraitEngine<'tcx>,
|
fulfill_cx: &'me mut dyn TraitEngine<'tcx>,
|
||||||
@ -210,7 +210,7 @@ fn type_op_eq<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn type_op_normalize<'tcx, T>(
|
fn type_op_normalize<'tcx, T>(
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
fulfill_cx: &mut dyn TraitEngine<'tcx>,
|
fulfill_cx: &mut dyn TraitEngine<'tcx>,
|
||||||
key: ParamEnvAnd<'tcx, Normalize<T>>,
|
key: ParamEnvAnd<'tcx, Normalize<T>>,
|
||||||
) -> Fallible<T>
|
) -> Fallible<T>
|
||||||
@ -285,7 +285,7 @@ fn type_op_prove_predicate<'tcx>(
|
|||||||
/// this query can be re-run to better track the span of the obligation cause, and improve the error
|
/// this query can be re-run to better track the span of the obligation cause, and improve the error
|
||||||
/// message. Do not call directly unless you're in that very specific context.
|
/// message. Do not call directly unless you're in that very specific context.
|
||||||
pub fn type_op_prove_predicate_with_cause<'a, 'tcx: 'a>(
|
pub fn type_op_prove_predicate_with_cause<'a, 'tcx: 'a>(
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'tcx>,
|
||||||
fulfill_cx: &'a mut dyn TraitEngine<'tcx>,
|
fulfill_cx: &'a mut dyn TraitEngine<'tcx>,
|
||||||
key: ParamEnvAnd<'tcx, ProvePredicate<'tcx>>,
|
key: ParamEnvAnd<'tcx, ProvePredicate<'tcx>>,
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
|
@ -80,11 +80,11 @@ mod rustc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct TransmuteTypeEnv<'cx, 'tcx> {
|
pub struct TransmuteTypeEnv<'cx, 'tcx> {
|
||||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
infcx: &'cx InferCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'cx, 'tcx> TransmuteTypeEnv<'cx, 'tcx> {
|
impl<'cx, 'tcx> TransmuteTypeEnv<'cx, 'tcx> {
|
||||||
pub fn new(infcx: &'cx InferCtxt<'cx, 'tcx>) -> Self {
|
pub fn new(infcx: &'cx InferCtxt<'tcx>) -> Self {
|
||||||
Self { infcx }
|
Self { infcx }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user