Skip to content

Conversation

@estebank
Copy link
Contributor

@estebank estebank commented Dec 31, 2025

error[E0277]: `?` couldn't convert the error to `dependency::Error`
  --> replaced
   |
LL | fn main() -> Result<(), Error> {
   |              ----------------- expected `dependency::Error` because of this
...
LL |     Err(Error2)?;
   |     -----------^ the trait `From<Error2>` is not implemented for `dependency::Error`
   |     |
   |     this can't be annotated with `?` because it has type `Result<_, Error2>`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
help: the trait `From<Error2>` is not implemented for `dependency::Error`
      but trait `From<()>` is implemented for it
  --> replaced
   |
LL | impl From<()> for Error {
   | ^^^^^^^^^^^^^^^^^^^^^^^
   = help: for that trait implementation, expected `()`, found `Error2`
   = note: there are multiple different versions of crate `dependency` in the dependency graph
   = help: you can use `cargo tree` to explore your dependency tree

The existing checks rely on having access to the actual types/traits that diverged to detect they are called the same, come from different crates with the same name. The new check is less specific, merely looking to see if the crate name the involved type belongs has multiple crates.

CC #78552.

… a different crate version than expected

```
error[E0277]: `?` couldn't convert the error to `dependency::Error`
  --> replaced
   |
LL | fn main() -> Result<(), Error> {
   |              ----------------- expected `dependency::Error` because of this
...
LL |     Err(Error2)?;
   |     -----------^ the trait `From<Error2>` is not implemented for `dependency::Error`
   |     |
   |     this can't be annotated with `?` because it has type `Result<_, Error2>`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
help: the trait `From<Error2>` is not implemented for `dependency::Error`
      but trait `From<()>` is implemented for it
  --> replaced
   |
LL | impl From<()> for Error {
   | ^^^^^^^^^^^^^^^^^^^^^^^
   = help: for that trait implementation, expected `()`, found `Error2`
   = note: there are multiple different versions of crate `dependency` in the dependency graph
   = help: you can use `cargo tree` to explore your dependency tree
```

The existing checks rely on having access to the actual types/traits that diverged to detect they are called the same, come from different crates with the same name. The new check is less specific, merely looking to see if the crate name the involved type belongs has multiple crates.
@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 31, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 31, 2025

jieyouxu is not on the review rotation at the moment.
They may take a while to respond.

@rustbot
Copy link
Collaborator

rustbot commented Dec 31, 2025

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@isosphere

This comment was marked as resolved.

@estebank
Copy link
Contributor Author

estebank commented Jan 2, 2026

This is the output I get:

~/workspace/rust-issue-78552-repro/repro-runtime$ cargo +dev build
   Compiling repro-runtime v0.1.0 (/home/gh-estebank/workspace/rust-issue-78552-repro/repro-runtime)
error[E0277]: `?` couldn't convert the error to `Status`
   --> repro-runtime/src/main.rs:5:78
    |
  4 | fn main() -> Result<(), Status> {
    |              ------------------ expected `Status` because of this
  5 |     Err(ApplicationError::ImpossibleCondition("you tried to run it!".into()))?
    |     -------------------------------------------------------------------------^ the trait `From<ApplicationError>` is not implemented for `Status`
    |     |
    |     this can't be annotated with `?` because it has type `Result<_, ApplicationError>`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
help: the following other types implement trait `From<T>`
   --> /home/gh-estebank/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tonic-0.14.2/src/status.rs:709:1
    |
709 | impl From<h2::Error> for Status {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Status` implements `From<h2::error::Error>`
...
722 | impl From<std::io::Error> for Status {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Status` implements `From<std::io::Error>`
    = note: there are multiple different versions of crate `tonic` in the dependency graph
    = help: you can use `cargo tree` to explore your dependency tree

For more information about this error, try `rustc --explain E0277`.
error: could not compile `repro-runtime` (bin "repro-runtime") due to 1 previous error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants