This repository was archived by the owner on May 28, 2025. It is now read-only.
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> {
131131 . find ( |m| m. kind == ty:: AssocKind :: Fn )
132132 . unwrap ( )
133133 . def_id ;
134- tcx. mk_fn_def ( method_def_id, tcx . mk_substs_trait ( source , [ ] ) )
134+ tcx. mk_fn_def ( method_def_id, [ source ] )
135135 }
136136}
137137
Original file line number Diff line number Diff line change @@ -2565,12 +2565,20 @@ impl<'tcx> TyCtxt<'tcx> {
25652565 }
25662566
25672567 #[ 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 ( ) ;
25692575 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 <_>>( ) ,
25732580 ) ;
2581+ let substs = self . mk_substs ( substs) ;
25742582 self . mk_ty ( FnDef ( def_id, substs) )
25752583 }
25762584
Original file line number Diff line number Diff line change @@ -838,8 +838,6 @@ fn trait_method<'tcx>(
838838 method_name : Symbol ,
839839 substs : impl IntoIterator < Item = impl Into < GenericArg < ' tcx > > > ,
840840) -> ConstantKind < ' tcx > {
841- let substs = tcx. mk_substs ( substs. into_iter ( ) . map ( Into :: into) ) ;
842-
843841 // The unhygienic comparison here is acceptable because this is only
844842 // used on known traits.
845843 let item = tcx
Original file line number Diff line number Diff line change @@ -417,10 +417,8 @@ impl<'tcx> CloneShimBuilder<'tcx> {
417417 ) {
418418 let tcx = self . tcx ;
419419
420- let substs = tcx. mk_substs_trait ( ty, [ ] ) ;
421-
422420 // `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 ] ) ;
424422 let func = Operand :: Constant ( Box :: new ( Constant {
425423 span : self . span ,
426424 user_ty : None ,
You can’t perform that action at this time.
0 commit comments