Rollup merge of #35765 - KiChjang:e0053-bonus, r=jonathandturner

Additional span info for E0053

Part of #35233.
Fixes #35212.

r? @jonathandturner
This commit is contained in:
Eduard-Mihai Burtescu 2016-08-18 06:12:23 +03:00 committed by GitHub
commit 8ccc11b31b
7 changed files with 158 additions and 27 deletions

View file

@ -9,15 +9,21 @@
// except according to those terms.
trait Foo {
fn foo(x: u16);
fn bar(&self);
fn foo(x: u16); //~ NOTE original trait requirement
fn bar(&self); //~ NOTE original trait requirement
}
struct Bar;
impl Foo for Bar {
fn foo(x: i16) { } //~ ERROR E0053
fn bar(&mut self) { } //~ ERROR E0053
fn foo(x: i16) { }
//~^ ERROR method `foo` has an incompatible type for trait
//~| NOTE expected u16
fn bar(&mut self) { }
//~^ ERROR method `bar` has an incompatible type for trait
//~| NOTE values differ in mutability
//~| NOTE expected type `fn(&Bar)`
//~| NOTE found type `fn(&mut Bar)`
}
fn main() {

View file

@ -0,0 +1,27 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// rustc-env:RUST_NEW_ERROR_FORMAT
trait Foo {
fn foo(x: u16);
fn bar(&mut self, bar: &mut Bar);
}
struct Bar;
impl Foo for Bar {
fn foo(x: i16) { }
fn bar(&mut self, bar: &Bar) { }
}
fn main() {
}

View file

@ -0,0 +1,23 @@
error[E0053]: method `foo` has an incompatible type for trait
--> $DIR/trait-impl-fn-incompatibility.rs:21:15
|
14 | fn foo(x: u16);
| --- original trait requirement
...
21 | fn foo(x: i16) { }
| ^^^ expected u16, found i16
error[E0053]: method `bar` has an incompatible type for trait
--> $DIR/trait-impl-fn-incompatibility.rs:22:28
|
15 | fn bar(&mut self, bar: &mut Bar);
| -------- original trait requirement
...
22 | fn bar(&mut self, bar: &Bar) { }
| ^^^^ values differ in mutability
|
= note: expected type `fn(&mut Bar, &mut Bar)`
= note: found type `fn(&mut Bar, &Bar)`
error: aborting due to 2 previous errors