@@ -1875,24 +1875,28 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1875
1875
self . tcx . erase_late_bound_regions ( value)
1876
1876
}
1877
1877
1878
+ /// Determine if the given associated item type is relevant in the current context.
1879
+ fn is_relevant_kind_for_mode ( & self , kind : ty:: AssocKind ) -> bool {
1880
+ match ( self . mode , kind) {
1881
+ ( Mode :: MethodCall , ty:: AssocKind :: Fn ) => true ,
1882
+ ( Mode :: Path , ty:: AssocKind :: Const | ty:: AssocKind :: Fn ) => true ,
1883
+ _ => false ,
1884
+ }
1885
+ }
1886
+
1878
1887
/// Finds the method with the appropriate name (or return type, as the case may be). If
1879
1888
/// `allow_similar_names` is set, find methods with close-matching names.
1880
1889
// The length of the returned iterator is nearly always 0 or 1 and this
1881
1890
// method is fairly hot.
1882
1891
fn impl_or_trait_item ( & self , def_id : DefId ) -> SmallVec < [ ty:: AssocItem ; 1 ] > {
1883
- let relevant_kind_for_mode = |kind| match ( self . mode , kind) {
1884
- ( Mode :: MethodCall , ty:: AssocKind :: Fn ) => true ,
1885
- ( Mode :: Path , ty:: AssocKind :: Const | ty:: AssocKind :: Fn ) => true ,
1886
- _ => false ,
1887
- } ;
1888
1892
if let Some ( name) = self . method_name {
1889
1893
if self . allow_similar_names {
1890
1894
let max_dist = max ( name. as_str ( ) . len ( ) , 3 ) / 3 ;
1891
1895
self . tcx
1892
1896
. associated_items ( def_id)
1893
1897
. in_definition_order ( )
1894
1898
. filter ( |x| {
1895
- if !relevant_kind_for_mode ( x. kind ) {
1899
+ if !self . is_relevant_kind_for_mode ( x. kind ) {
1896
1900
return false ;
1897
1901
}
1898
1902
match lev_distance_with_substrings ( name. as_str ( ) , x. name . as_str ( ) , max_dist)
@@ -1906,14 +1910,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1906
1910
} else {
1907
1911
self . fcx
1908
1912
. associated_value ( def_id, name)
1909
- . filter ( |x| relevant_kind_for_mode ( x. kind ) )
1913
+ . filter ( |x| self . is_relevant_kind_for_mode ( x. kind ) )
1910
1914
. map_or_else ( SmallVec :: new, |x| SmallVec :: from_buf ( [ x] ) )
1911
1915
}
1912
1916
} else {
1913
1917
self . tcx
1914
1918
. associated_items ( def_id)
1915
1919
. in_definition_order ( )
1916
- . filter ( |x| relevant_kind_for_mode ( x. kind ) )
1920
+ . filter ( |x| self . is_relevant_kind_for_mode ( x. kind ) )
1917
1921
. copied ( )
1918
1922
. collect ( )
1919
1923
}
0 commit comments