Skip to content

split "has incompatible type for trait" errors into multiple lines #27121

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

Merged
merged 1 commit into from
Jul 19, 2015
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
3 changes: 2 additions & 1 deletion src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/associated-const-impl-wrong-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ struct SignedBar;

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() {}
4 changes: 3 additions & 1 deletion src/test/compile-fail/issue-15094.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/test/compile-fail/issue-20225.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@ struct Foo;

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() {}
21 changes: 21 additions & 0 deletions src/test/compile-fail/issue-21332.rs
Original file line number Diff line number Diff line change
@@ -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() {}
4 changes: 3 additions & 1 deletion src/test/compile-fail/issue-24356.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ fn main() {
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);
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/trait-impl-method-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
4 changes: 3 additions & 1 deletion src/test/compile-fail/unsafe-trait-impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }