@@ -4954,41 +4954,23 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
4954
4954
} ) ;
4955
4955
}
4956
4956
4957
- fn structurally_resolve_type_or_else < F > ( & self , sp : Span , ty : Ty < ' tcx > , f : F )
4958
- -> Ty < ' tcx >
4959
- where F : Fn ( ) -> Ty < ' tcx >
4960
- {
4957
+ // Resolves `typ` by a single level if `typ` is a type variable. If no
4958
+ // resolution is possible, then an error is reported.
4959
+ pub fn structurally_resolved_type ( & self , sp : Span , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
4961
4960
let mut ty = self . resolve_type_vars_with_obligations ( ty) ;
4962
-
4963
4961
if ty. is_ty_var ( ) {
4964
- let alternative = f ( ) ;
4965
-
4966
4962
// If not, error.
4967
- if alternative. is_ty_var ( ) || alternative. references_error ( ) {
4968
- if !self . is_tainted_by_errors ( ) {
4969
- type_error_struct ! ( self . tcx. sess, sp, ty, E0619 ,
4970
- "the type of this value must be known in this context" )
4971
- . emit ( ) ;
4972
- }
4973
- self . demand_suptype ( sp, self . tcx . types . err , ty) ;
4974
- ty = self . tcx . types . err ;
4975
- } else {
4976
- self . demand_suptype ( sp, alternative, ty) ;
4977
- ty = alternative;
4963
+ if !self . is_tainted_by_errors ( ) {
4964
+ type_error_struct ! ( self . tcx. sess, sp, ty, E0619 ,
4965
+ "the type of this value must be known in this context" )
4966
+ . emit ( ) ;
4978
4967
}
4968
+ self . demand_suptype ( sp, self . tcx . types . err , ty) ;
4969
+ ty = self . tcx . types . err ;
4979
4970
}
4980
-
4981
4971
ty
4982
4972
}
4983
4973
4984
- // Resolves `typ` by a single level if `typ` is a type variable. If no
4985
- // resolution is possible, then an error is reported.
4986
- pub fn structurally_resolved_type ( & self , sp : Span , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
4987
- self . structurally_resolve_type_or_else ( sp, ty, || {
4988
- self . tcx . types . err
4989
- } )
4990
- }
4991
-
4992
4974
fn with_breakable_ctxt < F : FnOnce ( ) -> R , R > ( & self , id : ast:: NodeId ,
4993
4975
ctxt : BreakableCtxt < ' gcx , ' tcx > , f : F )
4994
4976
-> ( BreakableCtxt < ' gcx , ' tcx > , R ) {
0 commit comments