iomentum / cargo-breaking

Mozilla Public License 2.0
112 stars 7 forks source link

Use rustc internal API #19

Open scrabsha opened 3 years ago

scrabsha commented 3 years ago

Using rustc internal API makes a lot of things easier, as it provides features such as type resolution, world-class macro expansion, and so on.

I wrote a very simple proof-of-concept which shows that it is possible to extract the public API from a crate here.

IMO cargo-breaking would benefit from it since we wouldn't have to reimplement some parts of the compiler ourselves. For instance, the current path resolution algorithm works only on very simple situations, does not handle glob imports, dependencies, and so on. If we switch to rustc API, this kind of problem vanishes. We could reinvest the time we currently spend trying to understand and mimic the compiler internal algorithm in actually valuable development.

However, this approach comes with some drawbacks:

Development will happen on the rustc-backend branch.