Skip to content

Untruthful "there are multiple different versions of crate" #148892

@dtolnay

Description

@dtolnay

Code

// [dependencies]
// quote = "1"

use quote::quote;
use std::net::Ipv4Addr;

fn main() {
    let ip = Ipv4Addr::LOCALHOST;
    let _ = quote! { #ip };
}

Current output

error[E0277]: the trait bound `Ipv4Addr: ToTokens` is not satisfied
  --> src/main.rs:9:13
   |
 9 |     let _ = quote! { #ip };
   |             ^^^^^^^^^^^^^^
   |             |
   |             the trait `ToTokens` is not implemented for `Ipv4Addr`
   |             required by a bound introduced by this call
   |
note: there are multiple different versions of crate `quote` in the dependency graph
  --> /home/david/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/quote-1.0.42/src/to_tokens.rs:9:1
   |
 9 | pub trait ToTokens {
   | ^^^^^^^^^^^^^^^^^^ this is the expected trait
   |
  ::: /home/david/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/to_tokens.rs:11:1
   |
11 | pub trait ToTokens {
   | ------------------ this is the trait that was imported
   = help: you can use `cargo tree` to explore your dependency tree
   = help: the following other types implement trait `ToTokens`:
             &T
             &mut T
             Box<T>
             CStr
             CString
             Cow<'a, T>
             Option<T>
             Rc<T>
           and 24 others
   = note: this error originates in the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info)

Rationale and extra context

Rustc says "there are multiple different versions of crate quote in the dependency graph" and points to a ToTokens trait from version 1.0.42 of crate quote. As far as I understand, there is no other version of quote in the dependency graph. The diagnostic goes on to point to a different trait in crate proc_macro, but proc_macro is not a version of quote.

This diagnostic is new in nightly-2025-11-13 and is from #144674.

Rust Version

rustc 1.93.0-nightly (01867557c 2025-11-12)
binary: rustc
commit-hash: 01867557cd7dbe256a031a7b8e28d05daecd75ab
commit-date: 2025-11-12
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions