@@ -358,7 +358,8 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
358
358
fulfill_cx. register_predicate_obligation ( self , obligation) ;
359
359
if fulfill_cx. select_all_or_error ( self ) . is_empty ( ) {
360
360
return Ok ( (
361
- ty:: ClosureKind :: from_def_id ( self . tcx , trait_def_id)
361
+ self . tcx
362
+ . fn_trait_kind_from_def_id ( trait_def_id)
362
363
. expect ( "expected to map DefId to ClosureKind" ) ,
363
364
ty. rebind ( self . resolve_vars_if_possible ( var) ) ,
364
365
) ) ;
@@ -687,7 +688,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
687
688
}
688
689
ObligationCauseCode :: BindingObligation ( def_id, _)
689
690
| ObligationCauseCode :: ItemObligation ( def_id)
690
- if ty :: ClosureKind :: from_def_id ( tcx, * def_id ) . is_some ( ) =>
691
+ if tcx. is_fn_trait ( * def_id ) =>
691
692
{
692
693
err. code ( rustc_errors:: error_code!( E0059 ) ) ;
693
694
err. set_primary_message ( format ! (
@@ -847,8 +848,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
847
848
) ;
848
849
}
849
850
850
- let is_fn_trait =
851
- ty:: ClosureKind :: from_def_id ( tcx, trait_ref. def_id ( ) ) . is_some ( ) ;
851
+ let is_fn_trait = tcx. is_fn_trait ( trait_ref. def_id ( ) ) ;
852
852
let is_target_feature_fn = if let ty:: FnDef ( def_id, _) =
853
853
* trait_ref. skip_binder ( ) . self_ty ( ) . kind ( )
854
854
{
@@ -878,7 +878,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
878
878
// Note if the `FnMut` or `FnOnce` is less general than the trait we're trying
879
879
// to implement.
880
880
let selected_kind =
881
- ty :: ClosureKind :: from_def_id ( self . tcx , trait_ref. def_id ( ) )
881
+ self . tcx . fn_trait_kind_from_def_id ( trait_ref. def_id ( ) )
882
882
. expect ( "expected to map DefId to ClosureKind" ) ;
883
883
if !implemented_kind. extends ( selected_kind) {
884
884
err. note (
@@ -2154,7 +2154,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
2154
2154
if generics. params . iter ( ) . any ( |p| p. name != kw:: SelfUpper )
2155
2155
&& !snippet. ends_with ( '>' )
2156
2156
&& !generics. has_impl_trait ( )
2157
- && !self . tcx . fn_trait_kind_from_lang_item ( def_id) . is_some ( )
2157
+ && !self . tcx . is_fn_trait ( def_id)
2158
2158
{
2159
2159
// FIXME: To avoid spurious suggestions in functions where type arguments
2160
2160
// where already supplied, we check the snippet to make sure it doesn't
0 commit comments