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

Update E0033 to the new error format #35526

Merged
merged 3 commits into from
Aug 23, 2016
Merged
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
8 changes: 5 additions & 3 deletions src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if let ty::TyTrait(..) = mt.ty.sty {
// This is "x = SomeTrait" being reduced from
// "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
span_err!(self.tcx.sess, span, E0033,
"type `{}` cannot be dereferenced",
self.ty_to_string(expected));
let type_str = self.ty_to_string(expected);
struct_span_err!(self.tcx.sess, span, E0033,
"type `{}` cannot be dereferenced", type_str)
.span_label(span, &format!("type `{}` cannot be dereferenced", type_str))
.emit();
return false
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/test/compile-fail/E0033.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ trait SomeTrait {
}

fn main() {
let trait_obj: &SomeTrait = SomeTrait; //~ ERROR E0425
//~^ ERROR E0038
let &invalid = trait_obj; //~ ERROR E0033
let trait_obj: &SomeTrait = SomeTrait;
//~^ ERROR E0425
//~| ERROR E0038
//~| method `foo` has no receiver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually work? I didn't think it worked without ERROR or NOTE.

//~| NOTE the trait `SomeTrait` cannot be made into an object

let &invalid = trait_obj;
//~^ ERROR E0033
//~| NOTE type `&SomeTrait` cannot be dereferenced
}