Skip to content

Commit

Permalink
Update error message E0120
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Prouillet committed Aug 4, 2016
1 parent 271d048 commit 4492838
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/librustc_typeck/coherence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,24 @@ impl<'a, 'gcx, 'tcx> CoherenceChecker<'a, 'gcx, 'tcx> {
if let Some(impl_node_id) = tcx.map.as_local_node_id(impl_did) {
match tcx.map.find(impl_node_id) {
Some(hir_map::NodeItem(item)) => {
span_err!(tcx.sess, item.span, E0120,
"the Drop trait may only be implemented on structures");
let span = match item.node {
ItemImpl(_, _, _, _, ref ty, _) => {
ty.span
},
_ => item.span
};
struct_span_err!(tcx.sess, span, E0120,
"the Drop trait may only be implemented on structures")
.span_label(span, &format!("implementing Drop requires a struct"))
.emit();
}
_ => {
bug!("didn't find impl in ast map");
}
}
} else {
bug!("found external impl of Drop trait on \
:omething other than a struct");
something other than a struct");
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0120.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

trait MyTrait {}

impl Drop for MyTrait { //~ ERROR E0120
impl Drop for MyTrait {
//~^ ERROR E0120
//~| NOTE implementing Drop requires a struct
fn drop(&mut self) {}
}

Expand Down

0 comments on commit 4492838

Please sign in to comment.