Skip to content

Commit

Permalink
Rollup merge of rust-lang#35298 - Keats:err-120, r=jonathandturner
Browse files Browse the repository at this point in the history
Update error message E0120

Fixes rust-lang#35253 as part of rust-lang#35233.

r? @jonathandturner
  • Loading branch information
steveklabnik committed Aug 4, 2016
2 parents ef18466 + 4492838 commit 3d9003d
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 3d9003d

Please sign in to comment.