Skip to content

Commit 2f36ecf

Browse files
committed
E0119 update error format
1 parent e804a3c commit 2f36ecf

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/librustc_typeck/coherence/overlap.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,18 @@ impl<'cx, 'tcx,'v> intravisit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
141141
self.tcx.sess, self.tcx.span_of_impl(impl_def_id).unwrap(), E0119,
142142
"conflicting implementations of trait `{}`{}:",
143143
overlap.trait_desc,
144-
overlap.self_desc.map_or(String::new(),
145-
|ty| format!(" for type `{}`", ty)));
144+
overlap.self_desc.clone().map_or(String::new(),
145+
|ty| format!(" for type `{}`", ty)));
146146

147147
match self.tcx.span_of_impl(overlap.with_impl) {
148148
Ok(span) => {
149-
err.span_note(span, "conflicting implementation is here:");
149+
err.span_label(span,
150+
&format!("first implementation here"));
151+
err.span_label(self.tcx.span_of_impl(impl_def_id).unwrap(),
152+
&format!("conflicting implementation{}",
153+
overlap.self_desc
154+
.map_or(String::new(),
155+
|ty| format!(" for `{}`", ty))));
150156
}
151157
Err(cname) => {
152158
err.note(&format!("conflicting implementation in crate `{}`",

src/test/compile-fail/E0119.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ trait MyTrait {
1212
fn get(&self) -> usize;
1313
}
1414

15-
impl<T> MyTrait for T {
15+
impl<T> MyTrait for T { //~ NOTE first implementation here
1616
fn get(&self) -> usize { 0 }
1717
}
1818

@@ -21,6 +21,7 @@ struct Foo {
2121
}
2222

2323
impl MyTrait for Foo { //~ ERROR E0119
24+
//~| NOTE conflicting implementation for `Foo`
2425
fn get(&self) -> usize { self.value }
2526
}
2627

src/test/compile-fail/issue-28568.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
struct MyStruct;
1212

1313
impl Drop for MyStruct {
14-
//~^ NOTE conflicting implementation is here
14+
//~^ NOTE first implementation here
1515
fn drop(&mut self) { }
1616
}
1717

1818
impl Drop for MyStruct {
1919
//~^ ERROR conflicting implementations of trait
20+
//~| NOTE conflicting implementation for `MyStruct`
2021
fn drop(&mut self) { }
2122
}
2223

0 commit comments

Comments
 (0)