You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This can break code that looked like:
impl Foo for Box<Any> {
fn f(&self) { ... }
}
let x: Box<Any + Send> = ...;
x.f();
Change such code to:
impl Foo for Box<Any> {
fn f(&self) { ... }
}
let x: Box<Any> = ...;
x.f();
That is, upcast before calling methods.
This is a conservative solution to #5781. A more proper treatment (see
the xfail'd `trait-contravariant-self.rs`) would take variance into
account. This change fixes the soundness hole.
Some library changes had to be made to make this work. In particular,
`Box<Any>` is no longer showable, and only `Box<Any+Send>` is showable.
Eventually, this restriction can be lifted; for now, it does not prove
too onerous, because `Any` is only used for propagating the result of
task failure.
This patch also adds a test for the variance inference work in #12828,
which accidentally landed as part of DST.
Closes#5781.
[breaking-change]
5 commit comments
bors commentedon Jun 28, 2014
saw approval from huonw
at pcwalton@05e3248
bors commentedon Jun 28, 2014
merging pcwalton/rust/variance-in-trait-matching = 05e3248 into auto
bors commentedon Jun 28, 2014
pcwalton/rust/variance-in-trait-matching = 05e3248 merged ok, testing candidate = de337f3
bors commentedon Jun 28, 2014
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/87
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/88
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/88
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/88
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/91
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/92
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/91
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/97
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/92
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/91
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/94
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/92
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/91
bors commentedon Jun 28, 2014
fast-forwarding master to auto = de337f3