Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update E0185 and E0186 to new format #35314

Merged
merged 1 commit into from
Aug 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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