Auto merge of #46708 - pnkfelix:fix-issue-46112, r=arielb1
Fix visible_parent_map to choose globally minimal paths
Fix #46112: visible_parent_map construction needs a BFS over whole crate forest to get globally minimal paths.
(There are other latent bugs that were e.g. causing this test case to have weirdness like `<unnamed>` in the diagnostic output. Those bugs are not fixed here, since they are issues long-standing in the stable channel.)