KDAB / cxx-qt

Safe interop between Rust and Qt
https://kdab.github.io/cxx-qt/book/
973 stars 67 forks source link

Reexport CXX if possible to avoid needing dependency #883

Open ahayzen-kdab opened 4 months ago

ahayzen-kdab commented 4 months ago

Can we avoid needing cxx as a dependency and instead use CXX as a dependency of cxx-qt/cxx-qt-build and reexport it? This will ensure that the cxx version is the same etc.

LeonMatthesKDAB commented 4 months ago

Funnily enough, I've tried this literally 2 min. ago.

Alas, it doesn't work :/

The approach I took:

  1. Re-exported cxx from cxx_qt
  2. Add use cxx_qt::cxx; in front of each generated cxx bridge

Now I get the following error:

error[E0433]: failed to resolve: could not find `cxx` in the list of imported crates
  --> examples/qml_minimal/rust/src/cxxqt_object.rs:12:1
   |
12 | #[cxx_qt::bridge]
   | ^^^^^^^^^^^^^^^^^ could not find `cxx` in the list of imported crates
   |
   = note: this error originates in the attribute macro `cxx_qt::bridge` (in Nightly builds, run with -Z macro-backtrace for more info)

Checking this out with cargo expand, the issue seems to be that CXX is generating its own paths in the form of ::cxx::... Which means it's fully-qualifying the path to cxx. And afaik this means it will definitely look for a crate of that name, which must be added as a direct dependency :cry: .

So I think we may have to close this as wontfix :/