Skip to content

Commit 28b2add

Browse files
committed
Remove references to @trait from a compiler error message
1 parent 8801d89 commit 28b2add

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/librustc/middle/typeck/astconv.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,8 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
572572
let path_str = path_to_str(path);
573573
tcx.sess.span_err(
574574
ast_ty.span,
575-
format!("reference to trait `{}` where a type is expected; \
576-
try `@{}`, `~{}`, or `&{}`",
577-
path_str, path_str, path_str, path_str));
575+
format!("reference to trait `{name}` where a type is expected; \
576+
try `~{name}` or `&{name}`", name=path_str));
578577
ty::mk_err()
579578
}
580579
ast::DefTy(did) | ast::DefStruct(did) => {

src/test/compile-fail/issue-5883.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
trait A {}
1212

1313
struct Struct {
14-
r: A //~ ERROR reference to trait `A` where a type is expected
14+
r: A //~ ERROR reference to trait `A` where a type is expected; try `~A` or `&A`
1515
}
1616

17-
fn new_struct(r: A) -> Struct { //~ ERROR reference to trait `A` where a type is expected
17+
fn new_struct(r: A) -> Struct {
18+
//~^ ERROR reference to trait `A` where a type is expected; try `~A` or `&A`
1819
Struct { r: r }
1920
}
2021

2122
trait Curve {}
22-
enum E {X(Curve)} //~ ERROR reference to trait `Curve` where a type is expected
23+
enum E {X(Curve)}
24+
//~^ ERROR reference to trait `Curve` where a type is expected; try `~Curve` or `&Curve`
2325
fn main() {}

src/test/compile-fail/regions-trait-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn make_gc() -> @get_ctxt {
2929
let ctxt = ctxt { v: 22u };
3030
let hc = has_ctxt { c: &ctxt };
3131
return @hc as @get_ctxt;
32-
//^~ ERROR source contains reference
32+
//~^ ERROR source contains reference
3333
}
3434

3535
fn main() {

src/test/compile-fail/trait-bounds-not-on-bare-trait.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ trait Foo {
1313

1414
// This should emit the less confusing error, not the more confusing one.
1515

16-
fn foo(_x: Foo:Send) { //~ERROR reference to trait `Foo` where a type is expected
16+
fn foo(_x: Foo:Send) {
17+
//~^ERROR reference to trait `Foo` where a type is expected; try `~Foo` or `&Foo`
1718
}
1819

1920
fn main() { }

0 commit comments

Comments
 (0)