Rollup merge of #41489 - estebank:trait-bounds-diagnosstic, r=arielb1
Make unsatisfied trait bounds note multiline Make diagnostic note for existing method with unsatisfied trait bounds multiline for cleaner output. ``` = note: the method `count` exists but the following trait bounds were not satisfied: `[closure@../../src/test/compile-fail/issue-36053-2.rs:17:39: 17:53] : std::ops::FnMut<(&_,)>` `std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>> [closure@../../src/test/compile-fail/issue-36053-2.rs:17:39: 17:53]> : std::iter::Iterator` ``` Before: ``` = note: the method `count` exists but the following trait bounds were not satisfied: `[closure@../../src/test/compile-fail/issue-36053-2.rs:17:39: 17:53] : std::ops::FnMut<(&_,)>`, `std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@../../src/test/compile-fail/issue-36053-2.rs:17:39: 17:53]> : std::iter::Iterator` ```
This commit is contained in:
commit
7a9cf929d5
@ -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));
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user