]> git.lizzy.rs Git - rust.git/commit
Auto merge of #25212 - pnkfelix:dropck-box-trait, r=nikomatsakis
authorbors <bors@rust-lang.org>
Sat, 9 May 2015 09:20:43 +0000 (09:20 +0000)
committerbors <bors@rust-lang.org>
Sat, 9 May 2015 09:20:43 +0000 (09:20 +0000)
commit3906edf41e8faa0610daea954ffbda39841fbc0d
tree2bca2356418aa51281315baa1fff9b7cf5a3c453
parent95400c51c31877ea4699adc051477edccb5cfbca
parent8654dfbc2f4c1a6da7c9b8f9cce3cfa9f4bc46bb
Auto merge of #25212 - pnkfelix:dropck-box-trait, r=nikomatsakis

dropck: must assume `Box<Trait + 'a>` has a destructor of interest.

Fix #25199.

This detail was documented in [RFC 769]; the implementation was just missing.

[breaking-change]

The breakage here falls into both obvious and non-obvious cases.

The obvious case: if you were relying on the unsoundness this exposes (namely being able to reference dead storage from a destructor, by doing it via a boxed trait object bounded by the lifetime of the dead storage), then this change disallows that.

The non-obvious cases: The way dropck works, it causes lifetimes to be extended to longer extents than they covered before. I.e.  lifetimes that are attached as trait-bounds may become longer than they were previously.

* This includes lifetimes that are only *implicitly* attached as trait-bounds (due to [RFC 599]). So you may have code that was e.g. taking a parameter of type `&'a Box<Trait>` (which expands to `&'a Box<Trait+'a>`), that now may need to be assigned type `&'a Box<Trait+'static>` to ensure that `'a` is not inadvertantly inferred to a region that is actually too long.  (See commit ee06263 for an example of this.)

[RFC 769]: https://github.com/rust-lang/rfcs/blob/master/text/0769-sound-generic-drop.md#the-drop-check-rule

[RFC 599]: https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md