diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index e3591af6440f7..e9a95a4a9eb40 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -653,7 +653,7 @@ pub fn ast_ty_to_ty( 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) => { diff --git a/src/test/compile-fail/issue-5883.rs b/src/test/compile-fail/issue-5883.rs index 5a7eb75d90d4c..831e165ad0ef5 100644 --- a/src/test/compile-fail/issue-5883.rs +++ b/src/test/compile-fail/issue-5883.rs @@ -11,15 +11,15 @@ 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` 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` 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` or `&Curve` fn main() {} diff --git a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs index 50e55ad295ecb..435c90c78305b 100644 --- a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs +++ b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs @@ -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` or `&Foo` } fn main() { }