Remove TypeckResults from InferCtxt
This commit is contained in:
parent
4a68373217
commit
349415d1c6
67 changed files with 240 additions and 280 deletions
|
@ -31,7 +31,7 @@ use rustc_middle::ty::relate::{Relate, TypeRelation};
|
|||
use rustc_middle::ty::{Const, ImplSubject};
|
||||
|
||||
pub struct At<'a, 'tcx> {
|
||||
pub infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
pub infcx: &'a InferCtxt<'tcx>,
|
||||
pub cause: &'a ObligationCause<'tcx>,
|
||||
pub param_env: ty::ParamEnv<'tcx>,
|
||||
/// Whether we should define opaque types
|
||||
|
@ -48,9 +48,9 @@ pub struct Trace<'a, 'tcx> {
|
|||
trace: TypeTrace<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
#[inline]
|
||||
pub fn at(
|
||||
pub fn at<'a>(
|
||||
&'a self,
|
||||
cause: &'a ObligationCause<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -66,7 +66,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
tcx: self.tcx,
|
||||
defining_use_anchor: self.defining_use_anchor,
|
||||
considering_regions: self.considering_regions,
|
||||
in_progress_typeck_results: self.in_progress_typeck_results,
|
||||
inner: self.inner.clone(),
|
||||
skip_leak_check: self.skip_leak_check.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 smallvec::SmallVec;
|
||||
|
||||
impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
/// Canonicalizes a query value `V`. When we canonicalize a query,
|
||||
/// we not only canonicalize unbound inference variables, but we
|
||||
/// *also* replace all free regions whatsoever. So for example a
|
||||
|
@ -316,7 +316,7 @@ impl CanonicalizeMode for CanonicalizeFreeRegionsOtherThanStatic {
|
|||
}
|
||||
|
||||
struct Canonicalizer<'cx, 'tcx> {
|
||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
||||
infcx: &'cx InferCtxt<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
variables: SmallVec<[CanonicalVarInfo<'tcx>; 8]>,
|
||||
query_state: &'cx mut OriginalQueryValues<'tcx>,
|
||||
|
@ -521,7 +521,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
|||
/// `canonicalize_query` and `canonicalize_response`.
|
||||
fn canonicalize<V>(
|
||||
value: V,
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
infcx: &InferCtxt<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
canonicalize_region_mode: &dyn CanonicalizeMode,
|
||||
query_state: &mut OriginalQueryValues<'tcx>,
|
||||
|
|
|
@ -36,7 +36,7 @@ mod canonicalizer;
|
|||
pub mod query_response;
|
||||
mod substitute;
|
||||
|
||||
impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
/// Creates a substitution S for the canonical value with fresh
|
||||
/// inference variables and applies it to the canonical value.
|
||||
/// Returns both the instantiated result *and* the substitution S.
|
||||
|
|
|
@ -32,7 +32,7 @@ use rustc_span::Span;
|
|||
use std::fmt::Debug;
|
||||
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
|
||||
/// implementation. It is given:
|
||||
///
|
||||
|
@ -677,7 +677,7 @@ pub fn make_query_region_constraints<'tcx>(
|
|||
}
|
||||
|
||||
struct QueryTypeRelatingDelegate<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
obligations: &'a mut Vec<PredicateObligation<'tcx>>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
cause: &'a ObligationCause<'tcx>,
|
||||
|
|
|
@ -43,7 +43,7 @@ use rustc_span::{Span, DUMMY_SP};
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct CombineFields<'infcx, 'tcx> {
|
||||
pub infcx: &'infcx InferCtxt<'infcx, 'tcx>,
|
||||
pub infcx: &'infcx InferCtxt<'tcx>,
|
||||
pub trace: TypeTrace<'tcx>,
|
||||
pub cause: Option<ty::relate::Cause>,
|
||||
pub param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -63,7 +63,7 @@ pub enum RelationDir {
|
|||
EqTo,
|
||||
}
|
||||
|
||||
impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
pub fn super_combine_tys<R>(
|
||||
&self,
|
||||
relation: &mut R,
|
||||
|
@ -452,7 +452,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
|||
}
|
||||
|
||||
struct Generalizer<'cx, 'tcx> {
|
||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
||||
infcx: &'cx InferCtxt<'tcx>,
|
||||
|
||||
/// The span, used when creating new type variables and things.
|
||||
cause: &'cx ObligationCause<'tcx>,
|
||||
|
@ -775,7 +775,7 @@ fn float_unification_error<'tcx>(
|
|||
}
|
||||
|
||||
struct ConstInferUnifier<'cx, 'tcx> {
|
||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
||||
infcx: &'cx InferCtxt<'tcx>,
|
||||
|
||||
span: Span,
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ pub mod nice_region_error;
|
|||
/// field is only populated during an in-progress typeck.
|
||||
/// Get an instance by calling `InferCtxt::err` or `FnCtxt::infer_err`.
|
||||
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>>>,
|
||||
}
|
||||
|
||||
|
@ -103,9 +103,9 @@ impl TypeErrCtxt<'_, '_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Deref for TypeErrCtxt<'a, 'tcx> {
|
||||
type Target = InferCtxt<'a, 'tcx>;
|
||||
fn deref(&self) -> &InferCtxt<'a, 'tcx> {
|
||||
impl<'tcx> Deref for TypeErrCtxt<'_, 'tcx> {
|
||||
type Target = InferCtxt<'tcx>;
|
||||
fn deref(&self) -> &InferCtxt<'tcx> {
|
||||
&self.infcx
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
|
|||
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>>> {
|
||||
if let ty::Opaque(def_id, substs) = ty.kind() {
|
||||
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> {
|
||||
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(
|
||||
&self,
|
||||
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
|
||||
/// statement, peeling off any inner blocks.
|
||||
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 ty_getter = move |ty_vid| {
|
||||
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
|
||||
}
|
||||
|
||||
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 ty = infcx.resolve_vars_if_possible(ty);
|
||||
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
|
||||
/// something users are familiar with. Directly printing the `fn_sig` of closures also
|
||||
/// 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 fn_sig = substs.as_closure().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)
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
/// Extracts data used by diagnostic for either types or constants
|
||||
/// which were stuck during inference.
|
||||
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(
|
||||
&self,
|
||||
kind: hir::GeneratorKind,
|
||||
|
@ -657,7 +657,7 @@ impl<'tcx> InferSource<'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 {
|
||||
InferSourceKind::LetBinding { ty, .. }
|
||||
| InferSourceKind::ClosureArg { ty, .. }
|
||||
|
@ -694,7 +694,7 @@ struct InsertableGenericArgs<'tcx> {
|
|||
/// While doing so, the currently best spot is stored in `infer_source`.
|
||||
/// For details on how we rank spots, see [Self::source_cost]
|
||||
struct FindInferSourceVisitor<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
typeck_results: &'a TypeckResults<'tcx>,
|
||||
|
||||
target: GenericArg<'tcx>,
|
||||
|
@ -706,7 +706,7 @@ struct FindInferSourceVisitor<'a, 'tcx> {
|
|||
|
||||
impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
||||
fn new(
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
typeck_results: &'a TypeckResults<'tcx>,
|
||||
target: GenericArg<'tcx>,
|
||||
) -> Self {
|
||||
|
|
|
@ -38,7 +38,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeVi
|
|||
use std::collections::hash_map::Entry;
|
||||
|
||||
pub struct TypeFreshener<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
ty_freshen_count: u32,
|
||||
const_freshen_count: u32,
|
||||
ty_freshen_map: FxHashMap<ty::InferTy, Ty<'tcx>>,
|
||||
|
@ -47,7 +47,7 @@ pub struct 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 {
|
||||
infcx,
|
||||
ty_freshen_count: 0,
|
||||
|
|
|
@ -43,7 +43,7 @@ struct VariableLengths {
|
|||
region_constraints_len: usize,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
fn variable_lengths(&self) -> VariableLengths {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
VariableLengths {
|
||||
|
@ -167,7 +167,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub struct InferenceFudger<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
type_vars: (Range<TyVid>, Vec<TypeVariableOrigin>),
|
||||
int_vars: Range<IntVid>,
|
||||
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> {
|
||||
fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'tcx> {
|
||||
fn infcx(&self) -> &'infcx InferCtxt<'tcx> {
|
||||
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
|
||||
/// `binder` with placeholder variables in a new universe. This means that the
|
||||
/// 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(
|
||||
&self,
|
||||
overly_polymorphic: bool,
|
||||
snapshot: &CombinedSnapshot<'_, 'tcx>,
|
||||
snapshot: &CombinedSnapshot<'tcx>,
|
||||
) -> RelateResult<'tcx, ()> {
|
||||
// If the user gave `-Zno-leak-check`, or we have been
|
||||
// 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
|
||||
/// "up" the lattice (to bigger values).
|
||||
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>;
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ impl<'tcx> ConstEquateRelation<'tcx> for Lub<'_, '_, '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
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ use rustc_data_structures::undo_log::Rollback;
|
|||
use rustc_data_structures::unify as ut;
|
||||
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::hir_id::OwnerId;
|
||||
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
|
||||
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue};
|
||||
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::{Span, DUMMY_SP};
|
||||
|
||||
use std::cell::{Cell, Ref, RefCell};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::fmt;
|
||||
|
||||
use self::combine::CombineFields;
|
||||
|
@ -254,7 +253,7 @@ pub enum DefiningAnchor {
|
|||
Error,
|
||||
}
|
||||
|
||||
pub struct InferCtxt<'a, 'tcx> {
|
||||
pub struct InferCtxt<'tcx> {
|
||||
pub tcx: TyCtxt<'tcx>,
|
||||
|
||||
/// 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.
|
||||
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>>,
|
||||
|
||||
/// 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>,
|
||||
|
||||
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.
|
||||
|
@ -553,16 +546,13 @@ impl<'tcx> fmt::Display for FixupError<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A temporary returned by `tcx.infer_ctxt()`. This is necessary
|
||||
/// for multiple `InferCtxt` to share the same `in_progress_typeck_results`
|
||||
/// without using `Rc` or something similar.
|
||||
/// Used to configure inference contexts before their creation
|
||||
pub struct InferCtxtBuilder<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
defining_use_anchor: DefiningAnchor,
|
||||
considering_regions: bool,
|
||||
fresh_typeck_results: Option<RefCell<ty::TypeckResults<'tcx>>>,
|
||||
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> {
|
||||
|
@ -575,26 +565,17 @@ impl<'tcx> TyCtxtInferExt<'tcx> for TyCtxt<'tcx> {
|
|||
tcx: self,
|
||||
defining_use_anchor: DefiningAnchor::Error,
|
||||
considering_regions: true,
|
||||
fresh_typeck_results: None,
|
||||
normalize_fn_sig_for_diagnostic: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
/// 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
|
||||
/// (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.
|
||||
pub fn with_opaque_type_inference(mut self, defining_use_anchor: DefiningAnchor) -> Self {
|
||||
self.defining_use_anchor = defining_use_anchor;
|
||||
|
@ -608,7 +589,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
|
|||
|
||||
pub fn with_normalize_fn_sig_for_diagnostic(
|
||||
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.normalize_fn_sig_for_diagnostic = Some(fun);
|
||||
self
|
||||
|
@ -625,7 +606,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
|
|||
&mut self,
|
||||
span: Span,
|
||||
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
|
||||
where
|
||||
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 {
|
||||
tcx,
|
||||
defining_use_anchor,
|
||||
considering_regions,
|
||||
ref fresh_typeck_results,
|
||||
ref normalize_fn_sig_for_diagnostic,
|
||||
} = *self;
|
||||
let in_progress_typeck_results = fresh_typeck_results.as_ref();
|
||||
f(InferCtxt {
|
||||
tcx,
|
||||
defining_use_anchor,
|
||||
considering_regions,
|
||||
in_progress_typeck_results,
|
||||
inner: RefCell::new(InferCtxtInner::new()),
|
||||
lexical_region_resolutions: RefCell::new(None),
|
||||
selection_cache: Default::default(),
|
||||
|
@ -677,7 +655,7 @@ impl<'tcx, T> InferOk<'tcx, T> {
|
|||
/// Extracts `value`, registering any obligations into `fulfill_cx`.
|
||||
pub fn into_value_registering_obligations(
|
||||
self,
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
infcx: &InferCtxt<'tcx>,
|
||||
fulfill_cx: &mut dyn TraitEngine<'tcx>,
|
||||
) -> T {
|
||||
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"]
|
||||
pub struct CombinedSnapshot<'a, 'tcx> {
|
||||
pub struct CombinedSnapshot<'tcx> {
|
||||
undo_snapshot: Snapshot<'tcx>,
|
||||
region_constraints_snapshot: RegionSnapshot,
|
||||
universe: ty::UniverseIndex,
|
||||
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.
|
||||
/// 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 }
|
||||
}
|
||||
|
||||
|
@ -746,7 +723,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
/// if this is not a type variable.
|
||||
///
|
||||
/// 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() {
|
||||
ty::Infer(ty::TyVar(vid)) => {
|
||||
Some(*self.inner.borrow_mut().type_variables().var_origin(vid))
|
||||
|
@ -787,7 +764,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
vars
|
||||
}
|
||||
|
||||
fn combine_fields(
|
||||
fn combine_fields<'a>(
|
||||
&'a self,
|
||||
trace: TypeTrace<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -829,7 +806,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
result
|
||||
}
|
||||
|
||||
fn start_snapshot(&self) -> CombinedSnapshot<'a, 'tcx> {
|
||||
fn start_snapshot(&self) -> CombinedSnapshot<'tcx> {
|
||||
debug!("start_snapshot()");
|
||||
|
||||
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(),
|
||||
universe: self.universe(),
|
||||
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")]
|
||||
fn rollback_to(&self, cause: &str, snapshot: CombinedSnapshot<'a, 'tcx>) {
|
||||
fn rollback_to(&self, cause: &str, snapshot: CombinedSnapshot<'tcx>) {
|
||||
let CombinedSnapshot {
|
||||
undo_snapshot,
|
||||
region_constraints_snapshot,
|
||||
universe,
|
||||
was_in_snapshot,
|
||||
_in_progress_typeck_results,
|
||||
} = snapshot;
|
||||
|
||||
self.in_snapshot.set(was_in_snapshot);
|
||||
|
@ -868,13 +839,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
#[instrument(skip(self, snapshot), level = "debug")]
|
||||
fn commit_from(&self, snapshot: CombinedSnapshot<'a, 'tcx>) {
|
||||
fn commit_from(&self, snapshot: CombinedSnapshot<'tcx>) {
|
||||
let CombinedSnapshot {
|
||||
undo_snapshot,
|
||||
region_constraints_snapshot: _,
|
||||
universe: _,
|
||||
was_in_snapshot,
|
||||
_in_progress_typeck_results,
|
||||
} = snapshot;
|
||||
|
||||
self.in_snapshot.set(was_in_snapshot);
|
||||
|
@ -886,7 +856,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
#[instrument(skip(self, f), level = "debug")]
|
||||
pub fn commit_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
|
||||
where
|
||||
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> Result<T, E>,
|
||||
F: FnOnce(&CombinedSnapshot<'tcx>) -> Result<T, E>,
|
||||
{
|
||||
let snapshot = self.start_snapshot();
|
||||
let r = f(&snapshot);
|
||||
|
@ -906,7 +876,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
#[instrument(skip(self, f), level = "debug")]
|
||||
pub fn probe<R, F>(&self, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> R,
|
||||
F: FnOnce(&CombinedSnapshot<'tcx>) -> R,
|
||||
{
|
||||
let snapshot = self.start_snapshot();
|
||||
let r = f(&snapshot);
|
||||
|
@ -918,7 +888,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
#[instrument(skip(self, f), level = "debug")]
|
||||
pub fn probe_maybe_skip_leak_check<R, F>(&self, should_skip: bool, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> R,
|
||||
F: FnOnce(&CombinedSnapshot<'tcx>) -> R,
|
||||
{
|
||||
let snapshot = self.start_snapshot();
|
||||
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
|
||||
pub fn region_constraints_added_in_snapshot(
|
||||
&self,
|
||||
snapshot: &CombinedSnapshot<'a, 'tcx>,
|
||||
snapshot: &CombinedSnapshot<'tcx>,
|
||||
) -> Option<bool> {
|
||||
self.inner
|
||||
.borrow_mut()
|
||||
|
@ -946,7 +916,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
.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)
|
||||
}
|
||||
|
||||
|
@ -1519,7 +1489,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
struct ToFreshVars<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
span: Span,
|
||||
lbrct: LateBoundRegionConversionTime,
|
||||
map: FxHashMap<ty::BoundVar, ty::GenericArg<'tcx>>,
|
||||
|
@ -1893,7 +1863,7 @@ impl<'tcx> TypeFolder<'tcx> for InferenceLiteralEraser<'tcx> {
|
|||
}
|
||||
|
||||
struct ShallowResolver<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeFolder<'tcx> for ShallowResolver<'a, 'tcx> {
|
||||
|
|
|
@ -44,7 +44,7 @@ pub struct TypeRelating<'me, 'tcx, D>
|
|||
where
|
||||
D: TypeRelatingDelegate<'tcx>,
|
||||
{
|
||||
infcx: &'me InferCtxt<'me, 'tcx>,
|
||||
infcx: &'me InferCtxt<'tcx>,
|
||||
|
||||
/// Callback to use when we deduce an outlives relationship.
|
||||
delegate: D,
|
||||
|
@ -149,11 +149,7 @@ impl<'me, 'tcx, D> TypeRelating<'me, 'tcx, D>
|
|||
where
|
||||
D: TypeRelatingDelegate<'tcx>,
|
||||
{
|
||||
pub fn new(
|
||||
infcx: &'me InferCtxt<'me, 'tcx>,
|
||||
delegate: D,
|
||||
ambient_variance: ty::Variance,
|
||||
) -> Self {
|
||||
pub fn new(infcx: &'me InferCtxt<'tcx>, delegate: D, ambient_variance: ty::Variance) -> Self {
|
||||
Self {
|
||||
infcx,
|
||||
delegate,
|
||||
|
@ -867,7 +863,7 @@ struct TypeGeneralizer<'me, 'tcx, D>
|
|||
where
|
||||
D: TypeRelatingDelegate<'tcx>,
|
||||
{
|
||||
infcx: &'me InferCtxt<'me, 'tcx>,
|
||||
infcx: &'me InferCtxt<'tcx>,
|
||||
|
||||
delegate: &'me mut D,
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ pub struct OpaqueTypeDecl<'tcx> {
|
|||
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
|
||||
/// lazy TAIT around RPIT handling.
|
||||
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")]
|
||||
pub fn register_hidden_type(
|
||||
&self,
|
||||
|
|
|
@ -87,9 +87,9 @@ impl<'tcx> OutlivesEnvironment<'tcx> {
|
|||
}
|
||||
|
||||
/// Create a new `OutlivesEnvironment` with extra outlives bounds.
|
||||
pub fn with_bounds<'a>(
|
||||
pub fn with_bounds(
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
infcx: Option<&InferCtxt<'a, 'tcx>>,
|
||||
infcx: Option<&InferCtxt<'tcx>>,
|
||||
extra_bounds: impl IntoIterator<Item = OutlivesBound<'tcx>>,
|
||||
) -> Self {
|
||||
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]
|
||||
#[instrument(level = "debug")]
|
||||
fn build(self) -> OutlivesEnvironment<'tcx> {
|
||||
|
@ -125,7 +125,7 @@ impl<'a, 'tcx> OutlivesEnvironmentBuilder<'tcx> {
|
|||
/// contain inference variables, it must be supplied, in which
|
||||
/// case we will register "givens" on the inference context. (See
|
||||
/// `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
|
||||
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 smallvec::smallvec;
|
||||
|
||||
impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
/// Registers that the given region obligation must be resolved
|
||||
/// from within the scope of `body_id`. These regions are enqueued
|
||||
/// 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(
|
||||
&mut self,
|
||||
origin: SubregionOrigin<'tcx>,
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::traits::{Obligation, PredicateObligation};
|
|||
use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use super::InferCtxt;
|
||||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
/// Instead of normalizing an associated type projection,
|
||||
/// this function generates an inference variable and registers
|
||||
/// an obligation that this inference variable must be the result
|
||||
|
|
|
@ -66,7 +66,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
|
|||
tcx: TyCtxt<'tcx>,
|
||||
overly_polymorphic: bool,
|
||||
max_universe: ty::UniverseIndex,
|
||||
snapshot: &CombinedSnapshot<'_, 'tcx>,
|
||||
snapshot: &CombinedSnapshot<'tcx>,
|
||||
) -> RelateResult<'tcx, ()> {
|
||||
debug!(
|
||||
"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
|
||||
/// points for correctness.
|
||||
pub struct OpportunisticVarResolver<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> {
|
||||
#[inline]
|
||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
|
||||
pub fn new(infcx: &'a InferCtxt<'tcx>) -> Self {
|
||||
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
|
||||
/// [InferCtxt::resolve_vars_if_possible] first.
|
||||
pub struct OpportunisticRegionResolver<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'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 }
|
||||
}
|
||||
}
|
||||
|
@ -116,11 +116,11 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticRegionResolver<'a, 'tcx> {
|
|||
/// It does not construct the fully resolved type (which might
|
||||
/// involve some hashing and so forth).
|
||||
pub struct UnresolvedTypeFinder<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'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 }
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
|
|||
/// Full type resolution replaces all type and region variables with
|
||||
/// their concrete results. If any variable cannot be replaced (never unified, etc)
|
||||
/// 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
|
||||
T: TypeFoldable<'tcx>,
|
||||
{
|
||||
|
@ -177,7 +177,7 @@ where
|
|||
// N.B. This type is not public because the protocol around checking the
|
||||
// `err` field is not enforceable otherwise.
|
||||
struct FullTypeResolver<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> FallibleTypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
|
||||
|
|
|
@ -10,7 +10,7 @@ use super::{ObligationCause, PredicateObligation};
|
|||
pub trait TraitEngine<'tcx>: 'tcx {
|
||||
fn normalize_projection_type(
|
||||
&mut self,
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
infcx: &InferCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
projection_ty: ty::ProjectionTy<'tcx>,
|
||||
cause: ObligationCause<'tcx>,
|
||||
|
@ -21,7 +21,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
|
|||
/// parameters (except for `Self`).
|
||||
fn register_bound(
|
||||
&mut self,
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
infcx: &InferCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
def_id: DefId,
|
||||
|
@ -41,14 +41,13 @@ pub trait TraitEngine<'tcx>: 'tcx {
|
|||
|
||||
fn register_predicate_obligation(
|
||||
&mut self,
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
infcx: &InferCtxt<'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>)
|
||||
-> Vec<FulfillmentError<'tcx>>;
|
||||
fn select_where_possible(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<FulfillmentError<'tcx>>;
|
||||
|
||||
fn pending_obligations(&self) -> Vec<PredicateObligation<'tcx>>;
|
||||
|
||||
|
@ -58,7 +57,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
|
|||
pub trait TraitEngineExt<'tcx> {
|
||||
fn register_predicate_obligations(
|
||||
&mut self,
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
infcx: &InferCtxt<'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 {
|
||||
fn register_predicate_obligations(
|
||||
&mut self,
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
infcx: &InferCtxt<'tcx>,
|
||||
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>,
|
||||
) {
|
||||
for obligation in obligations {
|
||||
|
|
|
@ -10,7 +10,7 @@ use rustc_span::Span;
|
|||
use std::fmt;
|
||||
use std::iter;
|
||||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
pub fn report_extra_impl_obligation(
|
||||
&self,
|
||||
error_span: Span,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue