Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove references to @Trait from a compiler error message #13433

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/librustc/middle/typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,8 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
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) => {
Expand Down
8 changes: 5 additions & 3 deletions src/test/compile-fail/issue-5883.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
2 changes: 1 addition & 1 deletion src/test/compile-fail/regions-trait-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail/trait-bounds-not-on-bare-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }