rust/tests/ui/iterators
Esteban Küber f0c93117ed Use root obligation on E0277 for some cases
When encountering trait bound errors that satisfy some heuristics that
tell us that the relevant trait for the user comes from the root
obligation and not the current obligation, we use the root predicate for
the main message.

This allows to talk about "X doesn't implement Pattern<'_>" over the
most specific case that just happened to fail, like  "char doesn't
implement Fn(&mut char)" in
`tests/ui/traits/suggest-dereferences/root-obligation.rs`

The heuristics are:

 - the type of the leaf predicate is (roughly) the same as the type
   from the root predicate, as a proxy for "we care about the root"
 - the leaf trait and the root trait are different, so as to avoid
   talking about `&mut T: Trait` and instead remain talking about
   `T: Trait` instead
 - the root trait is not `Unsize`, as to avoid talking about it in
   `tests/ui/coercion/coerce-issue-49593-box-never.rs`.

```
error[E0277]: the trait bound `&char: Pattern<'_>` is not satisfied
  --> $DIR/root-obligation.rs:6:38
   |
LL |         .filter(|c| "aeiou".contains(c))
   |                             -------- ^ the trait `Fn<(char,)>` is not implemented for `&char`, which is required by `&char: Pattern<'_>`
   |                             |
   |                             required by a bound introduced by this call
   |
   = note: required for `&char` to implement `FnOnce<(char,)>`
   = note: required for `&char` to implement `Pattern<'_>`
note: required by a bound in `core::str::<impl str>::contains`
  --> $SRC_DIR/core/src/str/mod.rs:LL:COL
help: consider dereferencing here
   |
LL |         .filter(|c| "aeiou".contains(*c))
   |                                      +
```

Fix #79359, fix #119983, fix #118779, cc #118415 (the suggestion needs
to change).
2024-03-03 18:53:35 +00:00
..
array-of-ranges.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
array.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
bound.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bound.stderr Use root obligation on E0277 for some cases 2024-03-03 18:53:35 +00:00
collect-into-array.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
collect-into-array.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
collect-into-slice.rs On E0277 be clearer about implicit Sized bounds on type params and assoc types 2024-02-01 03:30:26 +00:00
collect-into-slice.stderr On E0277 be clearer about implicit Sized bounds on type params and assoc types 2024-02-01 03:30:26 +00:00
float_iterator_hint.rs add note for float iterator 2023-01-12 15:29:53 +01:00
float_iterator_hint.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
integral.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
integral.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
into-iter-on-arrays-2018.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
into-iter-on-arrays-2018.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
into-iter-on-arrays-2021.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
into-iter-on-arrays-lint.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
into-iter-on-arrays-lint.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
into-iter-on-arrays-lint.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
into-iterator-type-inference-shift.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
invalid-iterator-chain-fixable.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
invalid-iterator-chain-fixable.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
invalid-iterator-chain-fixable.stderr Special case iterator chain checks for suggestion 2023-10-14 04:11:54 +00:00
invalid-iterator-chain-with-int-infer.rs Handle inference variables in CollectAllMismatches correctly 2023-01-11 20:01:24 +00:00
invalid-iterator-chain-with-int-infer.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
invalid-iterator-chain.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid-iterator-chain.stderr Special case iterator chain checks for suggestion 2023-10-14 04:11:54 +00:00
issue-28098.rs Deduplicate more sized errors on call exprs 2024-01-24 02:53:15 +00:00
issue-28098.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
issue-58952-filter-type-length.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
iter-cloned-type-inference.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
iter-count-overflow-debug.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
iter-count-overflow-ndebug.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
iter-map-fold-type-length.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
iter-position-overflow-debug.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
iter-position-overflow-ndebug.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
iter-range.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
iter-step-overflow-debug.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
iter-step-overflow-ndebug.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
iter-sum-overflow-debug.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
iter-sum-overflow-ndebug.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
iter-sum-overflow-overflow-checks.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
ranges.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ranges.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
rsplit-clone.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
skip-count-overflow.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
string.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
string.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
vec-on-unimplemented.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-on-unimplemented.stderr Use only one label for multiple unsatisfied bounds on type (typeck) 2024-01-26 20:47:19 +00:00