File tree Expand file tree Collapse file tree 4 files changed +14
-10
lines changed
rustc_mir_build/src/build/matches Expand file tree Collapse file tree 4 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ impl<'tcx> OverloadedDeref<'tcx> {
131
131
. find ( |m| m. kind == ty:: AssocKind :: Fn )
132
132
. unwrap ( )
133
133
. def_id ;
134
- tcx. mk_fn_def ( method_def_id, tcx . mk_substs_trait ( source , [ ] ) )
134
+ tcx. mk_fn_def ( method_def_id, [ source ] )
135
135
}
136
136
}
137
137
Original file line number Diff line number Diff line change @@ -2565,12 +2565,20 @@ impl<'tcx> TyCtxt<'tcx> {
2565
2565
}
2566
2566
2567
2567
#[ inline]
2568
- pub fn mk_fn_def ( self , def_id : DefId , substs : SubstsRef < ' tcx > ) -> Ty < ' tcx > {
2568
+ pub fn mk_fn_def (
2569
+ self ,
2570
+ def_id : DefId ,
2571
+ substs : impl IntoIterator < Item = impl Into < GenericArg < ' tcx > > > ,
2572
+ ) -> Ty < ' tcx > {
2573
+ let substs = substs. into_iter ( ) . map ( Into :: into) ;
2574
+ let n = self . generics_of ( def_id) . count ( ) ;
2569
2575
debug_assert_eq ! (
2570
- self . generics_of( def_id) . count( ) ,
2571
- substs. len( ) ,
2572
- "wrong number of generic parameters for {def_id:?}: {substs:?}" ,
2576
+ ( n, Some ( n) ) ,
2577
+ substs. size_hint( ) ,
2578
+ "wrong number of generic parameters for {def_id:?}: {:?} \n Did you accidentally include the self-type in the params list?" ,
2579
+ substs. collect:: <Vec <_>>( ) ,
2573
2580
) ;
2581
+ let substs = self . mk_substs ( substs) ;
2574
2582
self . mk_ty ( FnDef ( def_id, substs) )
2575
2583
}
2576
2584
Original file line number Diff line number Diff line change @@ -838,8 +838,6 @@ fn trait_method<'tcx>(
838
838
method_name : Symbol ,
839
839
substs : impl IntoIterator < Item = impl Into < GenericArg < ' tcx > > > ,
840
840
) -> ConstantKind < ' tcx > {
841
- let substs = tcx. mk_substs ( substs. into_iter ( ) . map ( Into :: into) ) ;
842
-
843
841
// The unhygienic comparison here is acceptable because this is only
844
842
// used on known traits.
845
843
let item = tcx
Original file line number Diff line number Diff line change @@ -417,10 +417,8 @@ impl<'tcx> CloneShimBuilder<'tcx> {
417
417
) {
418
418
let tcx = self . tcx ;
419
419
420
- let substs = tcx. mk_substs_trait ( ty, [ ] ) ;
421
-
422
420
// `func == Clone::clone(&ty) -> ty`
423
- let func_ty = tcx. mk_fn_def ( self . def_id , substs ) ;
421
+ let func_ty = tcx. mk_fn_def ( self . def_id , [ ty ] ) ;
424
422
let func = Operand :: Constant ( Box :: new ( Constant {
425
423
span : self . span ,
426
424
user_ty : None ,
You can’t perform that action at this time.
0 commit comments