Run rustfmt --file-lines ... for changes from previous commits.

This commit is contained in:
Eduard-Mihai Burtescu 2019-06-14 01:32:15 +03:00
parent f3f9d6dfd9
commit afc39bbf24
107 changed files with 813 additions and 1159 deletions

View File

@ -506,12 +506,12 @@ fn stable_non_narrow_char(swc: ::syntax_pos::NonNarrowChar,
(pos.0 - source_file_start.0, width as u32)
}
impl<'tcx> HashStable<StableHashingContext<'tcx>> for feature_gate::Features {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'tcx>,
hasher: &mut StableHasher<W>) {
fn hash_stable<W: StableHasherResult>(
&self,
hcx: &mut StableHashingContext<'tcx>,
hasher: &mut StableHasher<W>,
) {
// Unfortunately we cannot exhaustively list fields here, since the
// struct is macro generated.
self.declared_lang_features.hash_stable(hcx, hasher);

View File

@ -11,9 +11,10 @@
use crate::ty;
use crate::mir;
impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>>
for &'tcx ty::List<T>
where T: HashStable<StableHashingContext<'a>> {
impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for &'tcx ty::List<T>
where
T: HashStable<StableHashingContext<'a>>,
{
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
@ -41,7 +42,8 @@ fn hash_stable<W: StableHasherResult>(&self,
}
impl<'a, 'tcx, T> ToStableHashKey<StableHashingContext<'a>> for &'tcx ty::List<T>
where T: HashStable<StableHashingContext<'a>>
where
T: HashStable<StableHashingContext<'a>>,
{
type KeyType = Fingerprint;
@ -119,18 +121,22 @@ fn hash_stable<W: StableHasherResult>(&self,
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::ConstVid<'tcx> {
#[inline]
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
fn hash_stable<W: StableHasherResult>(
&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>,
) {
self.index.hash_stable(hcx, hasher);
}
}
impl<'tcx> HashStable<StableHashingContext<'tcx>> for ty::BoundVar {
#[inline]
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'tcx>,
hasher: &mut StableHasher<W>) {
fn hash_stable<W: StableHasherResult>(
&self,
hcx: &mut StableHashingContext<'tcx>,
hasher: &mut StableHasher<W>,
) {
self.index().hash_stable(hcx, hasher);
}
}

View File

@ -44,11 +44,11 @@ pub struct Trace<'a, 'tcx: 'a> {
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
#[inline]
pub fn at(&'a self,
cause: &'a ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>)
-> At<'a, 'tcx>
{
pub fn at(
&'a self,
cause: &'a ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>,
) -> At<'a, 'tcx> {
At { infcx: self, cause, param_env }
}
}
@ -186,11 +186,9 @@ pub fn glb<T>(self,
/// error-reporting, but doesn't actually perform any operation
/// yet (this is useful when you want to set the trace using
/// distinct values from those you wish to operate upon).
pub fn trace<T>(self,
expected: T,
actual: T)
-> Trace<'a, 'tcx>
where T: ToTrace<'tcx>
pub fn trace<T>(self, expected: T, actual: T) -> Trace<'a, 'tcx>
where
T: ToTrace<'tcx>,
{
self.trace_exp(true, expected, actual)
}
@ -198,12 +196,9 @@ pub fn trace<T>(self,
/// Like `trace`, but the expected value is determined by the
/// boolean argument (if true, then the first argument `a` is the
/// "expected" value).
pub fn trace_exp<T>(self,
a_is_expected: bool,
a: T,
b: T)
-> Trace<'a, 'tcx>
where T: ToTrace<'tcx>
pub fn trace_exp<T>(self, a_is_expected: bool, a: T, b: T) -> Trace<'a, 'tcx>
where
T: ToTrace<'tcx>,
{
let trace = ToTrace::to_trace(self.cause, a_is_expected, a, b);
Trace { at: self, trace: trace, a_is_expected }

View File

@ -49,8 +49,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
pub fn enter_canonical_trait_query<K, R>(
&mut self,
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>>
where
K: TypeFoldable<'tcx>,
@ -126,7 +125,7 @@ pub fn make_canonicalized_query_response<T>(
pub fn make_query_response_ignoring_pending_obligations<T>(
&self,
inference_vars: CanonicalVarValues<'tcx>,
answer: T
answer: T,
) -> Canonical<'tcx, QueryResponse<'tcx, <T as Lift<'tcx>>::Lifted>>
where
T: Debug + Lift<'tcx> + TypeFoldable<'tcx>,

View File

@ -17,9 +17,10 @@ pub struct Equate<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
}
impl<'combine, 'infcx, 'tcx> Equate<'combine, 'infcx, 'tcx> {
pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool)
-> Equate<'combine, 'infcx, 'tcx>
{
pub fn new(
fields: &'combine mut CombineFields<'infcx, 'tcx>,
a_is_expected: bool,
) -> Equate<'combine, 'infcx, 'tcx> {
Equate { fields: fields, a_is_expected: a_is_expected }
}
}

View File

@ -74,7 +74,6 @@ fn visit_body(&mut self, body: &'tcx Body) {
}
}
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn extract_type_name(
&self,
@ -102,7 +101,7 @@ pub fn need_type_info_err(
&self,
body_id: Option<hir::BodyId>,
span: Span,
ty: Ty<'tcx>
ty: Ty<'tcx>,
) -> DiagnosticBuilder<'tcx> {
let ty = self.resolve_vars_if_possible(&ty);
let name = self.extract_type_name(&ty, None);
@ -229,7 +228,7 @@ pub fn need_type_info_err(
pub fn need_type_info_err_in_generator(
&self,
span: Span,
ty: Ty<'tcx>
ty: Ty<'tcx>,
) -> DiagnosticBuilder<'tcx> {
let ty = self.resolve_vars_if_possible(&ty);
let name = self.extract_type_name(&ty, None);

View File

@ -50,8 +50,7 @@ pub struct TypeFreshener<'a, 'tcx: 'a> {
}
impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>)
-> TypeFreshener<'a, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> TypeFreshener<'a, 'tcx> {
TypeFreshener {
infcx,
ty_freshen_count: 0,

View File

@ -14,9 +14,10 @@ pub struct Glb<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
}
impl<'combine, 'infcx, 'tcx> Glb<'combine, 'infcx, 'tcx> {
pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool)
-> Glb<'combine, 'infcx, 'tcx>
{
pub fn new(
fields: &'combine mut CombineFields<'infcx, 'tcx>,
a_is_expected: bool,
) -> Glb<'combine, 'infcx, 'tcx> {
Glb { fields: fields, a_is_expected: a_is_expected }
}
}
@ -85,9 +86,7 @@ fn binders<T>(&mut self, a: &ty::Binder<T>, b: &ty::Binder<T>)
}
}
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> {
self.fields.infcx
}

View File

@ -41,11 +41,14 @@ pub trait LatticeDir<'f, 'tcx: 'f>: TypeRelation<'tcx> {
fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>;
}
pub fn super_lattice_tys<'a, 'tcx, L>(this: &mut L,
a: Ty<'tcx>,
b: Ty<'tcx>)
-> RelateResult<'tcx, Ty<'tcx>>
where L: LatticeDir<'a, 'tcx>, 'tcx: 'a
pub fn super_lattice_tys<'a, 'tcx, L>(
this: &mut L,
a: Ty<'tcx>,
b: Ty<'tcx>,
) -> RelateResult<'tcx, Ty<'tcx>>
where
L: LatticeDir<'a, 'tcx>,
'tcx: 'a,
{
debug!("{}.lattice_tys({:?}, {:?})",
this.tag(),

View File

@ -46,8 +46,8 @@ fn print_help_message() {
pub fn maybe_print_constraints_for<'a, 'tcx>(
region_data: &RegionConstraintData<'tcx>,
region_rels: &RegionRelations<'a, 'tcx>)
{
region_rels: &RegionRelations<'a, 'tcx>,
) {
let tcx = region_rels.tcx;
let context = region_rels.context;
@ -127,10 +127,11 @@ enum Edge<'tcx> {
}
impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> {
fn new(name: String,
region_rels: &'a RegionRelations<'a, 'tcx>,
map: &'a ConstraintMap<'tcx>)
-> ConstraintGraph<'a, 'tcx> {
fn new(
name: String,
region_rels: &'a RegionRelations<'a, 'tcx>,
map: &'a ConstraintMap<'tcx>,
) -> ConstraintGraph<'a, 'tcx> {
let mut i = 0;
let mut node_ids = FxHashMap::default();
{
@ -246,10 +247,11 @@ fn target(&self, edge: &Edge<'tcx>) -> Node {
pub type ConstraintMap<'tcx> = BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>;
fn dump_region_data_to<'a, 'tcx>(region_rels: &RegionRelations<'a, 'tcx>,
map: &ConstraintMap<'tcx>,
path: &str)
-> io::Result<()> {
fn dump_region_data_to<'a, 'tcx>(
region_rels: &RegionRelations<'a, 'tcx>,
map: &ConstraintMap<'tcx>,
path: &str,
) -> io::Result<()> {
debug!("dump_region_data map (len: {}) path: {}",
map.len(),
path);

View File

@ -33,10 +33,7 @@ pub fn resolve<'tcx>(
region_rels: &RegionRelations<'_, 'tcx>,
var_infos: VarInfos,
data: RegionConstraintData<'tcx>,
) -> (
LexicalRegionResolutions<'tcx>,
Vec<RegionResolutionError<'tcx>>,
) {
) -> (LexicalRegionResolutions<'tcx>, Vec<RegionResolutionError<'tcx>>) {
debug!("RegionConstraintData: resolve_regions()");
let mut errors = vec![];
let mut resolver = LexicalResolver {

View File

@ -14,9 +14,10 @@ pub struct Lub<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
}
impl<'combine, 'infcx, 'tcx> Lub<'combine, 'infcx, 'tcx> {
pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool)
-> Lub<'combine, 'infcx, 'tcx>
{
pub fn new(
fields: &'combine mut CombineFields<'infcx, 'tcx>,
a_is_expected: bool,
) -> Lub<'combine, 'infcx, 'tcx> {
Lub { fields: fields, a_is_expected: a_is_expected }
}
}
@ -85,9 +86,7 @@ fn binders<T>(&mut self, a: &ty::Binder<T>, b: &ty::Binder<T>)
}
}
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> {
self.fields.infcx
}

View File

@ -190,11 +190,8 @@ pub fn save_implied_bounds(&mut self, body_id: hir::HirId) {
/// 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,
) where
fn add_outlives_bounds<I>(&mut self, infcx: Option<&InferCtxt<'a, 'tcx>>, outlives_bounds: I)
where
I: IntoIterator<Item = OutlivesBound<'tcx>>,
{
// Record relationships such as `T:'x` that don't go into the

View File

@ -105,7 +105,7 @@ pub struct UnresolvedTypeFinder<'a, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'tcx>,
/// Used to find the type parameter name and location for error reporting.
pub first_unresolved: Option<(Ty<'tcx>,Option<Span>)>,
pub first_unresolved: Option<(Ty<'tcx>, Option<Span>)>,
}
impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> {
@ -157,9 +157,9 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
/// 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>
where T : TypeFoldable<'tcx>
pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, value: &T) -> FixupResult<'tcx, T>
where
T: TypeFoldable<'tcx>,
{
let mut full_resolver = FullTypeResolver { infcx: infcx, err: None };
let result = value.fold_with(&mut full_resolver);

View File

@ -17,9 +17,10 @@ pub struct Sub<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
}
impl<'combine, 'infcx, 'tcx> Sub<'combine, 'infcx, 'tcx> {
pub fn new(f: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool)
-> Sub<'combine, 'infcx, 'tcx>
{
pub fn new(
f: &'combine mut CombineFields<'infcx, 'tcx>,
a_is_expected: bool,
) -> Sub<'combine, 'infcx, 'tcx> {
Sub { fields: f, a_is_expected: a_is_expected }
}

View File

@ -1456,10 +1456,7 @@ fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tc
})
}
fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
tcx: TyCtxt<'tcx>,
builtin_lints: T,
) {
fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tcx>, builtin_lints: T) {
let mut passes = tcx.sess.lint_store.borrow().late_passes.lock().take().unwrap();
if !tcx.sess.opts.debugging_opts.no_interleave_lints {

View File

@ -140,10 +140,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
}
}
fn configure_main(
tcx: TyCtxt<'_>,
visitor: &EntryContext<'_, '_>,
) -> Option<(DefId, EntryFnType)> {
fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) -> Option<(DefId, EntryFnType)> {
if let Some((hir_id, _)) = visitor.start_fn {
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Start))
} else if let Some((hir_id, _)) = visitor.attr_main_fn {

View File

@ -52,11 +52,7 @@ pub fn symbol_name(&self, tcx: TyCtxt<'tcx>) -> ty::SymbolName {
}
}
pub fn compare_stable(
&self,
tcx: TyCtxt<'tcx>,
other: &ExportedSymbol<'tcx>,
) -> cmp::Ordering {
pub fn compare_stable(&self, tcx: TyCtxt<'tcx>, other: &ExportedSymbol<'tcx>) -> cmp::Ordering {
match *self {
ExportedSymbol::NonGeneric(self_def_id) => match *other {
ExportedSymbol::NonGeneric(other_def_id) => {

View File

@ -288,14 +288,14 @@ pub fn new(
}
impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
pub fn with_infer(delegate: &'a mut (dyn Delegate<'tcx>+'a),
infcx: &'a InferCtxt<'a, 'tcx>,
body_owner: DefId,
param_env: ty::ParamEnv<'tcx>,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>)
-> Self
{
pub fn with_infer(
delegate: &'a mut (dyn Delegate<'tcx> + 'a),
infcx: &'a InferCtxt<'a, 'tcx>,
body_owner: DefId,
param_env: ty::ParamEnv<'tcx>,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>,
) -> Self {
ExprUseVisitor {
mc: mc::MemCategorizationContext::with_infer(
infcx,
@ -974,12 +974,12 @@ fn cat_captured_var(&mut self,
}
}
fn copy_or_move<'a, 'tcx>(mc: &mc::MemCategorizationContext<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
cmt: &mc::cmt_<'tcx>,
move_reason: MoveReason)
-> ConsumeMode
{
fn copy_or_move<'a, 'tcx>(
mc: &mc::MemCategorizationContext<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
cmt: &mc::cmt_<'tcx>,
move_reason: MoveReason,
) -> ConsumeMode {
if !mc.type_is_copy_modulo_regions(param_env, cmt.ty, cmt.span) {
Move(move_reason)
} else {

View File

@ -432,11 +432,12 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
/// temporaries may be overly conservative;
/// - similarly, as the results of upvar analysis are not yet
/// known, the results around upvar accesses may be incorrect.
pub fn with_infer(infcx: &'a InferCtxt<'a, 'tcx>,
body_owner: DefId,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>)
-> MemCategorizationContext<'a, 'tcx> {
pub fn with_infer(
infcx: &'a InferCtxt<'a, 'tcx>,
body_owner: DefId,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>,
) -> MemCategorizationContext<'a, 'tcx> {
let tcx = infcx.tcx;
// Subtle: we can't do rvalue promotion analysis until the
@ -586,10 +587,11 @@ fn pat_ty_unadjusted(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
pub fn cat_expr(&self, expr: &hir::Expr) -> McResult<cmt_<'tcx>> {
// This recursion helper avoids going through *too many*
// adjustments, since *only* non-overloaded deref recurses.
fn helper<'a, 'tcx>(mc: &MemCategorizationContext<'a, 'tcx>,
expr: &hir::Expr,
adjustments: &[adjustment::Adjustment<'tcx>])
-> McResult<cmt_<'tcx>> {
fn helper<'a, 'tcx>(
mc: &MemCategorizationContext<'a, 'tcx>,
expr: &hir::Expr,
adjustments: &[adjustment::Adjustment<'tcx>],
) -> McResult<cmt_<'tcx>> {
match adjustments.split_last() {
None => mc.cat_expr_unadjusted(expr),
Some((adjustment, previous)) => {

View File

@ -646,11 +646,7 @@ pub fn nearest_common_ancestor(&self, scope_a: Scope, scope_b: Scope) -> Scope {
/// Assuming that the provided region was defined within this `ScopeTree`,
/// returns the outermost `Scope` that the region outlives.
pub fn early_free_scope(
&self,
tcx: TyCtxt<'tcx>,
br: &ty::EarlyBoundRegion,
) -> Scope {
pub fn early_free_scope(&self, tcx: TyCtxt<'tcx>, br: &ty::EarlyBoundRegion) -> Scope {
let param_owner = tcx.parent(br.def_id).unwrap();
let param_owner_id = tcx.hir().as_local_hir_id(param_owner).unwrap();

View File

@ -1125,12 +1125,7 @@ fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_>, params: &P<[hir::Gener
}
}
fn signal_shadowing_problem(
tcx: TyCtxt<'_>,
name: ast::Name,
orig: Original,
shadower: Shadower,
) {
fn signal_shadowing_problem(tcx: TyCtxt<'_>, name: ast::Name, orig: Original, shadower: Shadower) {
let mut err = if let (ShadowKind::Lifetime, ShadowKind::Lifetime) = (orig.kind, shadower.kind) {
// lifetime/lifetime shadowing is an error
struct_span_err!(

View File

@ -234,12 +234,7 @@ pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
}
impl<'tcx> BinOp {
pub fn ty(
&self,
tcx: TyCtxt<'tcx>,
lhs_ty: Ty<'tcx>,
rhs_ty: Ty<'tcx>,
) -> Ty<'tcx> {
pub fn ty(&self, tcx: TyCtxt<'tcx>, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>) -> Ty<'tcx> {
// FIXME: handle SIMD correctly
match self {
&BinOp::Add | &BinOp::Sub | &BinOp::Mul | &BinOp::Div | &BinOp::Rem |

View File

@ -30,7 +30,7 @@ impl FulfillmentContext<'tcx> {
fn in_environment(
infcx: &InferCtxt<'_, 'tcx>,
obligation: PredicateObligation<'tcx>
obligation: PredicateObligation<'tcx>,
) -> InEnvironment<'tcx, PredicateObligation<'tcx>> {
assert!(!infcx.is_in_snapshot());
let obligation = infcx.resolve_vars_if_possible(&obligation);

View File

@ -116,7 +116,7 @@ fn to_dep_kind() -> DepKind {
// # Global Cache
pub struct ProjectionCache<'tcx> {
data: PhantomData<&'tcx ()>
data: PhantomData<&'tcx ()>,
}
impl<'tcx> DepTrackingMapConfig for ProjectionCache<'tcx> {
@ -137,11 +137,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
/// type inference variables that appear in `result` to be
/// unified, and hence we need to process those obligations to get
/// the complete picture of the type.
fn drain_fulfillment_cx_or_panic<T>(&self,
fulfill_cx: &mut FulfillmentContext<'tcx>,
result: &T)
-> T::Lifted
where T: TypeFoldable<'tcx> + ty::Lift<'tcx>
fn drain_fulfillment_cx_or_panic<T>(
&self,
fulfill_cx: &mut FulfillmentContext<'tcx>,
result: &T,
) -> T::Lifted
where
T: TypeFoldable<'tcx> + ty::Lift<'tcx>,
{
debug!("drain_fulfillment_cx_or_panic()");

View File

@ -87,11 +87,11 @@ pub fn overlapping_impls<'tcx, F1, F2, R>(
})
}
fn with_fresh_ty_vars<'cx, 'tcx>(selcx: &mut SelectionContext<'cx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
impl_def_id: DefId)
-> ty::ImplHeader<'tcx>
{
fn with_fresh_ty_vars<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
impl_def_id: DefId,
) -> ty::ImplHeader<'tcx> {
let tcx = selcx.tcx();
let impl_substs = selcx.infcx().fresh_substs_for_item(DUMMY_SP, impl_def_id);

View File

@ -1249,10 +1249,7 @@ fn report_closure_arg_mismatch(
expected_ref: ty::PolyTraitRef<'tcx>,
found: ty::PolyTraitRef<'tcx>,
) -> DiagnosticBuilder<'tcx> {
fn build_fn_sig_string<'tcx>(
tcx: TyCtxt<'tcx>,
trait_ref: &ty::TraitRef<'tcx>,
) -> String {
fn build_fn_sig_string<'tcx>(tcx: TyCtxt<'tcx>, trait_ref: &ty::TraitRef<'tcx>) -> String {
let inputs = trait_ref.substs.type_at(1);
let sig = if let ty::Tuple(inputs) = inputs.sty {
tcx.mk_fn_sig(
@ -1456,7 +1453,7 @@ fn predicate_can_apply(
) -> bool {
struct ParamToVarFolder<'a, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'tcx>,
var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>
var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>,
}
impl<'a, 'tcx> TypeFolder<'tcx> for ParamToVarFolder<'a, 'tcx> {

View File

@ -95,8 +95,10 @@ pub fn new_ignoring_regions() -> FulfillmentContext<'tcx> {
}
/// Attempts to select obligations using `selcx`.
fn select(&mut self, selcx: &mut SelectionContext<'a, 'tcx>)
-> Result<(), Vec<FulfillmentError<'tcx>>> {
fn select(
&mut self,
selcx: &mut SelectionContext<'a, 'tcx>,
) -> Result<(), Vec<FulfillmentError<'tcx>>> {
debug!("select(obligation-forest-size={})", self.predicates.len());
let mut errors = Vec::new();
@ -143,13 +145,13 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
/// `SomeTrait` or a where-clause that lets us unify `$0` with
/// something concrete. If this fails, we'll unify `$0` with
/// `projection_ty` again.
fn normalize_projection_type(&mut self,
infcx: &InferCtxt<'_, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>)
-> Ty<'tcx>
{
fn normalize_projection_type(
&mut self,
infcx: &InferCtxt<'_, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>,
) -> Ty<'tcx> {
debug!("normalize_projection_type(projection_ty={:?})",
projection_ty);
@ -172,10 +174,11 @@ fn normalize_projection_type(&mut self,
normalized_ty
}
fn register_predicate_obligation(&mut self,
infcx: &InferCtxt<'_, 'tcx>,
obligation: PredicateObligation<'tcx>)
{
fn register_predicate_obligation(
&mut self,
infcx: &InferCtxt<'_, 'tcx>,
obligation: PredicateObligation<'tcx>,
) {
// this helps to reduce duplicate errors, as well as making
// debug output much nicer to read and so on.
let obligation = infcx.resolve_vars_if_possible(&obligation);
@ -192,9 +195,8 @@ fn register_predicate_obligation(&mut self,
fn select_all_or_error(
&mut self,
infcx: &InferCtxt<'_, 'tcx>
) -> Result<(),Vec<FulfillmentError<'tcx>>>
{
infcx: &InferCtxt<'_, 'tcx>,
) -> Result<(), Vec<FulfillmentError<'tcx>>> {
self.select_where_possible(infcx)?;
let errors: Vec<_> =
@ -209,10 +211,10 @@ fn select_all_or_error(
}
}
fn select_where_possible(&mut self,
infcx: &InferCtxt<'_, 'tcx>)
-> Result<(),Vec<FulfillmentError<'tcx>>>
{
fn select_where_possible(
&mut self,
infcx: &InferCtxt<'_, 'tcx>,
) -> Result<(), Vec<FulfillmentError<'tcx>>> {
let mut selcx = SelectionContext::new(infcx);
self.select(&mut selcx)
}
@ -224,7 +226,7 @@ fn pending_obligations(&self) -> Vec<PredicateObligation<'tcx>> {
struct FulfillProcessor<'a, 'b: 'a, 'tcx: 'b> {
selcx: &'a mut SelectionContext<'b, 'tcx>,
register_region_obligations: bool
register_region_obligations: bool,
}
fn mk_pending(os: Vec<PredicateObligation<'tcx>>) -> Vec<PendingPredicateObligation<'tcx>> {
@ -514,9 +516,10 @@ fn process_backedge<'c, I>(&mut self, cycle: I,
}
/// Returns the set of type variables contained in a trait ref
fn trait_ref_type_vars<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx>,
t: ty::PolyTraitRef<'tcx>) -> Vec<Ty<'tcx>>
{
fn trait_ref_type_vars<'a, 'tcx>(
selcx: &mut SelectionContext<'a, 'tcx>,
t: ty::PolyTraitRef<'tcx>,
) -> Vec<Ty<'tcx>> {
t.skip_binder() // ok b/c this check doesn't care about regions
.input_types()
.map(|t| selcx.infcx().resolve_vars_if_possible(&t))

View File

@ -909,9 +909,10 @@ pub fn fully_normalize<'a, 'tcx, T>(
mut fulfill_cx: FulfillmentContext<'tcx>,
cause: ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>,
value: &T)
-> Result<T, Vec<FulfillmentError<'tcx>>>
where T : TypeFoldable<'tcx>
value: &T,
) -> Result<T, Vec<FulfillmentError<'tcx>>>
where
T: TypeFoldable<'tcx>,
{
debug!("fully_normalize_with_fulfillcx(value={:?})", value);
let selcx = &mut SelectionContext::new(infcx);

View File

@ -185,10 +185,8 @@ fn push_candidate(&mut self, candidate: ProjectionTyCandidate<'tcx>) -> bool {
/// the projection cache key used to track these additional obligations.
pub fn poly_project_and_unify_type<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &PolyProjectionObligation<'tcx>)
-> Result<Option<Vec<PredicateObligation<'tcx>>>,
MismatchedProjectionTypes<'tcx>>
{
obligation: &PolyProjectionObligation<'tcx>,
) -> Result<Option<Vec<PredicateObligation<'tcx>>>, MismatchedProjectionTypes<'tcx>> {
debug!("poly_project_and_unify_type(obligation={:?})",
obligation);
@ -212,10 +210,8 @@ pub fn poly_project_and_unify_type<'cx, 'tcx>(
/// If successful, this may result in additional obligations.
fn project_and_unify_type<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionObligation<'tcx>)
-> Result<Option<Vec<PredicateObligation<'tcx>>>,
MismatchedProjectionTypes<'tcx>>
{
obligation: &ProjectionObligation<'tcx>,
) -> Result<Option<Vec<PredicateObligation<'tcx>>>, MismatchedProjectionTypes<'tcx>> {
debug!("project_and_unify_type(obligation={:?})",
obligation);
@ -253,12 +249,14 @@ fn project_and_unify_type<'cx, 'tcx>(
/// them with a fully resolved type where possible. The return value
/// combines the normalized result and any additional obligations that
/// were incurred as result.
pub fn normalize<'a, 'b, 'tcx, T>(selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
value: &T)
-> Normalized<'tcx, T>
where T : TypeFoldable<'tcx>
pub fn normalize<'a, 'b, 'tcx, T>(
selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
value: &T,
) -> Normalized<'tcx, T>
where
T: TypeFoldable<'tcx>,
{
normalize_with_depth(selcx, param_env, cause, 0, value)
}
@ -269,10 +267,10 @@ pub fn normalize_with_depth<'a, 'b, 'tcx, T>(
param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
depth: usize,
value: &T)
-> Normalized<'tcx, T>
where T : TypeFoldable<'tcx>
value: &T,
) -> Normalized<'tcx, T>
where
T: TypeFoldable<'tcx>,
{
debug!("normalize_with_depth(depth={}, value={:?})", depth, value);
let mut normalizer = AssocTypeNormalizer::new(selcx, param_env, cause, depth);
@ -296,12 +294,12 @@ struct AssocTypeNormalizer<'a, 'b: 'a, 'tcx: 'b> {
}
impl<'a, 'b, 'tcx> AssocTypeNormalizer<'a, 'b, 'tcx> {
fn new(selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
depth: usize)
-> AssocTypeNormalizer<'a, 'b, 'tcx>
{
fn new(
selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
depth: usize,
) -> AssocTypeNormalizer<'a, 'b, 'tcx> {
AssocTypeNormalizer {
selcx,
param_env,
@ -462,9 +460,8 @@ pub fn normalize_projection_type<'a, 'b, 'tcx>(
projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>,
depth: usize,
obligations: &mut Vec<PredicateObligation<'tcx>>)
-> Ty<'tcx>
{
obligations: &mut Vec<PredicateObligation<'tcx>>,
) -> Ty<'tcx> {
opt_normalize_projection_type(selcx, param_env, projection_ty.clone(), cause.clone(), depth,
obligations)
.unwrap_or_else(move || {
@ -507,9 +504,8 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>,
depth: usize,
obligations: &mut Vec<PredicateObligation<'tcx>>)
-> Option<Ty<'tcx>>
{
obligations: &mut Vec<PredicateObligation<'tcx>>,
) -> Option<Ty<'tcx>> {
let infcx = selcx.infcx();
let projection_ty = infcx.resolve_vars_if_possible(&projection_ty);
@ -705,9 +701,10 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
/// If there are unresolved type variables, then we need to include
/// any subobligations that bind them, at least until those type
/// variables are fully resolved.
fn prune_cache_value_obligations<'a, 'tcx>(infcx: &'a InferCtxt<'a, 'tcx>,
result: &NormalizedTy<'tcx>)
-> NormalizedTy<'tcx> {
fn prune_cache_value_obligations<'a, 'tcx>(
infcx: &'a InferCtxt<'a, 'tcx>,
result: &NormalizedTy<'tcx>,
) -> NormalizedTy<'tcx> {
if infcx.unresolved_type_vars(&result.value).is_none() {
return NormalizedTy { value: result.value, obligations: vec![] };
}
@ -768,9 +765,8 @@ fn get_paranoid_cache_value_obligation<'a, 'tcx>(
param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>,
depth: usize)
-> PredicateObligation<'tcx>
{
depth: usize,
) -> PredicateObligation<'tcx> {
let trait_ref = projection_ty.trait_ref(infcx.tcx).to_poly_trait_ref();
Obligation {
cause,
@ -799,13 +795,13 @@ fn get_paranoid_cache_value_obligation<'a, 'tcx>(
/// an error for this obligation, but we legitimately should not,
/// because it contains `[type error]`. Yuck! (See issue #29857 for
/// one case where this arose.)
fn normalize_to_error<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>,
depth: usize)
-> NormalizedTy<'tcx>
{
fn normalize_to_error<'a, 'tcx>(
selcx: &mut SelectionContext<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>,
depth: usize,
) -> NormalizedTy<'tcx> {
let trait_ref = projection_ty.trait_ref(selcx.tcx()).to_poly_trait_ref();
let trait_obligation = Obligation { cause,
recursion_depth: depth,
@ -863,9 +859,8 @@ fn with_addl_obligations(mut self,
/// - `obligation` must be fully normalized
fn project_type<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>)
-> Result<ProjectedTy<'tcx>, ProjectionTyError<'tcx>>
{
obligation: &ProjectionTyObligation<'tcx>,
) -> Result<ProjectedTy<'tcx>, ProjectionTyError<'tcx>> {
debug!("project(obligation={:?})",
obligation);
@ -929,8 +924,8 @@ fn assemble_candidates_from_param_env<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>)
{
candidate_set: &mut ProjectionTyCandidateSet<'tcx>,
) {
debug!("assemble_candidates_from_param_env(..)");
assemble_candidates_from_predicates(selcx,
obligation,
@ -954,8 +949,8 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>)
{
candidate_set: &mut ProjectionTyCandidateSet<'tcx>,
) {
debug!("assemble_candidates_from_trait_def(..)");
let tcx = selcx.tcx();
@ -992,8 +987,9 @@ fn assemble_candidates_from_predicates<'cx, 'tcx, I>(
obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>,
ctor: fn(ty::PolyProjectionPredicate<'tcx>) -> ProjectionTyCandidate<'tcx>,
env_predicates: I)
where I: IntoIterator<Item=ty::Predicate<'tcx>>
env_predicates: I,
) where
I: IntoIterator<Item = ty::Predicate<'tcx>>,
{
debug!("assemble_candidates_from_predicates(obligation={:?})",
obligation);
@ -1033,8 +1029,8 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>)
{
candidate_set: &mut ProjectionTyCandidateSet<'tcx>,
) {
// If we are resolving `<T as TraitRef<...>>::Item == Type`,
// start out by selecting the predicate `T as TraitRef<...>`:
let poly_trait_ref = obligation_trait_ref.to_poly_trait_ref();
@ -1181,9 +1177,8 @@ fn confirm_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate: ProjectionTyCandidate<'tcx>)
-> Progress<'tcx>
{
candidate: ProjectionTyCandidate<'tcx>,
) -> Progress<'tcx> {
debug!("confirm_candidate(candidate={:?}, obligation={:?})",
candidate,
obligation);
@ -1204,9 +1199,8 @@ fn confirm_select_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>,
vtable: Selection<'tcx>)
-> Progress<'tcx>
{
vtable: Selection<'tcx>,
) -> Progress<'tcx> {
match vtable {
super::VtableImpl(data) =>
confirm_impl_candidate(selcx, obligation, data),
@ -1232,10 +1226,9 @@ fn confirm_select_candidate<'cx, 'tcx>(
fn confirm_object_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>)
-> Progress<'tcx>
{
obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>,
) -> Progress<'tcx> {
let self_ty = obligation_trait_ref.self_ty();
let object_ty = selcx.infcx().shallow_resolve(self_ty);
debug!("confirm_object_candidate(object_ty={:?})",
@ -1298,9 +1291,8 @@ fn confirm_object_candidate<'cx, 'tcx>(
fn confirm_generator_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
vtable: VtableGeneratorData<'tcx, PredicateObligation<'tcx>>)
-> Progress<'tcx>
{
vtable: VtableGeneratorData<'tcx, PredicateObligation<'tcx>>,
) -> Progress<'tcx> {
let gen_sig = vtable.substs.poly_sig(vtable.generator_def_id, selcx.tcx());
let Normalized {
value: gen_sig,
@ -1351,9 +1343,8 @@ fn confirm_generator_candidate<'cx, 'tcx>(
fn confirm_fn_pointer_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
fn_pointer_vtable: VtableFnPointerData<'tcx, PredicateObligation<'tcx>>)
-> Progress<'tcx>
{
fn_pointer_vtable: VtableFnPointerData<'tcx, PredicateObligation<'tcx>>,
) -> Progress<'tcx> {
let fn_type = selcx.infcx().shallow_resolve(fn_pointer_vtable.fn_ty);
let sig = fn_type.fn_sig(selcx.tcx());
let Normalized {
@ -1373,9 +1364,8 @@ fn confirm_fn_pointer_candidate<'cx, 'tcx>(
fn confirm_closure_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
vtable: VtableClosureData<'tcx, PredicateObligation<'tcx>>)
-> Progress<'tcx>
{
vtable: VtableClosureData<'tcx, PredicateObligation<'tcx>>,
) -> Progress<'tcx> {
let tcx = selcx.tcx();
let infcx = selcx.infcx();
let closure_sig_ty = vtable.substs.closure_sig_ty(vtable.closure_def_id, tcx);
@ -1406,9 +1396,8 @@ fn confirm_callable_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
fn_sig: ty::PolyFnSig<'tcx>,
flag: util::TupleArgumentsFlag)
-> Progress<'tcx>
{
flag: util::TupleArgumentsFlag,
) -> Progress<'tcx> {
let tcx = selcx.tcx();
debug!("confirm_callable_candidate({:?},{:?})",
@ -1481,9 +1470,8 @@ fn confirm_param_env_candidate<'cx, 'tcx>(
fn confirm_impl_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
impl_vtable: VtableImplData<'tcx, PredicateObligation<'tcx>>)
-> Progress<'tcx>
{
impl_vtable: VtableImplData<'tcx, PredicateObligation<'tcx>>,
) -> Progress<'tcx> {
let VtableImplData { impl_def_id, substs, nested } = impl_vtable;
let tcx = selcx.tcx();
@ -1524,9 +1512,8 @@ fn confirm_impl_candidate<'cx, 'tcx>(
fn assoc_ty_def<'cx, 'tcx>(
selcx: &SelectionContext<'cx, 'tcx>,
impl_def_id: DefId,
assoc_ty_def_id: DefId)
-> specialization_graph::NodeItem<ty::AssocItem>
{
assoc_ty_def_id: DefId,
) -> specialization_graph::NodeItem<ty::AssocItem> {
let tcx = selcx.tcx();
let assoc_ty_name = tcx.associated_item(assoc_ty_def_id).ident;
let trait_def_id = tcx.impl_trait_ref(impl_def_id).unwrap().def_id;
@ -1609,10 +1596,10 @@ pub struct ProjectionCacheKey<'tcx> {
}
impl<'cx, 'tcx> ProjectionCacheKey<'tcx> {
pub fn from_poly_projection_predicate(selcx: &mut SelectionContext<'cx, 'tcx>,
predicate: &ty::PolyProjectionPredicate<'tcx>)
-> Option<Self>
{
pub fn from_poly_projection_predicate(
selcx: &mut SelectionContext<'cx, 'tcx>,
predicate: &ty::PolyProjectionPredicate<'tcx>,
) -> Option<Self> {
let infcx = selcx.infcx();
// We don't do cross-snapshot caching of obligations with escaping regions,
// so there's no cache key to use

View File

@ -44,9 +44,7 @@ fn fully_perform(
/// which produces the resulting query region constraints.
///
/// [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html
pub trait QueryTypeOp<'tcx>:
fmt::Debug + Sized + TypeFoldable<'tcx> + Lift<'tcx>
{
pub trait QueryTypeOp<'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + Lift<'tcx> {
type QueryResponse: TypeFoldable<'tcx> + Lift<'tcx>;
/// Give query the option for a simple fast path that never

View File

@ -69,12 +69,13 @@ pub struct OverlapError {
/// through associated type projection. We deal with such cases by using
/// *fulfillment* to relate the two impls, requiring that all projections are
/// resolved.
pub fn translate_substs<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
source_impl: DefId,
source_substs: SubstsRef<'tcx>,
target_node: specialization_graph::Node)
-> SubstsRef<'tcx> {
pub fn translate_substs<'a, 'tcx>(
infcx: &InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
source_impl: DefId,
source_substs: SubstsRef<'tcx>,
target_node: specialization_graph::Node,
) -> SubstsRef<'tcx> {
debug!("translate_substs({:?}, {:?}, {:?}, {:?})",
param_env, source_impl, source_substs, target_node);
let source_trait_ref = infcx.tcx
@ -209,11 +210,12 @@ pub(super) fn specializes<'tcx>(
/// generics of `target_impl`, including both those needed to unify with
/// `source_trait_ref` and those whose identity is determined via a where
/// clause in the impl.
fn fulfill_implication<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
source_trait_ref: ty::TraitRef<'tcx>,
target_impl: DefId)
-> Result<SubstsRef<'tcx>, ()> {
fn fulfill_implication<'a, 'tcx>(
infcx: &InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
source_trait_ref: ty::TraitRef<'tcx>,
target_impl: DefId,
) -> Result<SubstsRef<'tcx>, ()> {
debug!("fulfill_implication({:?}, trait_ref={:?} |- {:?} applies)",
param_env, source_trait_ref, target_impl);

View File

@ -383,12 +383,7 @@ pub fn insert(
}
/// Insert cached metadata mapping from a child impl back to its parent.
pub fn record_impl_from_cstore(
&mut self,
tcx: TyCtxt<'tcx>,
parent: DefId,
child: DefId,
) {
pub fn record_impl_from_cstore(&mut self, tcx: TyCtxt<'tcx>, parent: DefId, child: DefId) {
if self.parent.insert(child, parent).is_some() {
bug!("When recording an impl from the crate store, information about its parent \
was already present.");

View File

@ -12,10 +12,7 @@
use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized};
fn anonymize_predicate<'tcx>(
tcx: TyCtxt<'tcx>,
pred: &ty::Predicate<'tcx>,
) -> ty::Predicate<'tcx> {
fn anonymize_predicate<'tcx>(tcx: TyCtxt<'tcx>, pred: &ty::Predicate<'tcx>) -> ty::Predicate<'tcx> {
match *pred {
ty::Predicate::Trait(ref data) =>
ty::Predicate::Trait(tcx.anonymize_late_bound_regions(data)),
@ -420,10 +417,7 @@ pub struct SupertraitDefIds<'tcx> {
visited: FxHashSet<DefId>,
}
pub fn supertrait_def_ids<'tcx>(
tcx: TyCtxt<'tcx>,
trait_def_id: DefId,
) -> SupertraitDefIds<'tcx> {
pub fn supertrait_def_ids<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId) -> SupertraitDefIds<'tcx> {
SupertraitDefIds {
tcx,
stack: vec![trait_def_id],
@ -489,13 +483,12 @@ fn size_hint(&self) -> (usize, Option<usize>) {
/// Instantiate all bound parameters of the impl with the given substs,
/// returning the resulting trait ref and all obligations that arise.
/// The obligations are closed under normalization.
pub fn impl_trait_ref_and_oblig<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
impl_def_id: DefId,
impl_substs: SubstsRef<'tcx>,)
-> (ty::TraitRef<'tcx>,
Vec<PredicateObligation<'tcx>>)
{
pub fn impl_trait_ref_and_oblig<'a, 'tcx>(
selcx: &mut SelectionContext<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
impl_def_id: DefId,
impl_substs: SubstsRef<'tcx>,
) -> (ty::TraitRef<'tcx>, Vec<PredicateObligation<'tcx>>) {
let impl_trait_ref =
selcx.tcx().impl_trait_ref(impl_def_id).unwrap();
let impl_trait_ref =

View File

@ -104,11 +104,7 @@ pub struct OverloadedDeref<'tcx> {
}
impl<'tcx> OverloadedDeref<'tcx> {
pub fn method_call(
&self,
tcx: TyCtxt<'tcx>,
source: Ty<'tcx>,
) -> (DefId, SubstsRef<'tcx>) {
pub fn method_call(&self, tcx: TyCtxt<'tcx>, source: Ty<'tcx>) -> (DefId, SubstsRef<'tcx>) {
let trait_def_id = match self.mutbl {
hir::MutImmutable => tcx.lang_items().deref_trait(),
hir::MutMutable => tcx.lang_items().deref_mut_trait()

View File

@ -139,7 +139,7 @@ fn new(arena: &'tcx SyncDroplessArena) -> CtxtInterners<'tcx> {
fn intern_ty(
local: &CtxtInterners<'tcx>,
global: &CtxtInterners<'tcx>,
st: TyKind<'tcx>
st: TyKind<'tcx>,
) -> Ty<'tcx> {
let flags = super::flags::FlagComputation::for_sty(&st);
@ -857,7 +857,6 @@ impl<'a, 'tcx> Lift<'tcx> for CanonicalUserTypeAnnotation<'a> {
}
}
/// Canonicalized user type annotation.
pub type CanonicalUserType<'tcx> = Canonical<'tcx, UserType<'tcx>>;
@ -1139,12 +1138,13 @@ pub fn alloc_steal_mir(self, mir: Body<'tcx>) -> &'tcx Steal<Body<'tcx>> {
self.arena.alloc(Steal::new(mir))
}
pub fn alloc_adt_def(self,
did: DefId,
kind: AdtKind,
variants: IndexVec<VariantIdx, ty::VariantDef>,
repr: ReprOptions)
-> &'tcx ty::AdtDef {
pub fn alloc_adt_def(
self,
did: DefId,
kind: AdtKind,
variants: IndexVec<VariantIdx, ty::VariantDef>,
repr: ReprOptions,
) -> &'tcx ty::AdtDef {
let def = ty::AdtDef::new(self, did, kind, variants, repr);
self.arena.alloc(def)
}
@ -1923,9 +1923,9 @@ pub fn with_thread_locals<F, R>(f: F) -> R
/// Sets `context` as the new current ImplicitCtxt for the duration of the function `f`
#[inline]
pub fn enter_context<'a, 'tcx, F, R>(context: &ImplicitCtxt<'a, 'tcx>,
f: F) -> R
where F: FnOnce(&ImplicitCtxt<'a, 'tcx>) -> R
pub fn enter_context<'a, 'tcx, F, R>(context: &ImplicitCtxt<'a, 'tcx>, f: F) -> R
where
F: FnOnce(&ImplicitCtxt<'a, 'tcx>) -> R,
{
set_tlv(context as *const _ as usize, || {
f(&context)
@ -1999,7 +1999,8 @@ pub unsafe fn with_global<F, R>(f: F) -> R
/// Allows access to the current ImplicitCtxt in a closure if one is available
#[inline]
pub fn with_context_opt<F, R>(f: F) -> R
where F: for<'a, 'tcx> FnOnce(Option<&ImplicitCtxt<'a, 'tcx>>) -> R
where
F: for<'a, 'tcx> FnOnce(Option<&ImplicitCtxt<'a, 'tcx>>) -> R,
{
let context = get_tlv();
if context == 0 {
@ -2017,7 +2018,8 @@ pub fn with_context_opt<F, R>(f: F) -> R
/// Panics if there is no ImplicitCtxt available
#[inline]
pub fn with_context<F, R>(f: F) -> R
where F: for<'a, 'tcx> FnOnce(&ImplicitCtxt<'a, 'tcx>) -> R
where
F: for<'a, 'tcx> FnOnce(&ImplicitCtxt<'a, 'tcx>) -> R,
{
with_context_opt(|opt_context| f(opt_context.expect("no ImplicitCtxt stored in tls")))
}
@ -2254,14 +2256,14 @@ fn borrow<'a>(&'a self) -> &'a GoalKind<'tcx> {
}
impl<'tcx> Borrow<[ExistentialPredicate<'tcx>]>
for Interned<'tcx, List<ExistentialPredicate<'tcx>>> {
for Interned<'tcx, List<ExistentialPredicate<'tcx>>>
{
fn borrow<'a>(&'a self) -> &'a [ExistentialPredicate<'tcx>] {
&self.0[..]
}
}
impl<'tcx> Borrow<[Predicate<'tcx>]>
for Interned<'tcx, List<Predicate<'tcx>>> {
impl<'tcx> Borrow<[Predicate<'tcx>]> for Interned<'tcx, List<Predicate<'tcx>>> {
fn borrow<'a>(&'a self) -> &'a [Predicate<'tcx>] {
&self.0[..]
}
@ -2273,15 +2275,13 @@ fn borrow<'a>(&'a self) -> &'a Const<'tcx> {
}
}
impl<'tcx> Borrow<[Clause<'tcx>]>
for Interned<'tcx, List<Clause<'tcx>>> {
impl<'tcx> Borrow<[Clause<'tcx>]> for Interned<'tcx, List<Clause<'tcx>>> {
fn borrow<'a>(&'a self) -> &'a [Clause<'tcx>] {
&self.0[..]
}
}
impl<'tcx> Borrow<[Goal<'tcx>]>
for Interned<'tcx, List<Goal<'tcx>>> {
impl<'tcx> Borrow<[Goal<'tcx>]> for Interned<'tcx, List<Goal<'tcx>>> {
fn borrow<'a>(&'a self) -> &'a [Goal<'tcx>] {
&self.0[..]
}
@ -2942,9 +2942,7 @@ pub fn is_late_bound(self, id: HirId) -> bool {
.unwrap_or(false)
}
pub fn object_lifetime_defaults(self, id: HirId)
-> Option<&'tcx [ObjectLifetimeDefault]>
{
pub fn object_lifetime_defaults(self, id: HirId) -> Option<&'tcx [ObjectLifetimeDefault]> {
self.object_lifetime_defaults_map(id.owner)
.and_then(|map| map.get(&id.local_id).map(|v| &**v))
}

View File

@ -443,12 +443,7 @@ struct BoundVarReplacer<'a, 'tcx> {
}
impl<'a, 'tcx> BoundVarReplacer<'a, 'tcx> {
fn new<F, G, H>(
tcx: TyCtxt<'tcx>,
fld_r: &'a mut F,
fld_t: &'a mut G,
fld_c: &'a mut H,
) -> Self
fn new<F, G, H>(tcx: TyCtxt<'tcx>, fld_r: &'a mut F, fld_t: &'a mut G, fld_c: &'a mut H) -> Self
where
F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
G: FnMut(ty::BoundTy) -> Ty<'tcx>,

View File

@ -2443,23 +2443,26 @@ fn hash_stable<W: StableHasherResult>(&self,
});
impl<'tcx> HashStable<StableHashingContext<'tcx>> for Align {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'tcx>,
hasher: &mut StableHasher<W>) {
fn hash_stable<W: StableHasherResult>(
&self,
hcx: &mut StableHashingContext<'tcx>,
hasher: &mut StableHasher<W>,
) {
self.bytes().hash_stable(hcx, hasher);
}
}
impl<'tcx> HashStable<StableHashingContext<'tcx>> for Size {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'tcx>,
hasher: &mut StableHasher<W>) {
fn hash_stable<W: StableHasherResult>(
&self,
hcx: &mut StableHashingContext<'tcx>,
hasher: &mut StableHasher<W>,
) {
self.bytes().hash_stable(hcx, hasher);
}
}
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for LayoutError<'tcx>
{
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for LayoutError<'tcx> {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {

View File

@ -975,11 +975,7 @@ pub fn region_param(
}
/// Returns the `GenericParamDef` associated with this `ParamTy`.
pub fn type_param(
&'tcx self,
param: &ParamTy,
tcx: TyCtxt<'tcx>,
) -> &'tcx GenericParamDef {
pub fn type_param(&'tcx self, param: &ParamTy, tcx: TyCtxt<'tcx>) -> &'tcx GenericParamDef {
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
let param = &self.params[index as usize];
match param.kind {
@ -993,11 +989,7 @@ pub fn type_param(
}
/// Returns the `ConstParameterDef` associated with this `ParamConst`.
pub fn const_param(
&'tcx self,
param: &ParamConst,
tcx: TyCtxt<'tcx>,
) -> &GenericParamDef {
pub fn const_param(&'tcx self, param: &ParamConst, tcx: TyCtxt<'tcx>) -> &GenericParamDef {
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
let param = &self.params[index as usize];
match param.kind {
@ -1772,7 +1764,8 @@ pub fn into_parts(self) -> (ParamEnv<'tcx>, T) {
}
impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for ParamEnvAnd<'tcx, T>
where T: HashStable<StableHashingContext<'a>>
where
T: HashStable<StableHashingContext<'a>>,
{
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
@ -2363,11 +2356,7 @@ pub fn variant_of_res(&self, res: Res) -> &VariantDef {
}
#[inline]
pub fn eval_explicit_discr(
&self,
tcx: TyCtxt<'tcx>,
expr_did: DefId,
) -> Option<Discr<'tcx>> {
pub fn eval_explicit_discr(&self, tcx: TyCtxt<'tcx>, expr_did: DefId) -> Option<Discr<'tcx>> {
let param_env = ParamEnv::empty();
let repr_type = self.repr.discr_type();
let substs = InternalSubsts::identity_for_item(tcx.global_tcx(), expr_did);
@ -2714,7 +2703,7 @@ pub fn to_user_str(&self) -> &'static str {
#[derive(Debug, Clone)]
pub enum Attributes<'tcx> {
Owned(Lrc<[ast::Attribute]>),
Borrowed(&'tcx [ast::Attribute])
Borrowed(&'tcx [ast::Attribute]),
}
impl<'tcx> ::std::ops::Deref for Attributes<'tcx> {
@ -3007,9 +2996,7 @@ pub fn item_name(self, id: DefId) -> Symbol {
}
/// Returns the possibly-auto-generated MIR of a `(DefId, Subst)` pair.
pub fn instance_mir(self, instance: ty::InstanceDef<'tcx>)
-> &'tcx Body<'tcx>
{
pub fn instance_mir(self, instance: ty::InstanceDef<'tcx>) -> &'tcx Body<'tcx> {
match instance {
ty::InstanceDef::Item(did) => {
self.optimized_mir(did)
@ -3300,10 +3287,7 @@ fn crate_hash<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> Svh {
tcx.hir().crate_hash
}
fn instance_def_size_estimate<'tcx>(
tcx: TyCtxt<'tcx>,
instance_def: InstanceDef<'tcx>,
) -> usize {
fn instance_def_size_estimate<'tcx>(tcx: TyCtxt<'tcx>, instance_def: InstanceDef<'tcx>) -> usize {
match instance_def {
InstanceDef::Item(..) |
InstanceDef::DropGlue(..) => {

View File

@ -326,9 +326,7 @@ fn print(&self, cx: P) -> Result<Self::Output, Self::Error> {
}
}
impl<'tcx, P: Printer<'tcx>> Print<'tcx, P>
for &'tcx ty::List<ty::ExistentialPredicate<'tcx>>
{
impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
type Output = P::DynExistential;
type Error = P::Error;
fn print(&self, cx: P) -> Result<Self::Output, Self::Error> {

View File

@ -23,11 +23,7 @@ pub struct DefPathBasedNames<'tcx> {
}
impl DefPathBasedNames<'tcx> {
pub fn new(
tcx: TyCtxt<'tcx>,
omit_disambiguators: bool,
omit_local_crate_name: bool,
) -> Self {
pub fn new(tcx: TyCtxt<'tcx>, omit_disambiguators: bool, omit_local_crate_name: bool) -> Self {
DefPathBasedNames { tcx, omit_disambiguators, omit_local_crate_name }
}

View File

@ -167,15 +167,15 @@ pub fn highlighting_bound_region(
/// Trait for printers that pretty-print using `fmt::Write` to the printer.
pub trait PrettyPrinter<'tcx>:
Printer<'tcx,
Printer<
'tcx,
Error = fmt::Error,
Path = Self,
Region = Self,
Type = Self,
DynExistential = Self,
Const = Self,
> +
fmt::Write
> + fmt::Write
{
/// Like `print_def_path` but for value paths.
fn print_value_path(
@ -186,21 +186,17 @@ fn print_value_path(
self.print_def_path(def_id, substs)
}
fn in_binder<T>(
self,
value: &ty::Binder<T>,
) -> Result<Self, Self::Error>
where T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>
fn in_binder<T>(self, value: &ty::Binder<T>) -> Result<Self, Self::Error>
where
T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>,
{
value.skip_binder().print(self)
}
/// Print comma-separated elements.
fn comma_sep<T>(
mut self,
mut elems: impl Iterator<Item = T>,
) -> Result<Self, Self::Error>
where T: Print<'tcx, Self, Output = Self, Error = Self::Error>
fn comma_sep<T>(mut self, mut elems: impl Iterator<Item = T>) -> Result<Self, Self::Error>
where
T: Print<'tcx, Self, Output = Self, Error = Self::Error>,
{
if let Some(first) = elems.next() {
self = first.print(self)?;
@ -1239,11 +1235,9 @@ fn print_value_path(
Ok(self)
}
fn in_binder<T>(
self,
value: &ty::Binder<T>,
) -> Result<Self, Self::Error>
where T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>
fn in_binder<T>(self, value: &ty::Binder<T>) -> Result<Self, Self::Error>
where
T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>,
{
self.pretty_in_binder(value)
}
@ -1417,11 +1411,9 @@ pub fn pretty_print_region(
// HACK(eddyb) limited to `FmtPrinter` because of `binder_depth`,
// `region_index` and `used_region_names`.
impl<F: fmt::Write> FmtPrinter<'_, 'tcx, F> {
pub fn pretty_in_binder<T>(
mut self,
value: &ty::Binder<T>,
) -> Result<Self, fmt::Error>
where T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx>
pub fn pretty_in_binder<T>(mut self, value: &ty::Binder<T>) -> Result<Self, fmt::Error>
where
T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx>,
{
fn name_by_region_index(index: usize) -> InternedString {
match index {
@ -1510,9 +1502,9 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
}
}
impl<'tcx, T, P: PrettyPrinter<'tcx>> Print<'tcx, P>
for ty::Binder<T>
where T: Print<'tcx, P, Output = P, Error = P::Error> + TypeFoldable<'tcx>
impl<'tcx, T, P: PrettyPrinter<'tcx>> Print<'tcx, P> for ty::Binder<T>
where
T: Print<'tcx, P, Output = P, Error = P::Error> + TypeFoldable<'tcx>,
{
type Output = P;
type Error = P::Error;
@ -1521,10 +1513,10 @@ fn print(&self, cx: P) -> Result<Self::Output, Self::Error> {
}
}
impl<'tcx, T, U, P: PrettyPrinter<'tcx>> Print<'tcx, P>
for ty::OutlivesPredicate<T, U>
where T: Print<'tcx, P, Output = P, Error = P::Error>,
U: Print<'tcx, P, Output = P, Error = P::Error>,
impl<'tcx, T, U, P: PrettyPrinter<'tcx>> Print<'tcx, P> for ty::OutlivesPredicate<T, U>
where
T: Print<'tcx, P, Output = P, Error = P::Error>,
U: Print<'tcx, P, Output = P, Error = P::Error>,
{
type Output = P;
type Error = P::Error;

View File

@ -100,11 +100,7 @@ pub(super) fn r#await(
}
#[cfg(not(parallel_compiler))]
pub(super) fn find_cycle_in_stack(
&self,
tcx: TyCtxt<'tcx>,
span: Span,
) -> CycleError<'tcx> {
pub(super) fn find_cycle_in_stack(&self, tcx: TyCtxt<'tcx>, span: Span) -> CycleError<'tcx> {
// Get the current executing query (waiter) and find the waitee amongst its parents
let mut current_job = tls::with_related_context(tcx, |icx| icx.query.clone());
let mut cycle = Vec::new();

View File

@ -156,11 +156,7 @@ pub fn new_empty(source_map: &'sess SourceMap) -> OnDiskCache<'sess> {
}
}
pub fn serialize<'tcx, E>(
&self,
tcx: TyCtxt<'tcx>,
encoder: &mut E,
) -> Result<(), E::Error>
pub fn serialize<'tcx, E>(&self, tcx: TyCtxt<'tcx>, encoder: &mut E) -> Result<(), E::Error>
where
E: ty_codec::TyEncoder,
{

View File

@ -104,11 +104,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
/// This function is inlined because that results in a noticeable speed-up
/// for some compile-time benchmarks.
#[inline(always)]
pub(super) fn try_get(
tcx: TyCtxt<'tcx>,
span: Span,
key: &Q::Key,
) -> TryGetJob<'a, 'tcx, Q> {
pub(super) fn try_get(tcx: TyCtxt<'tcx>, span: Span, key: &Q::Key) -> TryGetJob<'a, 'tcx, Q> {
let cache = Q::query_cache(tcx);
loop {
let mut lock = cache.borrow_mut();
@ -351,11 +347,7 @@ pub fn try_print_query_stack() {
}
#[inline(never)]
pub(super) fn get_query<Q: QueryDescription<'tcx>>(
self,
span: Span,
key: Q::Key)
-> Q::Value {
pub(super) fn get_query<Q: QueryDescription<'tcx>>(self, span: Span, key: Q::Key) -> Q::Value {
debug!("ty::query::get_query<{}>(key={:?}, span={:?})",
Q::NAME.as_str(),
key,
@ -444,9 +436,8 @@ fn load_from_disk_and_cache_in_memory<Q: QueryDescription<'tcx>>(
key: Q::Key,
prev_dep_node_index: SerializedDepNodeIndex,
dep_node_index: DepNodeIndex,
dep_node: &DepNode
) -> Q::Value
{
dep_node: &DepNode,
) -> Q::Value {
// Note this function can be called concurrently from the same query
// We must ensure that this is handled correctly
@ -537,8 +528,8 @@ fn force_query_with_job<Q: QueryDescription<'tcx>>(
self,
key: Q::Key,
job: JobOwner<'_, 'tcx, Q>,
dep_node: DepNode)
-> (Q::Value, DepNodeIndex) {
dep_node: DepNode,
) -> (Q::Value, DepNodeIndex) {
// If the following assertion triggers, it can have two reasons:
// 1. Something is wrong with DepNode creation, either here or
// in DepGraph::try_mark_green()
@ -623,12 +614,7 @@ pub(super) fn ensure_query<Q: QueryDescription<'tcx>>(self, key: Q::Key) -> () {
}
#[allow(dead_code)]
fn force_query<Q: QueryDescription<'tcx>>(
self,
key: Q::Key,
span: Span,
dep_node: DepNode
) {
fn force_query<Q: QueryDescription<'tcx>>(self, key: Q::Key, span: Span, dep_node: DepNode) {
profq_msg!(
self,
ProfileQueriesMsg::QueryBegin(span.data(),

View File

@ -804,7 +804,7 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> bool {
}
}
impl<'tcx, T:TypeFoldable<'tcx>, U:TypeFoldable<'tcx>> TypeFoldable<'tcx> for (T, U) {
impl<'tcx, T: TypeFoldable<'tcx>, U: TypeFoldable<'tcx>> TypeFoldable<'tcx> for (T, U) {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> (T, U) {
(self.0.fold_with(folder), self.1.fold_with(folder))
}
@ -862,7 +862,7 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
}
}
impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
self.map_bound_ref(|ty| ty.fold_with(folder))
}

View File

@ -558,11 +558,7 @@ pub fn state_tys(
/// This is the types of the fields of a generator which are not stored in a
/// variant.
#[inline]
pub fn prefix_tys(
self,
def_id: DefId,
tcx: TyCtxt<'tcx>,
) -> impl Iterator<Item = Ty<'tcx>> {
pub fn prefix_tys(self, def_id: DefId, tcx: TyCtxt<'tcx>) -> impl Iterator<Item = Ty<'tcx>> {
self.upvar_tys(def_id, tcx)
}
}
@ -2265,11 +2261,7 @@ pub fn from_scalar(tcx: TyCtxt<'tcx>, val: Scalar, ty: Ty<'tcx>) -> &'tcx Self {
}
#[inline]
pub fn from_bits(
tcx: TyCtxt<'tcx>,
bits: u128,
ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> &'tcx Self {
pub fn from_bits(tcx: TyCtxt<'tcx>, bits: u128, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> &'tcx Self {
let ty = tcx.lift_to_global(&ty).unwrap();
let size = tcx.layout_of(ty).unwrap_or_else(|e| {
panic!("could not compute layout for {:?}: {:?}", ty, e)
@ -2308,11 +2300,7 @@ pub fn to_ptr(&self) -> Option<Pointer> {
}
#[inline]
pub fn assert_bits(
&self,
tcx: TyCtxt<'_>,
ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> Option<u128> {
pub fn assert_bits(&self, tcx: TyCtxt<'_>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> Option<u128> {
assert_eq!(self.ty, ty.value);
let ty = tcx.lift_to_global(&ty).unwrap();
let size = tcx.layout_of(ty).ok()?.size;

View File

@ -241,12 +241,7 @@ pub fn for_item<F>(tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRe
tcx.intern_substs(&substs)
}
pub fn extend_to<F>(
&self,
tcx: TyCtxt<'tcx>,
def_id: DefId,
mut mk_kind: F,
) -> SubstsRef<'tcx>
pub fn extend_to<F>(&self, tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRef<'tcx>
where
F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>,
{
@ -418,21 +413,11 @@ fn subst(&self, tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>]) -> Self {
self.subst_spanned(tcx, substs, None)
}
fn subst_spanned(
&self,
tcx: TyCtxt<'tcx>,
substs: &[Kind<'tcx>],
span: Option<Span>,
) -> Self;
fn subst_spanned(&self, tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>], span: Option<Span>) -> Self;
}
impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T {
fn subst_spanned(
&self,
tcx: TyCtxt<'tcx>,
substs: &[Kind<'tcx>],
span: Option<Span>,
) -> T {
fn subst_spanned(&self, tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>], span: Option<Span>) -> T {
let mut folder = SubstFolder { tcx,
substs,
span,

View File

@ -105,11 +105,7 @@ pub fn checked_add(self, tcx: TyCtxt<'tcx>, n: u128) -> (Self, bool) {
pub trait IntTypeExt {
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>;
fn disr_incr<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
val: Option<Discr<'tcx>>,
) -> Option<Discr<'tcx>>;
fn disr_incr<'tcx>(&self, tcx: TyCtxt<'tcx>, val: Option<Discr<'tcx>>) -> Option<Discr<'tcx>>;
fn initial_discriminant<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Discr<'tcx>;
}
@ -138,11 +134,7 @@ fn initial_discriminant<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Discr<'tcx> {
}
}
fn disr_incr<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
val: Option<Discr<'tcx>>,
) -> Option<Discr<'tcx>> {
fn disr_incr<'tcx>(&self, tcx: TyCtxt<'tcx>, val: Option<Discr<'tcx>>) -> Option<Discr<'tcx>> {
if let Some(val) = val {
assert_eq!(self.to_ty(tcx), val.ty);
let (new, oflo) = val.checked_add(tcx, 1);
@ -714,11 +706,7 @@ pub fn is_copy_modulo_regions(
/// over-approximation in generic contexts, where one can have
/// strange rules like `<T as Foo<'static>>::Bar: Sized` that
/// actually carry lifetime requirements.
pub fn is_sized(
&'tcx self,
tcx_at: TyCtxtAt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
) -> bool {
pub fn is_sized(&'tcx self, tcx_at: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
tcx_at.is_sized_raw(param_env.and(self))
}
@ -979,10 +967,7 @@ fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
#[derive(Clone, HashStable)]
pub struct NeedsDrop(pub bool);
fn needs_drop_raw<'tcx>(
tcx: TyCtxt<'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> NeedsDrop {
fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> NeedsDrop {
let (param_env, ty) = query.into_parts();
let needs_drop = |ty: Ty<'tcx>| -> bool {

View File

@ -15,13 +15,13 @@
/// inference variable, returns `None`, because we are not able to
/// make any progress at all. This is to prevent "livelock" where we
/// say "$0 is WF if $0 is WF".
pub fn obligations<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
body_id: hir::HirId,
ty: Ty<'tcx>,
span: Span)
-> Option<Vec<traits::PredicateObligation<'tcx>>>
{
pub fn obligations<'a, 'tcx>(
infcx: &InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
body_id: hir::HirId,
ty: Ty<'tcx>,
span: Span,
) -> Option<Vec<traits::PredicateObligation<'tcx>>> {
let mut wf = WfPredicates { infcx,
param_env,
body_id,
@ -41,25 +41,25 @@ pub fn obligations<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
/// 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
/// if `Bar: Eq`.
pub fn trait_obligations<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
body_id: hir::HirId,
trait_ref: &ty::TraitRef<'tcx>,
span: Span)
-> Vec<traits::PredicateObligation<'tcx>>
{
pub fn trait_obligations<'a, 'tcx>(
infcx: &InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
body_id: hir::HirId,
trait_ref: &ty::TraitRef<'tcx>,
span: Span,
) -> Vec<traits::PredicateObligation<'tcx>> {
let mut wf = WfPredicates { infcx, param_env, body_id, span, out: vec![] };
wf.compute_trait_ref(trait_ref, Elaborate::All);
wf.normalize()
}
pub fn predicate_obligations<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
body_id: hir::HirId,
predicate: &ty::Predicate<'tcx>,
span: Span)
-> Vec<traits::PredicateObligation<'tcx>>
{
pub fn predicate_obligations<'a, 'tcx>(
infcx: &InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
body_id: hir::HirId,
predicate: &ty::Predicate<'tcx>,
span: Span,
) -> Vec<traits::PredicateObligation<'tcx>> {
let mut wf = WfPredicates { infcx, param_env, body_id, span, out: vec![] };
// (*) ok to skip binders, because wf code is prepared for it

View File

@ -125,11 +125,7 @@ fn codegen_allocator<'tcx>(
) {
unsafe { allocator::codegen(tcx, mods, kind) }
}
fn compile_codegen_unit<'a, 'tcx: 'a>(
&self,
tcx: TyCtxt<'tcx>,
cgu_name: InternedString,
) {
fn compile_codegen_unit<'a, 'tcx: 'a>(&self, tcx: TyCtxt<'tcx>, cgu_name: InternedString) {
base::compile_codegen_unit(tcx, cgu_name);
}
fn target_machine_factory(

View File

@ -210,12 +210,7 @@ pub fn push_debuginfo_type_name<'tcx>(
}
}
fn push_item_name(
tcx: TyCtxt<'tcx>,
def_id: DefId,
qualified: bool,
output: &mut String,
) {
fn push_item_name(tcx: TyCtxt<'tcx>, def_id: DefId, qualified: bool, output: &mut String) {
if qualified {
output.push_str(&tcx.crate_name(def_id.krate).as_str());
for path_element in tcx.def_path(def_id).data {

View File

@ -367,11 +367,9 @@ fn region_should_not_be_omitted(
) -> bool {
false
}
fn comma_sep<T>(
mut self,
mut elems: impl Iterator<Item = T>,
) -> Result<Self, Self::Error>
where T: Print<'tcx, Self, Output = Self, Error = Self::Error>
fn comma_sep<T>(mut self, mut elems: impl Iterator<Item = T>) -> Result<Self, Self::Error>
where
T: Print<'tcx, Self, Output = Self, Error = Self::Error>,
{
if let Some(first) = elems.next() {
self = first.print(self)?;

View File

@ -184,11 +184,7 @@ fn visit_struct_field(&mut self, s: &'tcx hir::StructField) {
}
}
fn check_paths<'tcx>(
tcx: TyCtxt<'tcx>,
if_this_changed: &Sources,
then_this_would_need: &Targets,
) {
fn check_paths<'tcx>(tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_would_need: &Targets) {
// Return early here so as not to construct the query, which is not cheap.
if if_this_changed.is_empty() {
for &(target_span, _, _, _) in then_this_would_need {

View File

@ -811,7 +811,7 @@ pub fn create_global_ctxt(
resolutions: Resolutions,
outputs: OutputFilenames,
tx: mpsc::Sender<Box<dyn Any + Send>>,
crate_name: &str
crate_name: &str,
) -> BoxedGlobalCtxt {
let sess = compiler.session().clone();
let cstore = compiler.cstore.clone();

View File

@ -620,7 +620,7 @@ pub fn get_predicates(
tcx: TyCtxt<'tcx>,
) -> ty::GenericPredicates<'tcx> {
self.entry(item_id).predicates.unwrap().decode((self, tcx))
}
}
pub fn get_predicates_defined_on(
&self,
@ -701,19 +701,12 @@ pub fn get_coerce_unsized_info(&self,
self.get_impl_data(id).coerce_unsized_info
}
pub fn get_impl_trait(
&self,
id: DefIndex,
tcx: TyCtxt<'tcx>,
) -> Option<ty::TraitRef<'tcx>> {
pub fn get_impl_trait(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Option<ty::TraitRef<'tcx>> {
self.get_impl_data(id).trait_ref.map(|tr| tr.decode((self, tcx)))
}
/// Iterates over all the stability attributes in the given crate.
pub fn get_lib_features(
&self,
tcx: TyCtxt<'tcx>,
) -> &'tcx [(ast::Name, Option<ast::Name>)] {
pub fn get_lib_features(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(ast::Name, Option<ast::Name>)] {
// FIXME: For a proc macro crate, not sure whether we should return the "host"
// features or an empty Vec. Both don't cause ICEs.
tcx.arena.alloc_from_iter(self.root
@ -883,11 +876,7 @@ pub fn is_item_mir_available(&self, id: DefIndex) -> bool {
self.maybe_entry(id).and_then(|item| item.decode(self).mir).is_some()
}
pub fn maybe_get_optimized_mir(
&self,
tcx: TyCtxt<'tcx>,
id: DefIndex,
) -> Option<Body<'tcx>> {
pub fn maybe_get_optimized_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Option<Body<'tcx>> {
match self.is_proc_macro(id) {
true => None,
false => self.entry(id).mir.map(|mir| mir.decode((self, tcx))),

View File

@ -1511,12 +1511,7 @@ fn check_for_local_borrow(&mut self, borrow: &BorrowData<'tcx>, yield_span: Span
}
}
fn check_activations(
&mut self,
location: Location,
span: Span,
flow_state: &Flows<'cx, 'tcx>,
) {
fn check_activations(&mut self, location: Location, span: Span, flow_state: &Flows<'cx, 'tcx>) {
// Two-phase borrow support: For each activation that is newly
// generated at this statement, check if it interferes with
// another borrow.
@ -2034,11 +2029,11 @@ fn check_access_permissions(
};
}
fn is_local_ever_initialized(&self,
local: Local,
flow_state: &Flows<'cx, 'tcx>)
-> Option<InitIndex>
{
fn is_local_ever_initialized(
&self,
local: Local,
flow_state: &Flows<'cx, 'tcx>,
) -> Option<InitIndex> {
let mpi = self.move_data.rev_lookup.find_local(local);
let ii = &self.move_data.init_path_map[mpi];
for &index in ii {
@ -2050,11 +2045,7 @@ fn is_local_ever_initialized(&self,
}
/// Adds the place into the used mutable variables set
fn add_used_mut<'d>(
&mut self,
root_place: RootPlace<'d, 'tcx>,
flow_state: &Flows<'cx, 'tcx>,
) {
fn add_used_mut<'d>(&mut self, root_place: RootPlace<'d, 'tcx>, flow_state: &Flows<'cx, 'tcx>) {
match root_place {
RootPlace {
place: Place::Base(PlaceBase::Local(local)),

View File

@ -33,11 +33,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}
/// Search the upvars (if any) to find one that references fr. Return its index.
crate fn get_upvar_index_for_region(
&self,
tcx: TyCtxt<'tcx>,
fr: RegionVid,
) -> Option<usize> {
crate fn get_upvar_index_for_region(&self, tcx: TyCtxt<'tcx>, fr: RegionVid) -> Option<usize> {
let upvar_index = self
.universal_regions
.defining_ty
@ -134,5 +130,4 @@ impl<'tcx> RegionInferenceContext<'tcx> {
(argument_name, argument_span)
}
}

View File

@ -16,10 +16,7 @@ pub fn renumber_mir<'tcx>(infcx: &InferCtxt<'_, 'tcx>, body: &mut Body<'tcx>) {
/// Replaces all regions appearing in `value` with fresh inference
/// variables.
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
T: TypeFoldable<'tcx>,
{

View File

@ -150,9 +150,7 @@ fn add_type_test(&mut self, type_test: TypeTest<'tcx>) {
}
}
impl<'a, 'b, 'tcx> TypeOutlivesDelegate<'tcx>
for &'a mut ConstraintConversion<'b, 'tcx>
{
impl<'a, 'b, 'tcx> TypeOutlivesDelegate<'tcx> for &'a mut ConstraintConversion<'b, 'tcx> {
fn push_sub_region_constraint(
&mut self,
_origin: SubregionOrigin<'tcx>,

View File

@ -36,7 +36,6 @@ fn is_prefix_of(&self, other: &Place<'tcx>) -> bool {
}
}
pub(super) struct Prefixes<'cx, 'tcx: 'cx> {
body: &'cx Body<'tcx>,
tcx: TyCtxt<'tcx>,
@ -60,11 +59,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
/// Returns an iterator over the prefixes of `place`
/// (inclusive) from longest to smallest, potentially
/// terminating the iteration early based on `kind`.
pub(super) fn prefixes(
&self,
place: &'cx Place<'tcx>,
kind: PrefixSet,
) -> Prefixes<'cx, 'tcx> {
pub(super) fn prefixes(&self, place: &'cx Place<'tcx>, kind: PrefixSet) -> Prefixes<'cx, 'tcx> {
Prefixes {
next: Some(place),
kind,

View File

@ -70,11 +70,7 @@ pub struct MaybeInitializedPlaces<'a, 'tcx: 'a> {
}
impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
pub fn new(
tcx: TyCtxt<'tcx>,
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'tcx>,
) -> Self {
pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self {
MaybeInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
}
}
@ -125,11 +121,7 @@ pub struct MaybeUninitializedPlaces<'a, 'tcx: 'a> {
}
impl<'a, 'tcx> MaybeUninitializedPlaces<'a, 'tcx> {
pub fn new(
tcx: TyCtxt<'tcx>,
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'tcx>,
) -> Self {
pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self {
MaybeUninitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
}
}
@ -179,11 +171,7 @@ pub struct DefinitelyInitializedPlaces<'a, 'tcx: 'a> {
}
impl<'a, 'tcx: 'a> DefinitelyInitializedPlaces<'a, 'tcx> {
pub fn new(
tcx: TyCtxt<'tcx>,
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'tcx>,
) -> Self {
pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self {
DefinitelyInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
}
}
@ -228,11 +216,7 @@ pub struct EverInitializedPlaces<'a, 'tcx: 'a> {
}
impl<'a, 'tcx: 'a> EverInitializedPlaces<'a, 'tcx> {
pub fn new(
tcx: TyCtxt<'tcx>,
body: &'a Body<'tcx>,
mdpe: &'a MoveDataParamEnv<'tcx>,
) -> Self {
pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self {
EverInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
}
}
@ -241,7 +225,6 @@ impl<'a, 'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'a, 'tcx> {
fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
}
impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex,
state: DropFlagState)

View File

@ -52,8 +52,7 @@ pub struct Cx<'a, 'tcx: 'a> {
}
impl<'a, 'tcx> Cx<'a, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>,
src_id: hir::HirId) -> Cx<'a, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>, src_id: hir::HirId) -> Cx<'a, 'tcx> {
let tcx = infcx.tcx;
let src_def_id = tcx.hir().local_def_id_from_hir_id(src_id);
let tables = tcx.typeck_tables_of(src_def_id);

View File

@ -174,11 +174,9 @@ fn region_should_not_be_omitted(
) -> bool {
false
}
fn comma_sep<T>(
mut self,
mut elems: impl Iterator<Item = T>,
) -> Result<Self, Self::Error>
where T: Print<'tcx, Self, Output = Self, Error = Self::Error>
fn comma_sep<T>(mut self, mut elems: impl Iterator<Item = T>) -> Result<Self, Self::Error>
where
T: Print<'tcx, Self, Output = Self, Error = Self::Error>,
{
if let Some(first) = elems.next() {
self = first.print(self)?;

View File

@ -315,10 +315,7 @@ pub fn collect_crate_mono_items<'tcx>(
// Find all non-generic items by walking the HIR. These items serve as roots to
// start monomorphizing from.
fn collect_roots<'tcx>(
tcx: TyCtxt<'tcx>,
mode: MonoItemCollectionMode,
) -> Vec<MonoItem<'tcx>> {
fn collect_roots<'tcx>(tcx: TyCtxt<'tcx>, mode: MonoItemCollectionMode) -> Vec<MonoItem<'tcx>> {
debug!("Collecting roots");
let mut roots = Vec::new();
@ -1188,11 +1185,7 @@ fn create_mono_items_for_default_impls<'tcx>(
}
/// Scan the miri alloc in order to find function calls, closures, and drop-glue
fn collect_miri<'tcx>(
tcx: TyCtxt<'tcx>,
alloc_id: AllocId,
output: &mut Vec<MonoItem<'tcx>>,
) {
fn collect_miri<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut Vec<MonoItem<'tcx>>) {
let alloc_kind = tcx.alloc_map.lock().get(alloc_id);
match alloc_kind {
Some(GlobalAlloc::Static(def_id)) => {

View File

@ -203,10 +203,7 @@ struct PostInliningPartitioning<'tcx> {
internalization_candidates: FxHashSet<MonoItem<'tcx>>,
}
fn place_root_mono_items<'tcx, I>(
tcx: TyCtxt<'tcx>,
mono_items: I,
) -> PreInliningPartitioning<'tcx>
fn place_root_mono_items<'tcx, I>(tcx: TyCtxt<'tcx>, mono_items: I) -> PreInliningPartitioning<'tcx>
where
I: Iterator<Item = MonoItem<'tcx>>,
{

View File

@ -163,11 +163,7 @@ fn local_decls_for_sig<'tcx>(sig: &ty::FnSig<'tcx>, span: Span)
.collect()
}
fn build_drop_shim<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
ty: Option<Ty<'tcx>>,
) -> Body<'tcx> {
fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>) -> Body<'tcx> {
debug!("build_drop_shim(def_id={:?}, ty={:?})", def_id, ty);
// Check if this is a generator, if so, return the drop glue for it

View File

@ -31,12 +31,7 @@ pub enum AddCallGuards {
*/
impl MirPass for AddCallGuards {
fn run_pass<'tcx>(
&self,
_tcx: TyCtxt<'tcx>,
_src: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
self.add_call_guards(body);
}
}

View File

@ -46,11 +46,7 @@ fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Bod
}
}
pub fn add_moves_for_packed_drops<'tcx>(
tcx: TyCtxt<'tcx>,
body: &mut Body<'tcx>,
def_id: DefId,
) {
pub fn add_moves_for_packed_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, def_id: DefId) {
let patch = add_moves_for_packed_drops_patch(tcx, body, def_id);
patch.apply(body);
}

View File

@ -74,12 +74,7 @@ fn may_have_reference<'tcx>(ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> bool {
}
impl MirPass for AddRetag {
fn run_pass<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
_src: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
if !tcx.sess.opts.debugging_opts.mir_emit_retag {
return;
}

View File

@ -27,12 +27,7 @@
pub struct DeleteNonCodegenStatements;
impl MirPass for CleanupNonCodegenStatements {
fn run_pass<'tcx>(
&self,
_tcx: TyCtxt<'tcx>,
_source: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
let mut delete = DeleteNonCodegenStatements;
delete.visit_body(body);
}

View File

@ -31,12 +31,7 @@
pub struct ConstProp;
impl MirPass for ConstProp {
fn run_pass<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
source: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
// will be evaluated by miri and produce its errors there
if source.promoted.is_some() {
return;

View File

@ -30,12 +30,7 @@
pub struct CopyPropagation;
impl MirPass for CopyPropagation {
fn run_pass<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
_source: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
// We only run when the MIR optimization level is > 1.
// This avoids a slow pass, and messing up debug info.
if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 {

View File

@ -6,12 +6,7 @@
pub struct Deaggregator;
impl MirPass for Deaggregator {
fn run_pass<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
_source: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
let local_decls = &*local_decls;
for bb in basic_blocks {

View File

@ -18,12 +18,7 @@ fn name<'a>(&'a self) -> Cow<'a, str> {
Cow::Borrowed(self.0)
}
fn run_pass<'tcx>(
&self,
_tcx: TyCtxt<'tcx>,
_source: MirSource<'tcx>,
_body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, _body: &mut Body<'tcx>) {
}
}

View File

@ -1092,12 +1092,7 @@ fn create_cases<'tcx, F>(
}
impl MirPass for StateTransform {
fn run_pass<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
source: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
let yield_ty = if let Some(yield_ty) = body.yield_ty {
yield_ty
} else {

View File

@ -38,12 +38,7 @@ struct CallSite<'tcx> {
}
impl MirPass for Inline {
fn run_pass<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
source: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
if tcx.sess.opts.debugging_opts.mir_opt_level >= 2 {
Inliner { tcx, source }.run_pass(body);
}

View File

@ -10,12 +10,7 @@
pub struct Lower128Bit;
impl MirPass for Lower128Bit {
fn run_pass<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
_src: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
let debugging_override = tcx.sess.opts.debugging_opts.lower_128bit_ops;
let target_default = tcx.sess.host.options.i128_lowering;
if !debugging_override.unwrap_or(target_default) {

View File

@ -141,12 +141,7 @@ fn name<'a>(&'a self) -> Cow<'a, str> {
default_name::<Self>()
}
fn run_pass<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
source: MirSource<'tcx>,
body: &mut Body<'tcx>,
);
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>);
}
pub fn run_passes(

View File

@ -19,12 +19,7 @@ pub fn remove_noop_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>)
}
impl MirPass for RemoveNoopLandingPads {
fn run_pass<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
_src: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
remove_noop_landing_pads(tcx, body);
}
}

View File

@ -57,12 +57,7 @@ fn name<'a>(&'a self) -> Cow<'a, str> {
Cow::Borrowed(&self.label)
}
fn run_pass<'tcx>(
&self,
_tcx: TyCtxt<'tcx>,
_src: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
debug!("SimplifyCfg({:?}) - simplifying {:?}", self.label, body);
simplify_cfg(body);
}

View File

@ -19,12 +19,7 @@ fn name<'a>(&'a self) -> Cow<'a, str> {
Cow::Borrowed(&self.label)
}
fn run_pass<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
_src: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
for block in body.basic_blocks_mut() {
let terminator = block.terminator_mut();
terminator.kind = match terminator.kind {

View File

@ -37,12 +37,7 @@
pub struct UniformArrayMoveOut;
impl MirPass for UniformArrayMoveOut {
fn run_pass<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
_src: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
let mut patch = MirPatch::new(body);
{
let mut visitor = UniformArrayMoveOutVisitor{body, patch: &mut patch, tcx};
@ -164,12 +159,7 @@ fn uniform(&mut self,
pub struct RestoreSubsliceArrayMoveOut;
impl MirPass for RestoreSubsliceArrayMoveOut {
fn run_pass<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
_src: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
let mut patch = MirPatch::new(body);
{
let mut visitor = RestoreDataCollector {

View File

@ -21,10 +21,7 @@
pub use self::graphviz::write_node_label as write_graphviz_node_label;
/// If possible, suggest replacing `ref` with `ref mut`.
pub fn suggest_ref_mut<'tcx>(
tcx: TyCtxt<'tcx>,
binding_span: Span,
) -> Option<(String)> {
pub fn suggest_ref_mut<'tcx>(tcx: TyCtxt<'tcx>, binding_span: Span) -> Option<(String)> {
let hi_src = tcx.sess.source_map().span_to_snippet(binding_span).unwrap();
if hi_src.starts_with("ref")
&& hi_src["ref".len()..].starts_with(Pattern_White_Space)

View File

@ -93,11 +93,7 @@ pub fn dump_mir<'tcx, F>(
);
}
pub fn dump_enabled<'tcx>(
tcx: TyCtxt<'tcx>,
pass_name: &str,
source: MirSource<'tcx>,
) -> bool {
pub fn dump_enabled<'tcx>(tcx: TyCtxt<'tcx>, pass_name: &str, source: MirSource<'tcx>) -> bool {
let filters = match tcx.sess.opts.debugging_opts.dump_mir {
None => return false,
Some(ref filters) => filters,
@ -370,11 +366,7 @@ pub fn write_basic_block<'tcx, F>(
/// After we print the main statement, we sometimes dump extra
/// information. There's often a lot of little things "nuzzled up" in
/// a statement.
fn write_extra<'tcx, F>(
tcx: TyCtxt<'tcx>,
write: &mut dyn Write,
mut visit_op: F,
) -> io::Result<()>
fn write_extra<'tcx, F>(tcx: TyCtxt<'tcx>, write: &mut dyn Write, mut visit_op: F) -> io::Result<()>
where
F: FnMut(&mut ExtraComments<'tcx>),
{

View File

@ -337,11 +337,7 @@ fn item_tables<'a, 'tcx>(
if tcx.has_typeck_tables(def_id) { tcx.typeck_tables_of(def_id) } else { empty_tables }
}
fn min<'tcx>(
vis1: ty::Visibility,
vis2: ty::Visibility,
tcx: TyCtxt<'tcx>,
) -> ty::Visibility {
fn min<'tcx>(vis1: ty::Visibility, vis2: ty::Visibility, tcx: TyCtxt<'tcx>) -> ty::Visibility {
if vis1.is_at_least(vis2, tcx) { vis2 } else { vis1 }
}

View File

@ -179,10 +179,7 @@ fn make_solution(
impl context::ContextOps<ChalkArenas<'tcx>> for ChalkContext<'tcx> {
/// Returns `true` if this is a coinductive goal: basically proving that an auto trait
/// is implemented or proving that a trait reference is well-formed.
fn is_coinductive(
&self,
goal: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>
) -> bool {
fn is_coinductive(&self, goal: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>) -> bool {
use rustc::traits::{WellFormed, WhereClause};
let mut goal = goal.value.goal;
@ -441,12 +438,9 @@ fn canonicalize_constrained_subst(
fn u_canonicalize_goal(
&mut self,
value: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>,
) -> (
Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>,
UniverseMap,
) {
) -> (Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, UniverseMap) {
(value.clone(), UniverseMap)
}
}
fn invert_goal(
&mut self,
@ -652,7 +646,8 @@ fn upcast(&self) -> Self::Upcasted {
}
impl<'tcx, T> Upcast<'tcx> for Canonical<'tcx, T>
where T: Upcast<'tcx>
where
T: Upcast<'tcx>,
{
type Upcasted = Canonical<'tcx, T::Upcasted>;

View File

@ -15,10 +15,7 @@
use crate::generic_types;
use std::iter;
crate fn wf_clause_for_raw_ptr<'tcx>(
tcx: TyCtxt<'tcx>,
mutbl: hir::Mutability,
) -> Clauses<'tcx> {
crate fn wf_clause_for_raw_ptr<'tcx>(tcx: TyCtxt<'tcx>, mutbl: hir::Mutability) -> Clauses<'tcx> {
let ptr_ty = generic_types::raw_ptr(tcx, mutbl);
let wf_clause = ProgramClause {

View File

@ -15,7 +15,7 @@
environment: Environment<'tcx>,
variance: ty::Variance,
a: &T,
b: &T
b: &T,
) -> RelateResult<'tcx, UnificationResult<'tcx>> {
debug!("unify(
a = {:?},
@ -50,10 +50,7 @@ struct ChalkTypeRelatingDelegate<'me, 'tcx: 'me> {
}
impl ChalkTypeRelatingDelegate<'me, 'tcx> {
fn new(
infcx: &'me InferCtxt<'me, 'tcx>,
environment: Environment<'tcx>,
) -> Self {
fn new(infcx: &'me InferCtxt<'me, 'tcx>, environment: Environment<'tcx>) -> Self {
Self {
infcx,
environment,

View File

@ -39,7 +39,7 @@ fn implied_outlives_bounds<'tcx>(
fn compute_implied_outlives_bounds<'tcx>(
infcx: &InferCtxt<'_, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
ty: Ty<'tcx>
ty: Ty<'tcx>,
) -> Fallible<Vec<OutlivesBound<'tcx>>> {
let tcx = infcx.tcx;

View File

@ -1027,8 +1027,7 @@ fn check_pat_struct(
expected: Ty<'tcx>,
def_bm: ty::BindingMode,
discrim_span: Option<Span>,
) -> Ty<'tcx>
{
) -> Ty<'tcx> {
// Resolve the path and check the definition for errors.
let (variant, pat_ty) = if let Some(variant_ty) = self.check_struct_path(qpath, pat.hir_id)
{

View File

@ -31,7 +31,7 @@ pub struct Autoderef<'a, 'tcx: 'a> {
include_raw_pointers: bool,
span: Span,
silence_errors: bool,
reached_recursion_limit: bool
reached_recursion_limit: bool,
}
impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> {
@ -86,13 +86,13 @@ fn next(&mut self) -> Option<Self::Item> {
}
impl<'a, 'tcx> Autoderef<'a, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
body_id: hir::HirId,
span: Span,
base_ty: Ty<'tcx>)
-> Autoderef<'a, 'tcx>
{
pub fn new(
infcx: &'a InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
body_id: hir::HirId,
span: Span,
base_ty: Ty<'tcx>,
) -> Autoderef<'a, 'tcx> {
Autoderef {
infcx,
body_id,
@ -172,13 +172,15 @@ pub fn step_count(&self) -> usize {
}
/// Returns the adjustment steps.
pub fn adjust_steps(&self, fcx: &FnCtxt<'a, 'tcx>, needs: Needs)
-> Vec<Adjustment<'tcx>> {
pub fn adjust_steps(&self, fcx: &FnCtxt<'a, 'tcx>, needs: Needs) -> Vec<Adjustment<'tcx>> {
fcx.register_infer_ok_obligations(self.adjust_steps_as_infer_ok(fcx, needs))
}
pub fn adjust_steps_as_infer_ok(&self, fcx: &FnCtxt<'a, 'tcx>, needs: Needs)
-> InferOk<'tcx, Vec<Adjustment<'tcx>>> {
pub fn adjust_steps_as_infer_ok(
&self,
fcx: &FnCtxt<'a, 'tcx>,
needs: Needs,
) -> InferOk<'tcx, Vec<Adjustment<'tcx>>> {
let mut obligations = vec![];
let targets = self.steps.iter().skip(1).map(|&(ty, _)| ty)
.chain(iter::once(self.cur_ty));
@ -239,11 +241,7 @@ pub fn into_obligations(self) -> Vec<traits::PredicateObligation<'tcx>> {
}
}
pub fn report_autoderef_recursion_limit_error<'tcx>(
tcx: TyCtxt<'tcx>,
span: Span,
ty: Ty<'tcx>,
) {
pub fn report_autoderef_recursion_limit_error<'tcx>(tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>) {
// We've reached the recursion limit, error gracefully.
let suggested_limit = *tcx.sess.recursion_limit.get() * 2;
let msg = format!("reached the recursion limit while auto-dereferencing `{:?}`",

View File

@ -158,12 +158,13 @@ fn from(ErrorReported: ErrorReported) -> Self {
}
}
fn make_invalid_casting_error<'a, 'tcx>(sess: &'a Session,
span: Span,
expr_ty: Ty<'tcx>,
cast_ty: Ty<'tcx>,
fcx: &FnCtxt<'a, 'tcx>)
-> DiagnosticBuilder<'a> {
fn make_invalid_casting_error<'a, 'tcx>(
sess: &'a Session,
span: Span,
expr_ty: Ty<'tcx>,
cast_ty: Ty<'tcx>,
fcx: &FnCtxt<'a, 'tcx>,
) -> DiagnosticBuilder<'a> {
type_error_struct!(sess, span, expr_ty, E0606,
"casting `{}` as `{}` is invalid",
fcx.ty_to_string(expr_ty),
@ -171,13 +172,14 @@ fn make_invalid_casting_error<'a, 'tcx>(sess: &'a Session,
}
impl<'a, 'tcx> CastCheck<'tcx> {
pub fn new(fcx: &FnCtxt<'a, 'tcx>,
expr: &'tcx hir::Expr,
expr_ty: Ty<'tcx>,
cast_ty: Ty<'tcx>,
cast_span: Span,
span: Span)
-> Result<CastCheck<'tcx>, ErrorReported> {
pub fn new(
fcx: &FnCtxt<'a, 'tcx>,
expr: &'tcx hir::Expr,
expr_ty: Ty<'tcx>,
cast_ty: Ty<'tcx>,
cast_span: Span,
span: Span,
) -> Result<CastCheck<'tcx>, ErrorReported> {
let check = CastCheck {
expr,
expr_ty,
@ -531,11 +533,12 @@ fn do_check(&self, fcx: &FnCtxt<'a, 'tcx>) -> Result<CastKind, CastError> {
}
}
fn check_ptr_ptr_cast(&self,
fcx: &FnCtxt<'a, 'tcx>,
m_expr: ty::TypeAndMut<'tcx>,
m_cast: ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError> {
fn check_ptr_ptr_cast(
&self,
fcx: &FnCtxt<'a, 'tcx>,
m_expr: ty::TypeAndMut<'tcx>,
m_cast: ty::TypeAndMut<'tcx>,
) -> Result<CastKind, CastError> {
debug!("check_ptr_ptr_cast m_expr={:?} m_cast={:?}", m_expr, m_cast);
// ptr-ptr cast. vtables must match.
@ -572,10 +575,11 @@ fn check_ptr_ptr_cast(&self,
}
}
fn check_fptr_ptr_cast(&self,
fcx: &FnCtxt<'a, 'tcx>,
m_cast: ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError> {
fn check_fptr_ptr_cast(
&self,
fcx: &FnCtxt<'a, 'tcx>,
m_cast: ty::TypeAndMut<'tcx>,
) -> Result<CastKind, CastError> {
// fptr-ptr cast. must be to thin ptr
match fcx.pointer_kind(m_cast.ty, self.span)? {
@ -585,10 +589,11 @@ fn check_fptr_ptr_cast(&self,
}
}
fn check_ptr_addr_cast(&self,
fcx: &FnCtxt<'a, 'tcx>,
m_expr: ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError> {
fn check_ptr_addr_cast(
&self,
fcx: &FnCtxt<'a, 'tcx>,
m_expr: ty::TypeAndMut<'tcx>,
) -> Result<CastKind, CastError> {
// ptr-addr cast. must be from thin ptr
match fcx.pointer_kind(m_expr.ty, self.span)? {
@ -598,11 +603,12 @@ fn check_ptr_addr_cast(&self,
}
}
fn check_ref_cast(&self,
fcx: &FnCtxt<'a, 'tcx>,
m_expr: ty::TypeAndMut<'tcx>,
m_cast: ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError> {
fn check_ref_cast(
&self,
fcx: &FnCtxt<'a, 'tcx>,
m_expr: ty::TypeAndMut<'tcx>,
m_cast: ty::TypeAndMut<'tcx>,
) -> Result<CastKind, CastError> {
// array-ptr-cast.
if m_expr.mutbl == hir::MutImmutable && m_cast.mutbl == hir::MutImmutable {
@ -623,10 +629,11 @@ fn check_ref_cast(&self,
Err(CastError::IllegalCast)
}
fn check_addr_ptr_cast(&self,
fcx: &FnCtxt<'a, 'tcx>,
m_cast: TypeAndMut<'tcx>)
-> Result<CastKind, CastError> {
fn check_addr_ptr_cast(
&self,
fcx: &FnCtxt<'a, 'tcx>,
m_cast: TypeAndMut<'tcx>,
) -> Result<CastKind, CastError> {
// ptr-addr cast. pointer must be thin.
match fcx.pointer_kind(m_cast.ty, self.span)? {
None => Err(CastError::UnknownCastPtrKind),

View File

@ -121,9 +121,11 @@ fn success<'tcx>(adj: Vec<Adjustment<'tcx>>,
}
impl<'f, 'tcx> Coerce<'f, 'tcx> {
fn new(fcx: &'f FnCtxt<'f, 'tcx>,
cause: ObligationCause<'tcx>,
allow_two_phase: AllowTwoPhase) -> Self {
fn new(
fcx: &'f FnCtxt<'f, 'tcx>,
cause: ObligationCause<'tcx>,
allow_two_phase: AllowTwoPhase,
) -> Self {
Coerce {
fcx,
cause,
@ -1073,12 +1075,13 @@ pub fn merged_ty(&self) -> Ty<'tcx> {
/// could coerce from. This will record `expression`, and later
/// calls to `coerce` may come back and add adjustments and things
/// if necessary.
pub fn coerce<'a>(&mut self,
fcx: &FnCtxt<'a, 'tcx>,
cause: &ObligationCause<'tcx>,
expression: &'tcx hir::Expr,
expression_ty: Ty<'tcx>)
{
pub fn coerce<'a>(
&mut self,
fcx: &FnCtxt<'a, 'tcx>,
cause: &ObligationCause<'tcx>,
expression: &'tcx hir::Expr,
expression_ty: Ty<'tcx>,
) {
self.coerce_inner(fcx,
cause,
Some(expression),
@ -1098,12 +1101,13 @@ pub fn coerce<'a>(&mut self,
/// The `augment_error` gives you a chance to extend the error
/// message, in case any results (e.g., we use this to suggest
/// removing a `;`).
pub fn coerce_forced_unit<'a>(&mut self,
fcx: &FnCtxt<'a, 'tcx>,
cause: &ObligationCause<'tcx>,
augment_error: &mut dyn FnMut(&mut DiagnosticBuilder<'_>),
label_unit_as_expected: bool)
{
pub fn coerce_forced_unit<'a>(
&mut self,
fcx: &FnCtxt<'a, 'tcx>,
cause: &ObligationCause<'tcx>,
augment_error: &mut dyn FnMut(&mut DiagnosticBuilder<'_>),
label_unit_as_expected: bool,
) {
self.coerce_inner(fcx,
cause,
None,
@ -1115,14 +1119,15 @@ pub fn coerce_forced_unit<'a>(&mut self,
/// The inner coercion "engine". If `expression` is `None`, this
/// is a forced-unit case, and hence `expression_ty` must be
/// `Nil`.
fn coerce_inner<'a>(&mut self,
fcx: &FnCtxt<'a, 'tcx>,
cause: &ObligationCause<'tcx>,
expression: Option<&'tcx hir::Expr>,
mut expression_ty: Ty<'tcx>,
augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder<'_>)>,
label_expression_as_expected: bool)
{
fn coerce_inner<'a>(
&mut self,
fcx: &FnCtxt<'a, 'tcx>,
cause: &ObligationCause<'tcx>,
expression: Option<&'tcx hir::Expr>,
mut expression_ty: Ty<'tcx>,
augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder<'_>)>,
label_expression_as_expected: bool,
) {
// Incorporate whatever type inference information we have
// until now; in principle we might also want to process
// pending obligations, but doing so should only improve

View File

@ -410,15 +410,16 @@ fn check_region_bounds_on_impl_method<'tcx>(
Ok(())
}
fn extract_spans_for_error_reporting<'a, 'tcx>(infcx: &infer::InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
terr: &TypeError<'_>,
cause: &ObligationCause<'tcx>,
impl_m: &ty::AssocItem,
impl_sig: ty::FnSig<'tcx>,
trait_m: &ty::AssocItem,
trait_sig: ty::FnSig<'tcx>)
-> (Span, Option<Span>) {
fn extract_spans_for_error_reporting<'a, 'tcx>(
infcx: &infer::InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
terr: &TypeError<'_>,
cause: &ObligationCause<'tcx>,
impl_m: &ty::AssocItem,
impl_sig: ty::FnSig<'tcx>,
trait_m: &ty::AssocItem,
trait_sig: ty::FnSig<'tcx>,
) -> (Span, Option<Span>) {
let tcx = infcx.tcx;
let impl_m_hir_id = tcx.hir().as_local_hir_id(impl_m.def_id).unwrap();
let (impl_m_output, impl_m_iter) = match tcx.hir()

View File

@ -29,10 +29,7 @@
/// struct/enum definition for the nominal type itself (i.e.
/// cannot do `struct S<T>; impl<T:Clone> Drop for S<T> { ... }`).
///
pub fn check_drop_impl<'tcx>(
tcx: TyCtxt<'tcx>,
drop_impl_did: DefId,
) -> Result<(), ErrorReported> {
pub fn check_drop_impl<'tcx>(tcx: TyCtxt<'tcx>, drop_impl_did: DefId) -> Result<(), ErrorReported> {
let dtor_self_type = tcx.type_of(drop_impl_did);
let dtor_predicates = tcx.predicates_of(drop_impl_did);
match dtor_self_type.sty {

View File

@ -75,10 +75,12 @@ fn record(&mut self,
}
}
pub fn resolve_interior<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
def_id: DefId,
body_id: hir::BodyId,
interior: Ty<'tcx>) {
pub fn resolve_interior<'a, 'tcx>(
fcx: &'a FnCtxt<'a, 'tcx>,
def_id: DefId,
body_id: hir::BodyId,
interior: Ty<'tcx>,
) {
let body = fcx.tcx.hir().body(body_id);
let mut visitor = InteriorVisitor {
fcx,

View File

@ -58,11 +58,12 @@ pub fn confirm_method(
}
impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
fn new(fcx: &'a FnCtxt<'a, 'tcx>,
span: Span,
self_expr: &'tcx hir::Expr,
call_expr: &'tcx hir::Expr)
-> ConfirmContext<'a, 'tcx> {
fn new(
fcx: &'a FnCtxt<'a, 'tcx>,
span: Span,
self_expr: &'tcx hir::Expr,
call_expr: &'tcx hir::Expr,
) -> ConfirmContext<'a, 'tcx> {
ConfirmContext {
fcx,
span,
@ -263,10 +264,8 @@ fn fresh_receiver_substs(&mut self,
}
fn extract_existential_trait_ref<R, F>(&mut self, self_ty: Ty<'tcx>, mut closure: F) -> R
where F: FnMut(&mut ConfirmContext<'a, 'tcx>,
Ty<'tcx>,
ty::PolyExistentialTraitRef<'tcx>)
-> R
where
F: FnMut(&mut ConfirmContext<'a, 'tcx>, Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>) -> R,
{
// If we specified that this is an object method, then the
// self-type ought to be something that can be dereferenced to

View File

@ -174,13 +174,14 @@ pub fn method_exists(&self,
/// * `self_ty`: the (unadjusted) type of the self expression (`foo`)
/// * `supplied_method_types`: the explicit method type parameters, if any (`T1..Tn`)
/// * `self_expr`: the self expression (`foo`)
pub fn lookup_method(&self,
self_ty: Ty<'tcx>,
segment: &hir::PathSegment,
span: Span,
call_expr: &'tcx hir::Expr,
self_expr: &'tcx hir::Expr)
-> Result<MethodCallee<'tcx>, MethodError<'tcx>> {
pub fn lookup_method(
&self,
self_ty: Ty<'tcx>,
segment: &hir::PathSegment,
span: Span,
call_expr: &'tcx hir::Expr,
self_expr: &'tcx hir::Expr,
) -> Result<MethodCallee<'tcx>, MethodError<'tcx>> {
debug!("lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})",
segment.ident,
self_ty,
@ -245,13 +246,14 @@ pub fn lookup_method(&self,
Ok(result.callee)
}
fn lookup_probe(&self,
span: Span,
method_name: ast::Ident,
self_ty: Ty<'tcx>,
call_expr: &'tcx hir::Expr,
scope: ProbeScope)
-> probe::PickResult<'tcx> {
fn lookup_probe(
&self,
span: Span,
method_name: ast::Ident,
self_ty: Ty<'tcx>,
call_expr: &'tcx hir::Expr,
scope: ProbeScope,
) -> probe::PickResult<'tcx> {
let mode = probe::Mode::MethodCall;
let self_ty = self.resolve_vars_if_possible(&self_ty);
self.probe_for_name(span, mode, method_name, IsSuggestion(false),

View File

@ -259,18 +259,20 @@ pub fn probe_for_name(&self,
|probe_cx| probe_cx.pick())
}
fn probe_op<OP,R>(&'a self,
span: Span,
mode: Mode,
method_name: Option<ast::Ident>,
return_type: Option<Ty<'tcx>>,
is_suggestion: IsSuggestion,
self_ty: Ty<'tcx>,
scope_expr_id: hir::HirId,
scope: ProbeScope,
op: OP)
-> Result<R, MethodError<'tcx>>
where OP: FnOnce(ProbeContext<'a, 'tcx>) -> Result<R, MethodError<'tcx>>
fn probe_op<OP, R>(
&'a self,
span: Span,
mode: Mode,
method_name: Option<ast::Ident>,
return_type: Option<Ty<'tcx>>,
is_suggestion: IsSuggestion,
self_ty: Ty<'tcx>,
scope_expr_id: hir::HirId,
scope: ProbeScope,
op: OP,
) -> Result<R, MethodError<'tcx>>
where
OP: FnOnce(ProbeContext<'a, 'tcx>) -> Result<R, MethodError<'tcx>>,
{
let mut orig_values = OriginalQueryValues::default();
let param_env_and_self_ty =
@ -463,17 +465,17 @@ fn method_autoderef_steps<'tcx>(
})
}
impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
fn new(fcx: &'a FnCtxt<'a, 'tcx>,
span: Span,
mode: Mode,
method_name: Option<ast::Ident>,
return_type: Option<Ty<'tcx>>,
orig_steps_var_values: OriginalQueryValues<'tcx>,
steps: Lrc<Vec<CandidateStep<'tcx>>>,
is_suggestion: IsSuggestion)
-> ProbeContext<'a, 'tcx> {
fn new(
fcx: &'a FnCtxt<'a, 'tcx>,
span: Span,
mode: Mode,
method_name: Option<ast::Ident>,
return_type: Option<Ty<'tcx>>,
orig_steps_var_values: OriginalQueryValues<'tcx>,
steps: Lrc<Vec<CandidateStep<'tcx>>>,
is_suggestion: IsSuggestion,
) -> ProbeContext<'a, 'tcx> {
ProbeContext {
fcx,
span,
@ -808,12 +810,12 @@ fn assemble_inherent_candidates_from_param(&mut self, param_ty: ty::ParamTy) {
// Do a search through a list of bounds, using a callback to actually
// create the candidates.
fn elaborate_bounds<F>(&mut self,
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
mut mk_cand: F)
where F: for<'b> FnMut(&mut ProbeContext<'b, 'tcx>,
ty::PolyTraitRef<'tcx>,
ty::AssocItem)
fn elaborate_bounds<F>(
&mut self,
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
mut mk_cand: F,
) where
F: for<'b> FnMut(&mut ProbeContext<'b, 'tcx>, ty::PolyTraitRef<'tcx>, ty::AssocItem),
{
let tcx = self.tcx;
for bound_trait_ref in traits::transitive_bounds(tcx, bounds) {
@ -1045,9 +1047,11 @@ fn pick_core(&mut self) -> Option<PickResult<'tcx>> {
.next()
}
fn pick_by_value_method(&mut self, step: &CandidateStep<'tcx>, self_ty: Ty<'tcx>)
-> Option<PickResult<'tcx>>
{
fn pick_by_value_method(
&mut self,
step: &CandidateStep<'tcx>,
self_ty: Ty<'tcx>,
) -> Option<PickResult<'tcx>> {
//! For each type `T` in the step list, this attempts to find a
//! method where the (transformed) self type is exactly `T`. We
//! do however do one transformation on the adjustment: if we
@ -1075,11 +1079,12 @@ fn pick_by_value_method(&mut self, step: &CandidateStep<'tcx>, self_ty: Ty<'tcx>
})
}
fn pick_autorefd_method(&mut self,
step: &CandidateStep<'tcx>,
self_ty: Ty<'tcx>,
mutbl: hir::Mutability)
-> Option<PickResult<'tcx>> {
fn pick_autorefd_method(
&mut self,
step: &CandidateStep<'tcx>,
self_ty: Ty<'tcx>,
mutbl: hir::Mutability,
) -> Option<PickResult<'tcx>> {
let tcx = self.tcx;
// In general, during probing we erase regions. See

Some files were not shown because too many files have changed in this diff Show More