]> git.lizzy.rs Git - rust.git/commitdiff
Add UI test for E0053
authorKeith Yeung <kungfukeith11@gmail.com>
Wed, 17 Aug 2016 11:05:04 +0000 (04:05 -0700)
committerKeith Yeung <kungfukeith11@gmail.com>
Wed, 17 Aug 2016 22:33:50 +0000 (15:33 -0700)
src/test/ui/mismatched_types/trait-impl-fn-incompatibility.rs [new file with mode: 0644]
src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr [new file with mode: 0644]

diff --git a/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.rs b/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.rs
new file mode 100644 (file)
index 0000000..099c869
--- /dev/null
@@ -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() {
+}
+
diff --git a/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr b/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr
new file mode 100644 (file)
index 0000000..e5dfdc8
--- /dev/null
@@ -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
+