1
Fork 0

Rollup merge of #35326 - circuitfox:E0119-update-error-format, r=jonathandturner

E0119 update error format

Part of #35233, fixes #35252

r? @jonathandturner
This commit is contained in:
Guillaume Gomez 2016-08-05 16:12:59 +02:00 committed by GitHub
commit 31da06bebb
3 changed files with 13 additions and 5 deletions

View file

@ -141,12 +141,18 @@ impl<'cx, 'tcx,'v> intravisit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
self.tcx.sess, self.tcx.span_of_impl(impl_def_id).unwrap(), E0119, self.tcx.sess, self.tcx.span_of_impl(impl_def_id).unwrap(), E0119,
"conflicting implementations of trait `{}`{}:", "conflicting implementations of trait `{}`{}:",
overlap.trait_desc, overlap.trait_desc,
overlap.self_desc.map_or(String::new(), overlap.self_desc.clone().map_or(String::new(),
|ty| format!(" for type `{}`", ty))); |ty| format!(" for type `{}`", ty)));
match self.tcx.span_of_impl(overlap.with_impl) { match self.tcx.span_of_impl(overlap.with_impl) {
Ok(span) => { Ok(span) => {
err.span_note(span, "conflicting implementation is here:"); err.span_label(span,
&format!("first implementation here"));
err.span_label(self.tcx.span_of_impl(impl_def_id).unwrap(),
&format!("conflicting implementation{}",
overlap.self_desc
.map_or(String::new(),
|ty| format!(" for `{}`", ty))));
} }
Err(cname) => { Err(cname) => {
err.note(&format!("conflicting implementation in crate `{}`", err.note(&format!("conflicting implementation in crate `{}`",

View file

@ -12,7 +12,7 @@ trait MyTrait {
fn get(&self) -> usize; fn get(&self) -> usize;
} }
impl<T> MyTrait for T { impl<T> MyTrait for T { //~ NOTE first implementation here
fn get(&self) -> usize { 0 } fn get(&self) -> usize { 0 }
} }
@ -21,6 +21,7 @@ struct Foo {
} }
impl MyTrait for Foo { //~ ERROR E0119 impl MyTrait for Foo { //~ ERROR E0119
//~| NOTE conflicting implementation for `Foo`
fn get(&self) -> usize { self.value } fn get(&self) -> usize { self.value }
} }

View file

@ -11,12 +11,13 @@
struct MyStruct; struct MyStruct;
impl Drop for MyStruct { impl Drop for MyStruct {
//~^ NOTE conflicting implementation is here //~^ NOTE first implementation here
fn drop(&mut self) { } fn drop(&mut self) { }
} }
impl Drop for MyStruct { impl Drop for MyStruct {
//~^ ERROR conflicting implementations of trait //~^ ERROR conflicting implementations of trait
//~| NOTE conflicting implementation for `MyStruct`
fn drop(&mut self) { } fn drop(&mut self) { }
} }