diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-08-05 16:12:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-05 16:12:57 +0200 |
| commit | 65a283fac18f21da9836e763abc5be3be5014702 (patch) | |
| tree | fafaf8bfd4eabbfd49971fb31a2337cb9040b221 | |
| parent | 8038c17da541ff22e7c7a0ed83e8b1fc8066ed49 (diff) | |
| parent | 3b2f1845f3a1d8192a14b4184d5ba66ad7a98ac3 (diff) | |
| download | rust-65a283fac18f21da9836e763abc5be3be5014702.tar.gz rust-65a283fac18f21da9836e763abc5be3be5014702.zip | |
Rollup merge of #35298 - Keats:err-120, r=jonathandturner
Update error message E0120 Fixes #35253 as part of #35233. r? @jonathandturner
| -rw-r--r-- | src/librustc_typeck/coherence/mod.rs | 15 | ||||
| -rw-r--r-- | src/test/compile-fail/E0120.rs | 4 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 198e9afd5e1..2d14b0dacf2 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -249,8 +249,17 @@ 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"); @@ -258,7 +267,7 @@ impl<'a, 'gcx, 'tcx> CoherenceChecker<'a, 'gcx, 'tcx> { } } else { bug!("found external impl of Drop trait on \ - :omething other than a struct"); + something other than a struct"); } } } diff --git a/src/test/compile-fail/E0120.rs b/src/test/compile-fail/E0120.rs index de084274f6f..3fdeb753175 100644 --- a/src/test/compile-fail/E0120.rs +++ b/src/test/compile-fail/E0120.rs @@ -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) {} } |
