@@ -304,24 +304,23 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
304304 p. print_def_path ( def_id, & [ ] ) . map ( |_| p. segments )
305305 } ;
306306
307- // We compare strings because DefPath can be different
308- // for imported and non-imported crates
307+ // We compare strings because DefPath can be different for imported and
308+ // non-imported crates.
309309 let expected_str = self . tcx . def_path_str ( did1) ;
310310 let found_str = self . tcx . def_path_str ( did2) ;
311311 let Ok ( expected_abs) = abs_path ( did1) else { return false } ;
312312 let Ok ( found_abs) = abs_path ( did2) else { return false } ;
313- let same_path = || -> Result < _ , PrintError > {
314- Ok ( expected_str == found_str || expected_abs == found_abs)
315- } ;
316- // We want to use as unique a type path as possible. If both types are "locally
317- // known" by the same name, we use the "absolute path" which uses the original
318- // crate name instead.
319- let ( expected, found) = if expected_str == found_str {
320- ( join_path_syms ( & expected_abs) , join_path_syms ( & found_abs) )
321- } else {
322- ( expected_str. clone ( ) , found_str. clone ( ) )
323- } ;
324- if same_path ( ) . unwrap_or ( false ) {
313+ let same_path = expected_str == found_str || expected_abs == found_abs;
314+ if same_path {
315+ // We want to use as unique a type path as possible. If both types are "locally
316+ // known" by the same name, we use the "absolute path" which uses the original
317+ // crate name instead.
318+ let ( expected, found) = if expected_str == found_str {
319+ ( join_path_syms ( & expected_abs) , join_path_syms ( & found_abs) )
320+ } else {
321+ ( expected_str. clone ( ) , found_str. clone ( ) )
322+ } ;
323+
325324 // We've displayed "expected `a::b`, found `a::b`". We add context to
326325 // differentiate the different cases where that might happen.
327326 let expected_crate_name = self . tcx . crate_name ( did1. krate ) ;
0 commit comments