rust/compiler
bors 5b20c45999 Auto merge of #128849 - estebank:issue-89143, r=jackh726
Tweak detection of multiple crate versions to be more encompassing

Previously, we only emitted the additional context if the type was in the same crate as the trait that appeared multiple times in the dependency tree. Now, we look at all traits looking for two with the same name in different crates with the same crate number, and we are more flexible looking for the types involved. This will work even if the type that implements the wrong trait version is from a different crate entirely.

```
error[E0277]: the trait bound `CustomErrorHandler: ErrorHandler` is not satisfied because the trait comes from a different crate version
 --> src/main.rs:5:17
  |
5 |     cnb_runtime(CustomErrorHandler {});
  |                 ^^^^^^^^^^^^^^^^^^^^^ the trait `ErrorHandler` is not implemented for `CustomErrorHandler`
  |
note: there are multiple different versions of crate `c` in the dependency graph
 --> /home/gh-estebank/testcase-rustc-crate-version-mismatch/c-v0.2/src/lib.rs:1:1
  |
1 | pub trait ErrorHandler {}
  | ^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
  |
 ::: src/main.rs:1:5
  |
1 | use b::CustomErrorHandler;
  |     - one version of crate `c` is used here, as a dependency of crate `b`
2 | use c::cnb_runtime;
  |     - one version of crate `c` is used here, as a direct dependency of the current crate
  |
 ::: /home/gh-estebank/testcase-rustc-crate-version-mismatch/b/src/lib.rs:1:1
  |
1 | pub struct CustomErrorHandler {}
  | ----------------------------- this type doesn't implement the required trait
  |
 ::: /home/gh-estebank/testcase-rustc-crate-version-mismatch/c-v0.1/src/lib.rs:1:1
  |
1 | pub trait ErrorHandler {}
  | ---------------------- this is the found trait
  = note: two types coming from two different versions of the same crate are different types even if they look the same
  = help: you can use `cargo tree` to explore your dependency tree
```

Fix #89143.
2024-11-08 00:34:48 +00:00
..
rustc Remove unused intercrate dependencies 2024-11-07 14:17:16 +00:00
rustc_abi
rustc_arena
rustc_ast Add documentation on ast::Attribute 2024-11-05 16:38:15 +01:00
rustc_ast_ir
rustc_ast_lowering Remove unused intercrate dependencies 2024-11-07 14:17:16 +00:00
rustc_ast_passes Rename the FIXMEs, remove a few that dont matter anymore 2024-11-03 18:59:41 +00:00
rustc_ast_pretty
rustc_attr remove support for extern-block const intrinsics 2024-11-04 23:27:45 +01:00
rustc_baked_icu_data
rustc_borrowck Auto merge of #132580 - compiler-errors:globs, r=Noratrieb 2024-11-05 08:30:56 +00:00
rustc_builtin_macros
rustc_codegen_cranelift remove 'platform-intrinsic' ABI leftovers 2024-11-07 17:42:49 +01:00
rustc_codegen_gcc Basic inline assembly support for SPARC and SPARC64 2024-11-07 21:19:03 +09:00
rustc_codegen_llvm Basic inline assembly support for SPARC and SPARC64 2024-11-07 21:19:03 +09:00
rustc_codegen_ssa Remove unused intercrate dependencies 2024-11-07 14:17:16 +00:00
rustc_const_eval Rollup merge of #132057 - RalfJung:miri-abi-compat, r=wesleywiser 2024-11-07 13:08:27 +01:00
rustc_data_structures
rustc_driver
rustc_driver_impl make time format parsing compiletime 2024-11-03 15:51:39 +03:00
rustc_error_codes
rustc_error_messages
rustc_errors Rename target triple to target tuple in many places in the compiler 2024-11-02 21:29:59 +01:00
rustc_expand
rustc_feature add new rustc_const_stable_intrinsic attribute for const-stable intrinsics 2024-11-04 23:27:46 +01:00
rustc_fluent_macro
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #132423 - RalfJung:const-eval-align-offset, r=dtolnay 2024-11-03 20:08:13 -08:00
rustc_hir_analysis Rollup merge of #132734 - RalfJung:platform-intrinsic, r=compiler-errors 2024-11-07 18:19:38 +01:00
rustc_hir_pretty
rustc_hir_typeck Remove unused intercrate dependencies 2024-11-07 14:17:16 +00:00
rustc_incremental replace manual time convertions with std ones 2024-11-03 15:51:39 +03:00
rustc_index
rustc_index_macros
rustc_infer Remove unused intercrate dependencies 2024-11-07 14:17:16 +00:00
rustc_interface Rollup merge of #132259 - mrkajetanp:branch-protection-pauth-lr, r=davidtwco 2024-11-05 20:10:49 +01:00
rustc_lexer
rustc_lint Remove unused intercrate dependencies 2024-11-07 14:17:16 +00:00
rustc_lint_defs
rustc_llvm PassWrapper: adapt for new parameter in LLVM 2024-11-05 15:49:37 +11:00
rustc_log
rustc_macros
rustc_metadata ty::KContainer -> ty::AssocItemContainer::K 2024-11-04 04:45:52 +00:00
rustc_middle Rollup merge of #132734 - RalfJung:platform-intrinsic, r=compiler-errors 2024-11-07 18:19:38 +01:00
rustc_mir_build Auto merge of #132580 - compiler-errors:globs, r=Noratrieb 2024-11-05 08:30:56 +00:00
rustc_mir_dataflow compiler: Remove unused rustc_target from Cargo.tomls 2024-11-03 13:38:47 -08:00
rustc_mir_transform compiler: Directly use rustc_abi in mir_transform 2024-11-03 13:38:47 -08:00
rustc_monomorphize compiler: Add rustc_abi to _monomorphize 2024-11-02 20:31:47 -07:00
rustc_next_trait_solver Remove unused intercrate dependencies 2024-11-07 14:17:16 +00:00
rustc_parse Revert "Avoid nested replacement ranges" from #129346. 2024-11-04 15:57:35 +11:00
rustc_parse_format
rustc_passes remove support for extern-block const intrinsics 2024-11-04 23:27:45 +01:00
rustc_pattern_analysis compiler: Remove unused rustc_target from Cargo.tomls 2024-11-03 13:38:47 -08:00
rustc_privacy
rustc_query_impl
rustc_query_system replace manual time convertions with std ones 2024-11-03 15:51:39 +03:00
rustc_resolve Rollup merge of #132567 - estebank:bad-suggestion, r=Nadrieril 2024-11-05 20:10:51 +01:00
rustc_sanitizers compiler: Add rustc_abi to _sanitizers 2024-11-02 20:31:47 -07:00
rustc_serialize
rustc_session Auto merge of #132664 - matthiaskrgr:rollup-i27nr7i, r=matthiaskrgr 2024-11-06 01:21:42 +00:00
rustc_smir ty::BrK -> ty::BoundRegionKind::K 2024-11-04 04:45:52 +00:00
rustc_span Basic inline assembly support for SPARC and SPARC64 2024-11-07 21:19:03 +09:00
rustc_symbol_mangling ty::BrK -> ty::BoundRegionKind::K 2024-11-04 04:45:52 +00:00
rustc_target Auto merge of #132472 - taiki-e:sparc-asm, r=Amanieu 2024-11-07 21:07:06 +00:00
rustc_trait_selection Auto merge of #128849 - estebank:issue-89143, r=jackh726 2024-11-08 00:34:48 +00:00
rustc_traits
rustc_transmute
rustc_ty_utils Make fn_abi_sanity_check a bit stricter 2024-11-07 15:54:40 +00:00
rustc_type_ir Rename the FIXMEs, remove a few that dont matter anymore 2024-11-03 18:59:41 +00:00
rustc_type_ir_macros
stable_mir