Let mk_fn_def
take an iterator instead to simplify some call sites
This commit is contained in:
parent
7fd9beedc2
commit
0fe86aa977
4 changed files with 14 additions and 10 deletions
|
@ -131,7 +131,7 @@ impl<'tcx> OverloadedDeref<'tcx> {
|
||||||
.find(|m| m.kind == ty::AssocKind::Fn)
|
.find(|m| m.kind == ty::AssocKind::Fn)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.def_id;
|
.def_id;
|
||||||
tcx.mk_fn_def(method_def_id, tcx.mk_substs_trait(source, []))
|
tcx.mk_fn_def(method_def_id, [source])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2565,12 +2565,20 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mk_fn_def(self, def_id: DefId, substs: SubstsRef<'tcx>) -> Ty<'tcx> {
|
pub fn mk_fn_def(
|
||||||
|
self,
|
||||||
|
def_id: DefId,
|
||||||
|
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
|
||||||
|
) -> Ty<'tcx> {
|
||||||
|
let substs = substs.into_iter().map(Into::into);
|
||||||
|
let n = self.generics_of(def_id).count();
|
||||||
debug_assert_eq!(
|
debug_assert_eq!(
|
||||||
self.generics_of(def_id).count(),
|
(n, Some(n)),
|
||||||
substs.len(),
|
substs.size_hint(),
|
||||||
"wrong number of generic parameters for {def_id:?}: {substs:?}",
|
"wrong number of generic parameters for {def_id:?}: {:?} \nDid you accidentally include the self-type in the params list?",
|
||||||
|
substs.collect::<Vec<_>>(),
|
||||||
);
|
);
|
||||||
|
let substs = self.mk_substs(substs);
|
||||||
self.mk_ty(FnDef(def_id, substs))
|
self.mk_ty(FnDef(def_id, substs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -838,8 +838,6 @@ fn trait_method<'tcx>(
|
||||||
method_name: Symbol,
|
method_name: Symbol,
|
||||||
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
|
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
|
||||||
) -> ConstantKind<'tcx> {
|
) -> ConstantKind<'tcx> {
|
||||||
let substs = tcx.mk_substs(substs.into_iter().map(Into::into));
|
|
||||||
|
|
||||||
// The unhygienic comparison here is acceptable because this is only
|
// The unhygienic comparison here is acceptable because this is only
|
||||||
// used on known traits.
|
// used on known traits.
|
||||||
let item = tcx
|
let item = tcx
|
||||||
|
|
|
@ -417,10 +417,8 @@ impl<'tcx> CloneShimBuilder<'tcx> {
|
||||||
) {
|
) {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
|
||||||
let substs = tcx.mk_substs_trait(ty, []);
|
|
||||||
|
|
||||||
// `func == Clone::clone(&ty) -> ty`
|
// `func == Clone::clone(&ty) -> ty`
|
||||||
let func_ty = tcx.mk_fn_def(self.def_id, substs);
|
let func_ty = tcx.mk_fn_def(self.def_id, [ty]);
|
||||||
let func = Operand::Constant(Box::new(Constant {
|
let func = Operand::Constant(Box::new(Constant {
|
||||||
span: self.span,
|
span: self.span,
|
||||||
user_ty: None,
|
user_ty: None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue