@@ -271,11 +271,35 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
271271 let mut candidates = all_traits ( self . tcx ) . into_iter ( ) . filter_map ( |info| {
272272 self . associated_item ( info. def_id , item_name, Namespace :: ValueNS )
273273 } ) ;
274- if let ( true , false , SelfSource :: MethodCall ( expr) , Some ( _) ) = (
274+ // There are methods that are defined on the primitive types and won't be
275+ // found when exploring `all_traits`, but we also need them to be acurate on
276+ // our suggestions (#47759).
277+ let fund_assoc = |opt_def_id : Option < DefId > | {
278+ opt_def_id
279+ . and_then ( |id| self . associated_item ( id, item_name, Namespace :: ValueNS ) )
280+ . is_some ( )
281+ } ;
282+ let lang_items = tcx. lang_items ( ) ;
283+ let found_candidate = candidates. next ( ) . is_some ( )
284+ || fund_assoc ( lang_items. i8_impl ( ) )
285+ || fund_assoc ( lang_items. i16_impl ( ) )
286+ || fund_assoc ( lang_items. i32_impl ( ) )
287+ || fund_assoc ( lang_items. i64_impl ( ) )
288+ || fund_assoc ( lang_items. i128_impl ( ) )
289+ || fund_assoc ( lang_items. u8_impl ( ) )
290+ || fund_assoc ( lang_items. u16_impl ( ) )
291+ || fund_assoc ( lang_items. u32_impl ( ) )
292+ || fund_assoc ( lang_items. u64_impl ( ) )
293+ || fund_assoc ( lang_items. u128_impl ( ) )
294+ || fund_assoc ( lang_items. f32_impl ( ) )
295+ || fund_assoc ( lang_items. f32_runtime_impl ( ) )
296+ || fund_assoc ( lang_items. f64_impl ( ) )
297+ || fund_assoc ( lang_items. f64_runtime_impl ( ) ) ;
298+ if let ( true , false , SelfSource :: MethodCall ( expr) , true ) = (
275299 actual. is_numeric ( ) ,
276300 actual. has_concrete_skeleton ( ) ,
277301 source,
278- candidates . next ( ) ,
302+ found_candidate ,
279303 ) {
280304 let mut err = struct_span_err ! (
281305 tcx. sess,
0 commit comments