Skip to content

Commit 6487396

Browse files
author
Yossi Konstantinovsky
committed
Update E0185 and E0186 to new format
1 parent ea07d52 commit 6487396

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/librustc_typeck/check/compare_method.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,33 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
5959
(&ty::ExplicitSelfCategory::Static,
6060
&ty::ExplicitSelfCategory::Static) => {}
6161
(&ty::ExplicitSelfCategory::Static, _) => {
62-
span_err!(tcx.sess, impl_m_span, E0185,
62+
let mut err = struct_span_err!(tcx.sess, impl_m_span, E0185,
6363
"method `{}` has a `{}` declaration in the impl, \
6464
but not in the trait",
6565
trait_m.name,
6666
impl_m.explicit_self);
67+
err.span_label(impl_m_span, &format!("`{}` used in impl",
68+
impl_m.explicit_self));
69+
if let Some(span) = tcx.map.span_if_local(trait_m.def_id) {
70+
err.span_label(span, &format!("trait declared without `{}`",
71+
impl_m.explicit_self));
72+
}
73+
err.emit();
6774
return;
6875
}
6976
(_, &ty::ExplicitSelfCategory::Static) => {
70-
span_err!(tcx.sess, impl_m_span, E0186,
77+
let mut err = struct_span_err!(tcx.sess, impl_m_span, E0186,
7178
"method `{}` has a `{}` declaration in the trait, \
7279
but not in the impl",
7380
trait_m.name,
7481
trait_m.explicit_self);
82+
err.span_label(impl_m_span, &format!("expected `{}` in impl",
83+
trait_m.explicit_self));
84+
if let Some(span) = tcx.map.span_if_local(trait_m.def_id) {
85+
err.span_label(span, & format!("`{}` used in trait",
86+
trait_m.explicit_self));
87+
}
88+
err.emit();
7589
return;
7690
}
7791
_ => {

src/test/compile-fail/E0185.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
// except according to those terms.
1010

1111
trait Foo {
12-
fn foo();
12+
fn foo(); //~ trait declared without `&self`
1313
}
1414

1515
struct Bar;
1616

1717
impl Foo for Bar {
1818
fn foo(&self) {} //~ ERROR E0185
19+
//~^ `&self` used in impl
1920
}
2021

2122
fn main() {

src/test/compile-fail/E0186.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
// except according to those terms.
1010

1111
trait Foo {
12-
fn foo(&self);
12+
fn foo(&self); //~ `&self` used in trait
1313
}
1414

1515
struct Bar;
1616

1717
impl Foo for Bar {
1818
fn foo() {} //~ ERROR E0186
19+
//~^ expected `&self` in impl
1920
}
2021

2122
fn main() {

0 commit comments

Comments
 (0)