rust/compiler/rustc_trait_selection/src
许杰友 Jieyou Xu (Joe) 70e71f570d
Rollup merge of #133585 - estebank:issue-133563, r=jieyouxu
Do not call `extern_crate` on current trait on crate mismatch errors

When we encounter an error caused by traits/types of different versions of the same crate, filter out the current crate when collecting spans to add to the context so we don't call `extern_crate` on the `DefId` of the current crate, which is meaningless and ICEs.

Produced output with this filter:

```
error[E0277]: the trait bound `foo::Struct: Trait` is not satisfied
  --> y.rs:13:19
   |
13 |     check_trait::<foo::Struct>();
   |                   ^^^^^^^^^^^ the trait `Trait` is not implemented for `foo::Struct`
   |
note: there are multiple different versions of crate `foo` in the dependency graph
  --> y.rs:7:1
   |
4  | extern crate foo;
   | ----------------- one version of crate `foo` is used here, as a direct dependency of the current crate
5  |
6  | pub struct Struct;
   | ----------------- this type implements the required trait
7  | pub trait Trait {}
   | ^^^^^^^^^^^^^^^ this is the required trait
   |
  ::: x.rs:4:1
   |
4  | pub struct Struct;
   | ----------------- this type doesn't implement the required trait
5  | pub trait Trait {}
   | --------------- 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
note: required by a bound in `check_trait`
  --> y.rs:10:19
   |
10 | fn check_trait<T: Trait>() {}
   |                   ^^^^^ required by this bound in `check_trait`
```

Fix #133563.
2024-11-30 12:56:52 +08:00
..
error_reporting Rollup merge of #133585 - estebank:issue-133563, r=jieyouxu 2024-11-30 12:56:52 +08:00
errors ty::BrK -> ty::BoundRegionKind::K 2024-11-04 04:45:52 +00:00
solve support revealing defined opaque post borrowck 2024-11-28 10:40:58 +01:00
traits support revealing defined opaque post borrowck 2024-11-28 10:40:58 +01:00
errors.rs Make precise capturing suggestion machine-applicable only if it has not APITs 2024-11-12 04:08:34 +00:00
infer.rs move fn is_item_raw to TypingEnv 2024-11-19 18:06:20 +01:00
lib.rs Stabilize the map/value methods on ControlFlow 2024-09-25 19:00:17 -07:00
regions.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
solve.rs impossible obligations check fast path 2024-10-10 06:09:50 -04:00