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

Make unsatisfied trait bounds note multiline #41489

Merged
merged 1 commit into from
May 16, 2017
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
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let bound_list = unsatisfied_predicates.iter()
.map(|p| format!("`{} : {}`", p.self_ty(), p))
.collect::<Vec<_>>()
.join(", ");
.join("\n");
err.note(&format!("the method `{}` exists but the following trait bounds \
were not satisfied: {}",
were not satisfied:\n{}",
item_name,
bound_list));
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/ui/mismatched_types/issue-36053-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ error: no method named `count` found for type `std::iter::Filter<std::iter::Fuse
17 | once::<&str>("str").fuse().filter(|a: &str| true).count();
| ^^^^^
|
= note: the method `count` exists but the following trait bounds were not satisfied: `[closure@$DIR/issue-36053-2.rs:17:39: 17:53] : std::ops::FnMut<(&_,)>`, `std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:17:39: 17:53]> : std::iter::Iterator`
= note: the method `count` exists but the following trait bounds were not satisfied:
`[closure@$DIR/issue-36053-2.rs:17:39: 17:53] : std::ops::FnMut<(&_,)>`
`std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:17:39: 17:53]> : std::iter::Iterator`

error[E0281]: type mismatch: `[closure@$DIR/issue-36053-2.rs:17:39: 17:53]` implements the trait `for<'r> std::ops::FnMut<(&'r str,)>`, but the trait `for<'r> std::ops::FnMut<(&'r &str,)>` is required
--> $DIR/issue-36053-2.rs:17:32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ fn main() {
let a: Result<(), Foo> = Ok(());
a.unwrap();
//~^ ERROR no method named `unwrap` found for type `std::result::Result<(), Foo>`
//~| NOTE the following trait bounds were not satisfied: `Foo : std::fmt::Debug`
//~| NOTE the method `unwrap` exists but the following trait bounds were not satisfied
}
11 changes: 11 additions & 0 deletions src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error: no method named `unwrap` found for type `std::result::Result<(), Foo>` in the current scope
--> $DIR/method-help-unsatisfied-bound.rs:15:7
|
15 | a.unwrap();
| ^^^^^^
|
= note: the method `unwrap` exists but the following trait bounds were not satisfied:
`Foo : std::fmt::Debug`

error: aborting due to previous error