@@ -2044,22 +2044,22 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
20442044 ( exp_found. expected . kind ( ) , exp_found. found . kind ( ) )
20452045 {
20462046 if let ty:: Adt ( found_def, found_substs) = * found_ty. kind ( ) {
2047- let path_str = format ! ( "{:?}" , exp_def) ;
20482047 if exp_def == & found_def {
2049- let opt_msg = "you can convert from `&Option<T>` to `Option<&T>` using \
2050- `.as_ref()`";
2051- let result_msg = "you can convert from `&Result<T, E>` to \
2052- `Result<&T, &E>` using `.as_ref()`";
20532048 let have_as_ref = & [
2054- ( "std::option::Option" , opt_msg) ,
2055- ( "core::option::Option" , opt_msg) ,
2056- ( "std::result::Result" , result_msg) ,
2057- ( "core::result::Result" , result_msg) ,
2049+ (
2050+ sym:: Option ,
2051+ "you can convert from `&Option<T>` to `Option<&T>` using \
2052+ `.as_ref()`",
2053+ ) ,
2054+ (
2055+ sym:: Result ,
2056+ "you can convert from `&Result<T, E>` to \
2057+ `Result<&T, &E>` using `.as_ref()`",
2058+ ) ,
20582059 ] ;
2059- if let Some ( msg) = have_as_ref
2060- . iter ( )
2061- . find_map ( |( path, msg) | ( & path_str == path) . then_some ( msg) )
2062- {
2060+ if let Some ( msg) = have_as_ref. iter ( ) . find_map ( |( name, msg) | {
2061+ self . tcx . is_diagnostic_item ( * name, exp_def. did ( ) ) . then_some ( msg)
2062+ } ) {
20632063 let mut show_suggestion = true ;
20642064 for ( exp_ty, found_ty) in
20652065 iter:: zip ( exp_substs. types ( ) , found_substs. types ( ) )
0 commit comments