Skip to content

Conversation

Zalathar
Copy link
Contributor

@Zalathar Zalathar commented Oct 5, 2025

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

Enselic and others added 8 commits September 22, 2025 07:25
If a user does e.g.

    impl From<Bar> for foo::Foo

and get a compilation error about that `From<Bar>` is not implemented
for `Foo`, check if multiple versions of the crate with `Foo` is present
in the dependency graph. If so, give a hint about it.

I encountered this case in the wild and didn't realize I had multiple
versions of a crate in my dependency graph. So I was a bit confused at
first. This fix will make life easier for others.
…ieyouxu

compiler: Hint at multiple crate versions if trait impl is for wrong ADT

If a user does e.g.

    impl From<Bar> for foo::Foo

and get a compilation error about that `From<Bar>` is not implemented for `Foo`, check if multiple versions of the crate with `Foo` is present in the dependency graph. If so, give a hint about it.

Note that a test is added as a separate commit so it is easy to see what effect the fix has on the emitted error message.

This can be seen as a continuation of rust-lang#124944.

I think this closes RUST-71693 but I haven't checked since it lacks a minimal reproducer. If this gets merged I'll ask that reporter if this fix works for them.

## Real world example

I encountered this case in the wild and didn't realize I had multiple versions of a crate in my dependency graph. So I was a bit confused at first. For reference, here is what that looked like.

<details>
<summary>Click to expand</summary>

### Before fix

```
error[E0277]: the trait bound `lambda_http::lambda_runtime::Diagnostic: From<Error>` is not satisfied
   --> src/main.rs:73:5
    |
73  |     lambda_http::run(service_fn(handle_event)).await
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<Error>` is not implemented for `lambda_http::lambda_runtime::Diagnostic`
    |
    = help: the following other types implement trait `From<T>`:
              `lambda_http::lambda_runtime::Diagnostic` implements `From<&str>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<Box<dyn StdError + Send + Sync>>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<Box<dyn StdError>>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<Infallible>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<lambda_runtime::deserializer::DeserializeError>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<std::io::Error>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<std::string::String>`
    = note: required for `Error` to implement `Into<lambda_http::lambda_runtime::Diagnostic>`
note: required by a bound in `lambda_http::run`
   --> /home/martin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/lambda_http-0.17.0/src/lib.rs:199:26
    |
194 | pub async fn run<'a, R, S, E>(handler: S) -> Result<(), Error>
    |              --- required by a bound in this function
...
199 |     E: std::fmt::Debug + Into<Diagnostic>,
    |                          ^^^^^^^^^^^^^^^^ required by this bound in `run`

error[E0277]: the trait bound `lambda_http::lambda_runtime::Diagnostic: From<Error>` is not satisfied
   --> src/main.rs:73:48
    |
73  |     lambda_http::run(service_fn(handle_event)).await
    |                                                ^^^^^ the trait `From<Error>` is not implemented for `lambda_http::lambda_runtime::Diagnostic`
    |
    = help: the following other types implement trait `From<T>`:
              `lambda_http::lambda_runtime::Diagnostic` implements `From<&str>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<Box<dyn StdError + Send + Sync>>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<Box<dyn StdError>>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<Infallible>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<lambda_runtime::deserializer::DeserializeError>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<std::io::Error>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<std::string::String>`
    = note: required for `Error` to implement `Into<lambda_http::lambda_runtime::Diagnostic>`
note: required by a bound in `lambda_http::run`
   --> /home/martin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/lambda_http-0.17.0/src/lib.rs:199:26
    |
194 | pub async fn run<'a, R, S, E>(handler: S) -> Result<(), Error>
    |              --- required by a bound in this function
...
199 |     E: std::fmt::Debug + Into<Diagnostic>,
    |                          ^^^^^^^^^^^^^^^^ required by this bound in `run`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `auto-merge-dependabot-pull-requests-webhook` (bin "auto-merge-dependabot-pull-requests-webhook") due to 2 previous errors
```

### After fix

```
   Compiling auto-merge-dependabot-pull-requests-webhook v0.1.0 (/home/martin/src/auto-merge-dependabot-prs/rust-webhook)
error[E0277]: the trait bound `lambda_http::lambda_runtime::Diagnostic: From<Error>` is not satisfied
   --> src/main.rs:73:5
    |
 73 |     lambda_http::run(service_fn(handle_event)).await
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<Error>` is not implemented for `lambda_http::lambda_runtime::Diagnostic`
    |
help: item with same name found
   --> /home/martin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/lambda_runtime-0.13.0/src/diagnostic.rs:43:1
    |
 43 | pub struct Diagnostic {
    | ^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `lambda_runtime` are being used?
    = help: the following other types implement trait `From<T>`:
              `lambda_http::lambda_runtime::Diagnostic` implements `From<&str>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<Box<dyn StdError + Send + Sync>>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<Box<dyn StdError>>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<Infallible>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<lambda_runtime::deserializer::DeserializeError>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<std::io::Error>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<std::string::String>`
    = note: required for `Error` to implement `Into<lambda_http::lambda_runtime::Diagnostic>`
note: required by a bound in `lambda_http::run`
   --> /home/martin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/lambda_http-0.17.0/src/lib.rs:199:26
    |
194 | pub async fn run<'a, R, S, E>(handler: S) -> Result<(), Error>
    |              --- required by a bound in this function
...
199 |     E: std::fmt::Debug + Into<Diagnostic>,
    |                          ^^^^^^^^^^^^^^^^ required by this bound in `run`

error[E0277]: the trait bound `lambda_http::lambda_runtime::Diagnostic: From<Error>` is not satisfied
   --> src/main.rs:73:48
    |
 73 |     lambda_http::run(service_fn(handle_event)).await
    |                                                ^^^^^ the trait `From<Error>` is not implemented for `lambda_http::lambda_runtime::Diagnostic`
    |
help: item with same name found
   --> /home/martin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/lambda_runtime-0.13.0/src/diagnostic.rs:43:1
    |
 43 | pub struct Diagnostic {
    | ^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `lambda_runtime` are being used?
    = help: the following other types implement trait `From<T>`:
              `lambda_http::lambda_runtime::Diagnostic` implements `From<&str>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<Box<dyn StdError + Send + Sync>>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<Box<dyn StdError>>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<Infallible>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<lambda_runtime::deserializer::DeserializeError>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<std::io::Error>`
              `lambda_http::lambda_runtime::Diagnostic` implements `From<std::string::String>`
    = note: required for `Error` to implement `Into<lambda_http::lambda_runtime::Diagnostic>`
note: required by a bound in `lambda_http::run`
   --> /home/martin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/lambda_http-0.17.0/src/lib.rs:199:26
    |
194 | pub async fn run<'a, R, S, E>(handler: S) -> Result<(), Error>
    |              --- required by a bound in this function
...
199 |     E: std::fmt::Debug + Into<Diagnostic>,
    |                          ^^^^^^^^^^^^^^^^ required by this bound in `run`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `auto-merge-dependabot-pull-requests-webhook` (bin "auto-merge-dependabot-pull-requests-webhook") due to 2 previous errors
```

</details>

try-job: dist-various-1
Make #[link="dl"] an FCW rather than an error

Fixes rust-lang#147254
I forgot to implement the T-lang decision in rust-lang#143193 (comment), this implements that decision

r? `@jdonszelmann`
Can be reviewed commit-by-commit
This needs a beta backport
…eyouxu

update autodiff testcases

unblock EnzymeAD/Enzyme#2430 (again).
Just as I landed a fix for the last test, this one broke. The test should now be fine if the name mangling hash changes again.

Also removed an outdated fixme that's not needed since moving autodiff to an intrinsic. The test currently just checks that it compiles, I'll add more precise checks once we actually run this in CI.

r? compiler
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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. rollup A PR which is a rollup labels Oct 5, 2025
@Zalathar
Copy link
Contributor Author

Zalathar commented Oct 5, 2025

@bors r+ rollup=never p=5

@bors
Copy link
Collaborator

bors commented Oct 5, 2025

📌 Commit bae926d has been approved by Zalathar

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 5, 2025
@Zalathar
Copy link
Contributor Author

Zalathar commented Oct 5, 2025

Rollup of everything currently in the queue.

@bors
Copy link
Collaborator

bors commented Oct 5, 2025

⌛ Testing commit bae926d with merge 3d46260...

bors added a commit that referenced this pull request Oct 5, 2025
Rollup of 3 pull requests

Successful merges:

 - #146874 (compiler: Hint at multiple crate versions if trait impl is for wrong ADT )
 - #147262 (Make #[link="dl"] an FCW rather than an error)
 - #147364 (update autodiff testcases)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Collaborator

bors commented Oct 5, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 5, 2025
@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
checking C++ file formatting
spellchecking files
building external tool typos from package typos-cli@1.34.0
finished building tool typos
npm ERR! code EEXIST
npm ERR! syscall open
npm ERR! path /home/user/.npm/_cacache/tmp/50e810a0
npm ERR! errno -17
npm ERR! EEXIST: file already exists, open '/home/user/.npm/_cacache/tmp/50e810a0'
npm ERR! File exists: /home/user/.npm/_cacache/tmp/50e810a0
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in: /home/user/.npm/_logs/2025-10-05T10_41_04_694Z-debug-0.log
npm install did not exit successfully
tidy [extra_checks]: IO error: npm install returned exit code exit status: 239
tidy [extra_checks]: FAIL
tidy: The following check failed: extra_checks
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy /checkout /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo /checkout/obj/build 4 /node/bin/npm --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1549:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1280:29

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:02:35
  local time: Sun Oct  5 10:41:07 UTC 2025
  network time: Sun, 05 Oct 2025 10:41:07 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@Zalathar
Copy link
Contributor Author

Zalathar commented Oct 5, 2025

Looks flaky; closing in favour of a larger rollup.

@Zalathar Zalathar closed this Oct 5, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 5, 2025
@Zalathar Zalathar deleted the rollup-f6ipp2q branch October 5, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-run-make Area: port run-make Makefiles to rmake.rs rollup A PR which is a rollup 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.

7 participants