pub use self::RegionVariableOrigin::*;
pub use self::SubregionOrigin::*;
pub use self::ValuePairs::*;
-pub use ty::IntVarValue;
+pub use crate::ty::IntVarValue;
+
+use crate::hir::def_id::DefId;
+use crate::infer::canonical::{Canonical, CanonicalVarValues};
+use crate::middle::free_region::RegionRelations;
+use crate::middle::lang_items;
+use crate::middle::region;
+use crate::session::config::BorrowckMode;
+use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine};
+use crate::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
+use crate::ty::fold::TypeFoldable;
+use crate::ty::relate::RelateResult;
+use crate::ty::subst::{Kind, Substs};
+use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners};
+use crate::ty::{FloatVid, IntVid, TyVid};
+use crate::util::nodemap::FxHashMap;
use arena::SyncDroplessArena;
use errors::DiagnosticBuilder;
-use hir::def_id::DefId;
-use infer::canonical::{Canonical, CanonicalVarValues};
-use middle::free_region::RegionRelations;
-use middle::lang_items;
-use middle::region;
use rustc_data_structures::unify as ut;
-use session::config::BorrowckMode;
use std::cell::{Cell, Ref, RefCell, RefMut};
use std::collections::BTreeMap;
use std::fmt;
use syntax::ast;
use syntax_pos::symbol::InternedString;
-use syntax_pos::{self, Span};
-use traits::{self, ObligationCause, PredicateObligations, TraitEngine};
-use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
-use ty::fold::TypeFoldable;
-use ty::relate::RelateResult;
-use ty::subst::{Kind, Substs};
-use ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners};
-use ty::{FloatVid, IntVid, TyVid};
-use util::nodemap::FxHashMap;
+use syntax_pos::Span;
use self::combine::CombineFields;
use self::lexical_region_resolve::LexicalRegionResolutions;
/// replaced with.
pub type PlaceholderMap<'tcx> = BTreeMap<ty::BoundRegion, ty::Region<'tcx>>;
-/// See `error_reporting` module for more details
+/// See the `error_reporting` module for more details.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ValuePairs<'tcx> {
Types(ExpectedFound<Ty<'tcx>>),
/// The trace designates the path through inference that we took to
/// encounter an error or subtyping constraint.
///
-/// See `error_reporting` module for more details.
+/// See the `error_reporting` module for more details.
#[derive(Clone)]
pub struct TypeTrace<'tcx> {
cause: ObligationCause<'tcx>,
}
}
-/// Helper type of a temporary returned by tcx.infer_ctxt().
+/// Helper type of a temporary returned by `tcx.infer_ctxt()`.
/// Necessary because we can't write the following bound:
-/// F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(InferCtxt<'b, 'gcx, 'tcx>).
+/// `F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(InferCtxt<'b, 'gcx, 'tcx>)`.
pub struct InferCtxtBuilder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
global_tcx: TyCtxt<'a, 'gcx, 'gcx>,
arena: SyncDroplessArena,
/// inference context that contains each of the bound values
/// within instantiated as a fresh variable. The `f` closure is
/// invoked with the new infcx, along with the instantiated value
- /// `V` and a substitution `S`. This substitution `S` maps from
+ /// `V` and a substitution `S`. This substitution `S` maps from
/// the bound values in `C` to their instantiated values in `V`
/// (in other words, `S(C) = V`).
pub fn enter_with_canonical<T, R>(
}
}
- /// Extract `value`, registering any obligations into `fulfill_cx`
+ /// Extracts `value`, registering any obligations into `fulfill_cx`.
pub fn into_value_registering_obligations(
self,
infcx: &InferCtxt<'_, '_, 'tcx>,
}
pub fn type_is_unconstrained_numeric(&'a self, ty: Ty<'_>) -> UnconstrainedNumeric {
- use ty::error::UnconstrainedNumeric::Neither;
- use ty::error::UnconstrainedNumeric::{UnconstrainedFloat, UnconstrainedInt};
+ use crate::ty::error::UnconstrainedNumeric::Neither;
+ use crate::ty::error::UnconstrainedNumeric::{UnconstrainedFloat, UnconstrainedInt};
match ty.sty {
ty::Infer(ty::IntVar(vid)) => {
if self.int_unification_table
.commit(region_constraints_snapshot);
}
- /// Execute `f` and commit the bindings
+ /// Executes `f` and commit the bindings.
pub fn commit_unconditionally<R, F>(&self, f: F) -> R
where
F: FnOnce() -> R,
r
}
- /// Execute `f` and commit the bindings if closure `f` returns `Ok(_)`
+ /// Executes `f` and commit the bindings if closure `f` returns `Ok(_)`.
pub fn commit_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
where
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> Result<T, E>,
r
}
- /// Execute `f` then unroll any bindings it creates
+ /// Executes `f` then unroll any bindings it creates.
pub fn probe<R, F>(&self, f: F) -> R
where
F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> R,
self.float_unification_table.borrow_mut().new_key(None)
}
- /// Create a fresh region variable with the next available index.
+ /// Creates a fresh region variable with the next available index.
/// The variable will be created in the maximum universe created
/// thus far, allowing it to name any region created thus far.
pub fn next_region_var(&self, origin: RegionVariableOrigin) -> ty::Region<'tcx> {
self.next_region_var_in_universe(origin, self.universe())
}
- /// Create a fresh region variable with the next available index
+ /// Creates a fresh region variable with the next available index
/// in the given universe; typically, you can use
/// `next_region_var` and just use the maximal universe.
pub fn next_region_var_in_universe(
Substs::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param))
}
- /// True if errors have been reported since this infcx was
- /// created. This is sometimes used as a heuristic to skip
+ /// Returns `true` if errors have been reported since this infcx was
+ /// created. This is sometimes used as a heuristic to skip
/// reporting errors that often occur as a result of earlier
/// errors, but where it's hard to be 100% sure (e.g., unresolved
/// inference variables, regionck errors).
value.fold_with(&mut r)
}
- /// Returns true if `T` contains unresolved type variables. In the
+ /// Returns `true` if `T` contains unresolved type variables. In the
/// process of visiting `T`, this will resolve (where possible)
/// type variables in `T`, but it never constructs the final,
/// resolved type, so it's more efficient than
value.visit_with(&mut r)
}
- pub fn resolve_type_and_region_vars_if_possible<T>(&self, value: &T) -> T
- where
- T: TypeFoldable<'tcx>,
- {
- let mut r = resolve::OpportunisticTypeAndRegionResolver::new(self);
- value.fold_with(&mut r)
- }
-
pub fn fully_resolve<T: TypeFoldable<'tcx>>(&self, value: &T) -> FixupResult<T> {
/*!
* Attempts to resolve all type/region variables in
self.tcx.replace_bound_vars(value, fld_r, fld_t)
}
- /// See `verify_generic_bound` method in `region_constraints`
+ /// See the [`region_constraints::verify_generic_bound`] method.
pub fn verify_generic_bound(
&self,
origin: SubregionOrigin<'tcx>,
closure_kind_ty.to_opt_closure_kind()
}
- /// Obtain the signature of a closure. For closures, unlike
+ /// Obtain the signature of a closure. For closures, unlike
/// `tcx.fn_sig(def_id)`, this method will work during the
/// type-checking of the enclosing function and return the closure
/// signature in its partially inferred state.
}
/// Clears the selection, evaluation, and projection caches. This is useful when
- /// repeatedly attempting to select an Obligation while changing only
- /// its ParamEnv, since FulfillmentContext doesn't use 'probe'
+ /// repeatedly attempting to select an `Obligation` while changing only
+ /// its `ParamEnv`, since `FulfillmentContext` doesn't use probing.
pub fn clear_caches(&self) {
self.selection_cache.clear();
self.evaluation_cache.clear();
self.universe.get()
}
- /// Create and return a fresh universe that extends all previous
+ /// Creates and return a fresh universe that extends all previous
/// universes. Updates `self.universe` to that new universe.
pub fn create_next_universe(&self) -> ty::UniverseIndex {
let u = self.universe.get().next_universe();