Check that type_implements_trait actually is passed the right amount of generic params
This commit is contained in:
parent
0c47deed9f
commit
250dcf421a
4 changed files with 23 additions and 15 deletions
|
@ -113,12 +113,20 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
|||
fn type_implements_trait(
|
||||
&self,
|
||||
trait_def_id: DefId,
|
||||
ty: Ty<'tcx>,
|
||||
self_ty: Ty<'tcx>,
|
||||
params: SubstsRef<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> traits::EvaluationResult {
|
||||
let trait_ref =
|
||||
ty::TraitRef { def_id: trait_def_id, substs: self.tcx.mk_substs_trait(ty, params) };
|
||||
let trait_ref = ty::TraitRef {
|
||||
def_id: trait_def_id,
|
||||
substs: self.tcx.mk_substs_trait(self_ty, params),
|
||||
};
|
||||
|
||||
debug_assert_eq!(
|
||||
self.tcx.generics_of(trait_def_id).count() - 1,
|
||||
params.len(),
|
||||
"wrong number of generic parameters for {trait_def_id:?}, did you accidentally include the self-type in the params list?"
|
||||
);
|
||||
|
||||
let obligation = traits::Obligation {
|
||||
cause: traits::ObligationCause::dummy(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue