]> git.lizzy.rs Git - rust.git/commitdiff
split "has incompatible type for trait" errors into multiple lines
authorAndrew Paseltiner <apaseltiner@gmail.com>
Sun, 19 Jul 2015 01:14:36 +0000 (21:14 -0400)
committerAndrew Paseltiner <apaseltiner@gmail.com>
Sun, 19 Jul 2015 01:14:36 +0000 (21:14 -0400)
closes #21332

src/librustc/session/mod.rs
src/test/compile-fail/associated-const-impl-wrong-type.rs
src/test/compile-fail/issue-15094.rs
src/test/compile-fail/issue-20225.rs
src/test/compile-fail/issue-21332.rs [new file with mode: 0644]
src/test/compile-fail/issue-24356.rs
src/test/compile-fail/trait-impl-method-mismatch.rs
src/test/compile-fail/unsafe-trait-impl.rs

index 6b5f58720ab15c75e974f6fb62cb2557a9b17d31..2cdd2ee2f03c781c280c0b6255b9bae5ccdd8104 100644 (file)
@@ -301,7 +301,8 @@ fn split_msg_into_multilines(msg: &str) -> Option<String> {
         !msg.contains("if and else have incompatible types") &&
         !msg.contains("if may be missing an else clause") &&
         !msg.contains("match arms have incompatible types") &&
-        !msg.contains("structure constructor specifies a structure of type") {
+        !msg.contains("structure constructor specifies a structure of type") &&
+        !msg.contains("has an incompatible type for trait") {
             return None
     }
     let first = msg.match_indices("expected").filter(|s| {
index 4f20d9e78ebd010a74269a7f7598a42cc69693b2..4658d0f057d71c85aeeab2c9040bf4fd2c92bf40 100644 (file)
@@ -18,7 +18,9 @@ trait Foo {
 
 impl Foo for SignedBar {
     const BAR: i32 = -1;
-    //~^ ERROR E0326
+    //~^ ERROR implemented const `BAR` has an incompatible type for trait
+    //~| expected u32,
+    //~| found i32 [E0326]
 }
 
 fn main() {}
index 3853434e128ebd0b9465747277150ddf0c9fc41b..42e3456b309be35585a6ed39181eaebbb63aa745 100644 (file)
@@ -19,7 +19,9 @@ struct Debuger<T> {
 impl<T: fmt::Debug> ops::FnOnce<(),> for Debuger<T> {
     type Output = ();
     fn call_once(self, _args: ()) {
-//~^ ERROR `call_once` has an incompatible type for trait: expected "rust-call" fn, found "Rust" fn
+    //~^ ERROR `call_once` has an incompatible type for trait
+    //~| expected "rust-call" fn,
+    //~| found "Rust" fn
         println!("{:?}", self.x);
     }
 }
index fe427e02451af6a0587f2c7ae49cfc2f98dfa75e..b7845f1f1168af8a9353f819903b5fe03ab59e3c 100644 (file)
 
 impl<'a, T> Fn<(&'a T,)> for Foo {
   extern "rust-call" fn call(&self, (_,): (T,)) {}
-  //~^ ERROR: has an incompatible type for trait: expected &-ptr
+  //~^ ERROR: has an incompatible type for trait
+  //~| expected &-ptr
 }
 
 impl<'a, T> FnMut<(&'a T,)> for Foo {
   extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
-  //~^ ERROR: has an incompatible type for trait: expected &-ptr
+  //~^ ERROR: has an incompatible type for trait
+  //~| expected &-ptr
 }
 
 impl<'a, T> FnOnce<(&'a T,)> for Foo {
   type Output = ();
 
   extern "rust-call" fn call_once(self, (_,): (T,)) {}
-  //~^ ERROR: has an incompatible type for trait: expected &-ptr
+  //~^ ERROR: has an incompatible type for trait
+  //~| expected &-ptr
 }
 
 fn main() {}
diff --git a/src/test/compile-fail/issue-21332.rs b/src/test/compile-fail/issue-21332.rs
new file mode 100644 (file)
index 0000000..f25a9fd
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2015 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.
+
+struct S;
+
+impl Iterator for S {
+    type Item = i32;
+    fn next(&mut self) -> Result<i32, i32> { Ok(7) }
+    //~^ ERROR method `next` has an incompatible type for trait
+    //~| expected enum `core::option::Option`
+    //~|    found enum `core::result::Result` [E0053]
+}
+
+fn main() {}
index 22f71835336faed30adaf77cdcf43a1535ec5eb4..27d46be40fbeb69bbe96b617eff5dce36c28d484 100644 (file)
@@ -30,7 +30,9 @@ fn deref(&self) -> &i8 { &self.0 }
         impl Deref for Thing {
             //~^ ERROR not all trait items implemented, missing: `Target` [E0046]
             fn deref(&self) -> i8 { self.0 }
-            //~^ ERROR method `deref` has an incompatible type for trait: expected &-ptr, found i8 [E0053]
+            //~^ ERROR method `deref` has an incompatible type for trait
+            //~| expected &-ptr
+            //~| found i8 [E0053]
         }
 
         let thing = Thing(72);
index 4e2eb22421354d2d2ced3bb3a31c85859a7fa12e..f86d9b7648bbebfd19a2f9740fffdb0ad394c106 100644 (file)
@@ -16,7 +16,9 @@ trait Mumbo {
 impl Mumbo for usize {
     // Cannot have a larger effect than the trait:
     unsafe fn jumbo(&self, x: &usize) { *self + *x; }
-    //~^ ERROR expected normal fn, found unsafe fn
+    //~^ ERROR method `jumbo` has an incompatible type for trait
+    //~| expected normal fn,
+    //~| found unsafe fn
 }
 
 fn main() {}
index 71da2f7633f3cb970cb015aea763e612c8044714..51f876661f6510834a4dfd78ea2ea39a770b5440 100644 (file)
@@ -16,7 +16,9 @@ trait Foo {
 
 impl Foo for u32 {
     fn len(&self) -> u32 { *self }
-    //~^ ERROR incompatible type for trait: expected unsafe fn, found normal fn
+    //~^ ERROR method `len` has an incompatible type for trait
+    //~| expected unsafe fn,
+    //~| found normal fn
 }
 
 fn main() { }