iomentum / cargo-breaking

Mozilla Public License 2.0
112 stars 7 forks source link

Properly handle user-defined type #38

Open scrabsha opened 3 years ago

scrabsha commented 3 years ago

Let's consider the following code:

/// previous:
{
    pub struct S;
    pub fn f(_: S) {}
}
/// next:
{
    pub struct S;
    pub fn f(_: S) {}
}

Nothing has changed, but cargo-breaking detects a modification of function f.

This is caused by the fact that we compile the two versions as a dependency of a third one. As such, these two S declaration are handled as two different types, hence interpreted as a modification.

A simple workaround would be to create a bew method to the TyCtxt (perhaps by adding a trait), allowing it to better compare two types, we would call this method instead of checking for changes using ty_a == ty_b.