]> git.lizzy.rs Git - rust.git/commitdiff
Advice to use Box<T> not ~T
authorJeong YunWon <jeong@youknowone.org>
Sun, 18 May 2014 06:30:41 +0000 (15:30 +0900)
committerJeong YunWon <jeong@youknowone.org>
Sun, 18 May 2014 06:30:41 +0000 (15:30 +0900)
src/librustc/middle/typeck/astconv.rs
src/test/compile-fail/issue-5883.rs
src/test/compile-fail/trait-bounds-not-on-bare-trait.rs

index e3591af6440f7c275745601106e9de3f1b23d9cb..e9a95a4a9eb408b81c2ab186d07105b2bb072be6 100644 (file)
@@ -653,7 +653,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
                         tcx.sess.span_err(
                             ast_ty.span,
                             format!("reference to trait `{name}` where a type is expected; \
-                                    try `~{name}` or `&{name}`", name=path_str));
+                                    try `Box<{name}>` or `&{name}`", name=path_str));
                         ty::mk_err()
                     }
                     ast::DefTy(did) | ast::DefStruct(did) => {
index 5a7eb75d90d4ca926a8fa8bebb0213d016ff20d9..831e165ad0ef57b111ca8a0fa8e6d3fa47e0bf2d 100644 (file)
 trait A {}
 
 struct Struct {
-    r: A //~ ERROR reference to trait `A` where a type is expected; try `~A` or `&A`
+    r: A //~ ERROR reference to trait `A` where a type is expected; try `Box<A>` or `&A`
 }
 
 fn new_struct(r: A) -> Struct {
-    //~^ ERROR reference to trait `A` where a type is expected; try `~A` or `&A`
+    //~^ ERROR reference to trait `A` where a type is expected; try `Box<A>` or `&A`
     Struct { r: r }
 }
 
 trait Curve {}
 enum E {X(Curve)}
-//~^ ERROR reference to trait `Curve` where a type is expected; try `~Curve` or `&Curve`
+//~^ ERROR reference to trait `Curve` where a type is expected; try `Box<Curve>` or `&Curve`
 fn main() {}
index 50e55ad295ecbd48ccf59edf99e460b39ba16238..435c90c78305ba28c823f49c4566029732883af1 100644 (file)
@@ -14,7 +14,7 @@ trait Foo {
 // This should emit the less confusing error, not the more confusing one.
 
 fn foo(_x: Foo:Send) {
-    //~^ERROR reference to trait `Foo` where a type is expected; try `~Foo` or `&Foo`
+    //~^ERROR reference to trait `Foo` where a type is expected; try `Box<Foo>` or `&Foo`
 }
 
 fn main() { }