From 05e3248a7974f55b64f75a2483b37ff8c001a4ff Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 25 Jun 2014 18:18:13 -0700 Subject: librustc: Match trait self types exactly. This can break code that looked like: impl Foo for Box { fn f(&self) { ... } } let x: Box = ...; x.f(); Change such code to: impl Foo for Box { fn f(&self) { ... } } let x: Box = ...; 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` is no longer showable, and only `Box` 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] --- src/libsyntax/diagnostic.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 16c463f0c96..90569bfc132 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -18,6 +18,7 @@ use std::fmt; use std::io; use std::iter::range; use std::string::String; +use term::WriterWrapper; use term; // maximum number of lines we will print for each error; arbitrary. @@ -281,7 +282,7 @@ pub struct EmitterWriter { } enum Destination { - Terminal(Box> + Send>), + Terminal(Box + Send>), Raw(Box), } -- cgit 1.4.1-3-g733a5