diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 82be783616888..2119419e0b1e5 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -572,9 +572,8 @@ pub fn ast_ty_to_ty( let path_str = path_to_str(path); tcx.sess.span_err( ast_ty.span, - format!("reference to trait `{}` where a type is expected; \ - try `@{}`, `~{}`, or `&{}`", - path_str, path_str, path_str, path_str)); + format!("reference to trait `{name}` where a type is expected; \ + try `~{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 621510cea99e4..5a7eb75d90d4c 100644 --- a/src/test/compile-fail/issue-5883.rs +++ b/src/test/compile-fail/issue-5883.rs @@ -11,13 +11,15 @@ trait A {} struct Struct { - r: A //~ ERROR reference to trait `A` where a type is expected + r: A //~ ERROR reference to trait `A` where a type is expected; try `~A` or `&A` } -fn new_struct(r: A) -> Struct { //~ ERROR reference to trait `A` where a type is expected +fn new_struct(r: A) -> Struct { + //~^ ERROR reference to trait `A` where a type is expected; try `~A` or `&A` Struct { r: r } } trait Curve {} -enum E {X(Curve)} //~ ERROR reference to trait `Curve` where a type is expected +enum E {X(Curve)} +//~^ ERROR reference to trait `Curve` where a type is expected; try `~Curve` or `&Curve` fn main() {} diff --git a/src/test/compile-fail/regions-trait-2.rs b/src/test/compile-fail/regions-trait-2.rs index 5b1f6b241d25c..92c1849c15b83 100644 --- a/src/test/compile-fail/regions-trait-2.rs +++ b/src/test/compile-fail/regions-trait-2.rs @@ -29,7 +29,7 @@ fn make_gc() -> @get_ctxt { let ctxt = ctxt { v: 22u }; let hc = has_ctxt { c: &ctxt }; return @hc as @get_ctxt; - //^~ ERROR source contains reference + //~^ ERROR source contains reference } 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 d7c98ec4e9d24..50e55ad295ecb 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 @@ -13,7 +13,8 @@ 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 +fn foo(_x: Foo:Send) { + //~^ERROR reference to trait `Foo` where a type is expected; try `~Foo` or `&Foo` } fn main() { }