iomentum / cargo-breaking

Mozilla Public License 2.0
112 stars 7 forks source link

Adding a private field to a struct containing only public fields is a breaking change #43

Open zdimension opened 2 years ago

zdimension commented 2 years ago

Currently, only public fields are fetched using Rustdoc, but adding a private field can be a breaking change:

pub struct Foo(pub bar: u8, pub baz: u8);
// ↓
pub struct Foo(pub bar: u8, pub baz: u8, boo: u8);

will break structure literals:

let x = the_crate::Foo { bar: 12, baz: 34 }; // breaks!

Note that this is breaking only if the struct does not already contain a private field, because in that case no existing code can rely on constructs such as struct literals.

See RFC 1105 for more information on breaking changes in types.