5959 }
6060}
6161
62- trait ParamTypeMapper {
63- fn map_param_ty ( & self , ty : rty:: ParamType ) -> rty:: Type < rty:: Closed > ;
64- }
65-
66- impl < F > ParamTypeMapper for F
67- where
68- F : Fn ( rty:: ParamType ) -> rty:: Type < rty:: Closed > ,
69- {
70- fn map_param_ty ( & self , ty : rty:: ParamType ) -> rty:: Type < rty:: Closed > {
71- self ( ty)
72- }
73- }
74-
7562/// Translates [`mir_ty::Ty`] to [`rty::Type`].
7663///
7764/// This struct implements a translation from Rust MIR types to Thrust types.
@@ -87,9 +74,6 @@ pub struct TypeBuilder<'tcx> {
8774 /// mapped when we translate a [`mir_ty::ParamTy`] to [`rty::ParamType`].
8875 /// See [`rty::TypeParamIdx`] for more details.
8976 param_idx_mapping : HashMap < u32 , rty:: TypeParamIdx > ,
90- /// Optionally also want to further map rty::ParamType to other rty::Type before generating
91- /// templates. This is no-op by default.
92- param_type_mapper : std:: rc:: Rc < dyn ParamTypeMapper > ,
9377}
9478
9579impl < ' tcx > TypeBuilder < ' tcx > {
@@ -109,25 +93,15 @@ impl<'tcx> TypeBuilder<'tcx> {
10993 Self {
11094 tcx,
11195 param_idx_mapping,
112- param_type_mapper : std:: rc:: Rc :: new ( |ty : rty:: ParamType | ty. into ( ) ) ,
11396 }
11497 }
11598
116- pub fn with_param_mapper < F > ( mut self , mapper : F ) -> Self
117- where
118- F : Fn ( rty:: ParamType ) -> rty:: Type < rty:: Closed > + ' static ,
119- {
120- self . param_type_mapper = std:: rc:: Rc :: new ( mapper) ;
121- self
122- }
123-
12499 fn translate_param_type ( & self , ty : & mir_ty:: ParamTy ) -> rty:: Type < rty:: Closed > {
125100 let index = * self
126101 . param_idx_mapping
127102 . get ( & ty. index )
128103 . expect ( "unknown type param idx" ) ;
129- let param_ty = rty:: ParamType :: new ( index) ;
130- self . param_type_mapper . map_param_ty ( param_ty)
104+ rty:: ParamType :: new ( index) . into ( )
131105 }
132106
133107 // TODO: consolidate two impls
@@ -400,17 +374,6 @@ impl<'tcx, 'a, R> FunctionTemplateTypeBuilder<'tcx, 'a, R> {
400374 self . ret_rty = Some ( rty) ;
401375 self
402376 }
403-
404- pub fn would_contain_template ( & self ) -> bool {
405- if self . param_tys . is_empty ( ) {
406- return self . ret_rty . is_none ( ) ;
407- }
408-
409- let last_param_idx = rty:: FunctionParamIdx :: from ( self . param_tys . len ( ) - 1 ) ;
410- let param_annotated =
411- self . param_refinement . is_some ( ) || self . param_rtys . contains_key ( & last_param_idx) ;
412- self . ret_rty . is_none ( ) || !param_annotated
413- }
414377}
415378
416379impl < ' tcx , ' a , R > FunctionTemplateTypeBuilder < ' tcx , ' a , R >
0 commit comments