# What is backwards compatibility?

**URL:** <https://internals.rust-lang.org/t/what-is-backwards-compatibility/1780>\
**Category:** guidelines\
**Created:** [March 31, 2015, 1:59am UTC](https://internals.rust-lang.org/t/what-is-backwards-compatibility/1780 "2015-03-31T01:59:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![theemathas](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/theemathas/32/11817_2.png) [@theemathas](https://internals.rust-lang.org/u/theemathas)\
**Post date:** [March 31, 2015, 1:59am UTC](https://internals.rust-lang.org/t/what-is-backwards-compatibility/1780/1 "2015-03-31T01:59:16Z")

</div>

In some cases, it is easy to see that a change is backwards compatible. However, many changes that _seem_ backwards compatible _are not_.

On the other hand, some kinds of changes rarely break code. We have to decide whether these are considered to be “practically backwards-compatible”.

Here are some edge cases:

- Adding `pub` items to a `pub mod`

- Causes name clashes due to glob imports

- Adding `pub fn` inherent methods to a `pub` type

- Causes name clashes with `trait` methods.

- Adding object-safe provided methods to `pub trait`s

- Causes name clashes with inherent methods due to autoderef / autoref

- Adding `#[must_use]` to a type or a `fn`

- Breaks code with `#![deny(unused_must_use)]`

- Implementing `Drop` for a type

- Breaks `unsafe` code that assumes no `Drop` impl’s

- Adding private fields

- Breaks some `unsafe` code, e.g. `transmute()` and `Vec::map_in_place()`.

- Changes the result of `size_of()`.

---

<div class="post-metadata">

**Author:** ![Gankra](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/gankra/32/6002_2.png) [@Gankra](https://internals.rust-lang.org/u/Gankra)\
**Post date:** [March 31, 2015, 2:21am UTC](https://internals.rust-lang.org/t/what-is-backwards-compatibility/1780/2 "2015-03-31T02:21:55Z")

</div>

In general adding any public anything is a breaking change when you factor in `glob` imports. e.g. adding a new module can cause a naming conflict. Adding a trait can add new methods creating ambiguity or just create a conflict with a different type in scope. Making functionality more generic can break inference.

If we add negative bounds then implementing a trait can _unimplement_ another. Rust’s design is basically a back-compat nightmare if you’re strict about the definition of back-compat. The core team has been working on a definition that includes “acceptable breakage” like having to use UFCS to disambiguate. Basically I think the spirit is that a change isn’t really breaking if it doesn’t require you to change the spirit or design of your code. (so removing a function or making a function no longer take a concrete type is breaking, but needing to fiddle with imports/UFCS isn’t).

@aturon would know better than me, though.

---

<div class="post-metadata">

**Author:** ![theemathas](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/theemathas/32/11817_2.png) [@theemathas](https://internals.rust-lang.org/u/theemathas)\
**Post date:** [March 31, 2015, 2:29am UTC](https://internals.rust-lang.org/t/what-is-backwards-compatibility/1780/3 "2015-03-31T02:29:36Z")

</div>

@Gankro Note that even adding a public _method_ to an existing type can _silently_ break code, even without glob imports.

---

<div class="post-metadata">

**Author:** ![theemathas](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/theemathas/32/11817_2.png) [@theemathas](https://internals.rust-lang.org/u/theemathas)\
**Post date:** [March 31, 2015, 3:32am UTC](https://internals.rust-lang.org/t/what-is-backwards-compatibility/1780/4 "2015-03-31T03:32:21Z")

</div>

@aturon gave me this link in IRC: [https://github.com/rust-lang/meeting-minutes/blob/master/workweek-2014-08-18/api-evolution.md](https://github.com/rust-lang/meeting-minutes/blob/master/workweek-2014-08-18/api-evolution.md)

---

<div class="post-metadata">

**Author:** ![oli-obk](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/oli-obk/32/3168_2.png) [@oli-obk](https://internals.rust-lang.org/u/oli-obk)\
**Post date:** [March 31, 2015, 2:03pm UTC](https://internals.rust-lang.org/t/what-is-backwards-compatibility/1780/5 "2015-03-31T14:03:33Z")

</div>

> [@theemathas](#):
>
> - Adding #[must\_use] to a type or a fn
> - Breaks code with #![deny(unused\_must\_use)]

If you are adding `#[must_use]`, you are probably fixing a bug and the user of your type/function was using a bug. There should be no backwards-compatibility guarantee for bugs in my opinion.

---

<div class="post-metadata">

**Author:** ![SimonSapin](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/simonsapin/32/3158_2.png) [@SimonSapin](https://internals.rust-lang.org/u/SimonSapin)\
**Post date:** [April 1, 2015, 9:36am UTC](https://internals.rust-lang.org/t/what-is-backwards-compatibility/1780/6 "2015-04-01T09:36:47Z")

</div>

> [@ker](#):
>
> There's no backwards-compatibility guarantee for bugs.

Isn’t there? “Bugward-compatibility” is very real, in some systems. It’s fine to decide not to do it for the Rust language and standard library, but it should be an explicit, documented decision.

---

<div class="post-metadata">

**Author:** ![oli-obk](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/oli-obk/32/3168_2.png) [@oli-obk](https://internals.rust-lang.org/u/oli-obk)\
**Post date:** [April 1, 2015, 10:20am UTC](https://internals.rust-lang.org/t/what-is-backwards-compatibility/1780/7 "2015-04-01T10:20:33Z")

</div>

yea, sorry. I’ve been expressing an opinion as a fact again 😕 edited the post.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:24am UTC](https://internals.rust-lang.org/t/what-is-backwards-compatibility/1780/8 "2019-03-25T08:24:08Z")

</div>

Closed on March 25, 2019, 8:24am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
