Skip to content

Commit

Permalink
Rollup merge of rust-lang#35314 - yossi-k:issue/35277, r=jonathandturner
Browse files Browse the repository at this point in the history
Update E0185 and E0186 to new format

Part of rust-lang#35233.
Fixes rust-lang#35277.
Fixes rust-lang#35276.
r? @jonathandturner
  • Loading branch information
Jonathan Turner committed Aug 7, 2016
2 parents f5e7a59 + 6487396 commit f9f6fd4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/librustc_typeck/check/compare_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,33 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
(&ty::ExplicitSelfCategory::Static,
&ty::ExplicitSelfCategory::Static) => {}
(&ty::ExplicitSelfCategory::Static, _) => {
span_err!(tcx.sess, impl_m_span, E0185,
let mut err = struct_span_err!(tcx.sess, impl_m_span, E0185,
"method `{}` has a `{}` declaration in the impl, \
but not in the trait",
trait_m.name,
impl_m.explicit_self);
err.span_label(impl_m_span, &format!("`{}` used in impl",
impl_m.explicit_self));
if let Some(span) = tcx.map.span_if_local(trait_m.def_id) {
err.span_label(span, &format!("trait declared without `{}`",
impl_m.explicit_self));
}
err.emit();
return;
}
(_, &ty::ExplicitSelfCategory::Static) => {
span_err!(tcx.sess, impl_m_span, E0186,
let mut err = struct_span_err!(tcx.sess, impl_m_span, E0186,
"method `{}` has a `{}` declaration in the trait, \
but not in the impl",
trait_m.name,
trait_m.explicit_self);
err.span_label(impl_m_span, &format!("expected `{}` in impl",
trait_m.explicit_self));
if let Some(span) = tcx.map.span_if_local(trait_m.def_id) {
err.span_label(span, & format!("`{}` used in trait",
trait_m.explicit_self));
}
err.emit();
return;
}
_ => {
Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail/E0185.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
// except according to those terms.

trait Foo {
fn foo();
fn foo(); //~ trait declared without `&self`
}

struct Bar;

impl Foo for Bar {
fn foo(&self) {} //~ ERROR E0185
//~^ `&self` used in impl
}

fn main() {
Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail/E0186.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
// except according to those terms.

trait Foo {
fn foo(&self);
fn foo(&self); //~ `&self` used in trait
}

struct Bar;

impl Foo for Bar {
fn foo() {} //~ ERROR E0186
//~^ expected `&self` in impl
}

fn main() {
Expand Down

0 comments on commit f9f6fd4

Please sign in to comment.