Skip to content

Commit

Permalink
Auto merge of #29404 - jonas-schievink:external-overlap-print, r=Aatch
Browse files Browse the repository at this point in the history
This makes the error message in #28981 a bit shorter (152 to 115 lines).

Previous output (the local impl was always printed twice when it conflicted with an external impl):
```
test.rs:3:1: 3:23 error: conflicting implementations for trait `core::ops::Deref` [E0119]
test.rs:3 impl<T> Deref for T {}
          ^~~~~~~~~~~~~~~~~~~~~~
test.rs:3:1: 3:23 help: run `rustc --explain E0119` to see a detailed explanation
test.rs:3:1: 3:23 note: conflicting implementation in crate `std`
test.rs:3 impl<T> Deref for T {}
          ^~~~~~~~~~~~~~~~~~~~~~
```

Output after this patch:
```
test.rs:3:1: 3:23 error: conflicting implementations for trait `core::ops::Deref` [E0119]
test.rs:3 impl<T> Deref for T {}
          ^~~~~~~~~~~~~~~~~~~~~~
test.rs:3:1: 3:23 help: run `rustc --explain E0119` to see a detailed explanation
note: conflicting implementation in crate `std`
```
  • Loading branch information
bors committed Oct 28, 2015
2 parents 18ff06e + 6c094b9 commit 7e3c8cf
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/librustc_typeck/coherence/overlap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,18 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
"conflicting implementations for trait `{}`",
self.tcx.item_path_str(trait_def_id));

self.report_overlap_note(impl1, impl2);
self.report_overlap_note(impl2);
}

fn report_overlap_note(&self, impl1: DefId, impl2: DefId) {
fn report_overlap_note(&self, impl2: DefId) {

if impl2.is_local() {
span_note!(self.tcx.sess, self.span_of_impl(impl2),
"note conflicting implementation here");
} else {
let crate_store = &self.tcx.sess.cstore;
let cdata = crate_store.get_crate_data(impl2.krate);
span_note!(self.tcx.sess, self.span_of_impl(impl1),
"conflicting implementation in crate `{}`",
cdata.name);
self.tcx.sess.note(&format!("conflicting implementation in crate `{}`", cdata.name));
}
}

Expand Down

0 comments on commit 7e3c8cf

Please sign in to comment.