X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_trait_selection%2Fsrc%2Ftraits%2Fselect%2Fconfirmation.rs;h=b9025c98fe7b71a421e3c9804d6c4df8aa6a1db1;hb=91afd0263269c44d57fe127f4c20748b5747113b;hp=b97ab39d991fee4dd05b23d2f0f9d46bfe254379;hpb=bdbf0998f3e6f323b680594cad66c7e792c861f4;p=rust.git diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index b97ab39d991..b9025c98fe7 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -12,7 +12,7 @@ use rustc_infer::infer::InferOk; use rustc_infer::infer::LateBoundRegionConversionTime::HigherRankedType; use rustc_middle::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, Subst, SubstsRef}; -use rustc_middle::ty::{self, GenericParamDefKind, Ty}; +use rustc_middle::ty::{self, EarlyBinder, GenericParamDefKind, Ty}; use rustc_middle::ty::{ToPolyTraitRef, ToPredicate}; use rustc_span::def_id::DefId; @@ -174,7 +174,8 @@ fn confirm_projection_candidate( _ => bug!("projection candidate for unexpected type: {:?}", placeholder_self_ty), }; - let candidate_predicate = tcx.item_bounds(def_id)[idx].subst(tcx, substs); + let candidate_predicate = + tcx.bound_item_bounds(def_id).map_bound(|i| i[idx]).subst(tcx, substs); let candidate = candidate_predicate .to_opt_poly_trait_pred() .expect("projection candidate is not a trait predicate") @@ -500,7 +501,7 @@ fn confirm_object_candidate( // This maybe belongs in wf, but that can't (doesn't) handle // higher-ranked things. // Prevent, e.g., `dyn Iterator`. - for bound in self.tcx().item_bounds(assoc_type) { + for bound in self.tcx().bound_item_bounds(assoc_type).transpose_iter() { let subst_bound = if defs.count() == 0 { bound.subst(tcx, trait_predicate.trait_ref.substs) @@ -509,9 +510,9 @@ fn confirm_object_candidate( substs.extend(trait_predicate.trait_ref.substs.iter()); let mut bound_vars: smallvec::SmallVec<[ty::BoundVariableKind; 8]> = smallvec::SmallVec::with_capacity( - bound.kind().bound_vars().len() + defs.count(), + bound.0.kind().bound_vars().len() + defs.count(), ); - bound_vars.extend(bound.kind().bound_vars().into_iter()); + bound_vars.extend(bound.0.kind().bound_vars().into_iter()); InternalSubsts::fill_single(&mut substs, defs, &mut |param, _| match param .kind { @@ -558,7 +559,8 @@ fn confirm_object_candidate( let assoc_ty_substs = tcx.intern_substs(&substs); let bound_vars = tcx.mk_bound_variable_kinds(bound_vars.into_iter()); - let bound = bound.kind().skip_binder().subst(tcx, assoc_ty_substs); + let bound = + EarlyBinder(bound.0.kind().skip_binder()).subst(tcx, assoc_ty_substs); tcx.mk_predicate(ty::Binder::bind_with_vars(bound, bound_vars)) }; let normalized_bound = normalize_with_depth_to( @@ -712,9 +714,9 @@ fn confirm_closure_candidate( /// and we desugared it so that the type of the expression is /// `Closure`, and `Closure` expects `i32` as argument. Then it /// is "as if" the compiler generated this impl: - /// - /// impl Fn(i32) for Closure { ... } - /// + /// ```ignore (illustrative) + /// impl Fn(i32) for Closure { ... } + /// ``` /// Now imagine our obligation is `Closure: Fn(usize)`. So far /// we have matched the self type `Closure`. At this point we'll /// compare the `i32` to `usize` and generate an error. @@ -1005,10 +1007,10 @@ fn confirm_builtin_unsize_candidate( // The last field of the structure has to exist and contain type/const parameters. let (tail_field, prefix_fields) = def.non_enum_variant().fields.split_last().ok_or(Unimplemented)?; - let tail_field_ty = tcx.type_of(tail_field.did); + let tail_field_ty = tcx.bound_type_of(tail_field.did); let mut unsizing_params = GrowableBitSet::new_empty(); - for arg in tail_field_ty.walk() { + for arg in tail_field_ty.0.walk() { if let Some(i) = maybe_unsizing_param_idx(arg) { unsizing_params.insert(i); }