-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cargo check panic on nightly #133563
Comments
minimal repro: a.rs: #![crate_type = "lib"]
#![crate_name = "foo"]
pub struct Struct;
pub trait Trait {}
impl Trait for Struct {} b.rs: #![crate_type = "lib"]
#![crate_name = "foo"]
extern crate foo;
pub struct Struct;
pub trait Trait {}
impl Trait for Struct {}
fn check_trait<T: Trait>() {}
fn ice() {
check_trait::<foo::Struct>();
} run: rustc a.rs
rustc b.rs -L. -Cmetadata=1 ... but I'm still curious how you managed to hit this in the wild, because it requires a crate to somehow depend on another crate with the same name. This line will ICE when passing rust/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs Line 1734 in c1cfab2
@rustbot label S-has-mcve A-diagnostics -needs-triage |
Multiple versions of the same dependency will have the same name, so maybe a newer version depends on an old version? (If simply having multiple versions isn’t enough to reproduce the issue) |
@lqd described as you did it made me realize that that situation is not actually uncommon to the point it has a name: "semver trick". |
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 rust-lang#133563.
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 rust-lang#133563.
Rollup merge of rust-lang#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 rust-lang#133563.
Cargo check on a leptos Rust project on nightly. Unable to provide an example due to time constraints, sorry.
Meta
rustc-ice-2024-11-28T06_34_32-9970.txt
Backtrace
The text was updated successfully, but these errors were encountered: