1
Fork 0

Advice to use Box<T> not ~T

This commit is contained in:
Jeong YunWon 2014-05-18 15:30:41 +09:00
parent 3da5a5cd18
commit 2ee0ca5132
3 changed files with 5 additions and 5 deletions

View file

@ -653,7 +653,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
tcx.sess.span_err( tcx.sess.span_err(
ast_ty.span, ast_ty.span,
format!("reference to trait `{name}` where a type is expected; \ 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() ty::mk_err()
} }
ast::DefTy(did) | ast::DefStruct(did) => { ast::DefTy(did) | ast::DefStruct(did) => {

View file

@ -11,15 +11,15 @@
trait A {} trait A {}
struct Struct { 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 { 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 } Struct { r: r }
} }
trait Curve {} trait Curve {}
enum E {X(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() {} fn main() {}

View file

@ -14,7 +14,7 @@ trait Foo {
// This should emit the less confusing error, not the more confusing one. // This should emit the less confusing error, not the more confusing one.
fn foo(_x: Foo:Send) { 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() { } fn main() { }