-
Couldn't load subscription status.
- Fork 13.9k
Point out the type of associated types in every method call of iterator chains #105332
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
Conversation
|
r? @lcnr (rustbot has picked a reviewer for you, use r? to override) |
273085e to
179525c
Compare
This comment was marked as resolved.
This comment was marked as resolved.
|
I think 42847b08439f853116064ec37c255db4776a5e2d should be pulled into a different PR since it's unrelated. |
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
4d9f99d to
f0159cf
Compare
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
f0159cf to
aad80ca
Compare
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
8dccc28 to
beeb026
Compare
beeb026 to
fa976a8
Compare
|
r? @oli-obk |
6d87cb0 to
c02fd64
Compare
When encountering an unmet obligation that affects a method chain, like
in iterator chains where one of the links has the wrong associated
type, we point at every method call and mention their evaluated
associated type at that point to give context to the user of where
expectations diverged from the code as written.
```
note: the expression is of type `Map<std::slice::Iter<'_, {integer}>, [closure@$DIR/invalid-iterator-chain.rs:12:18: 12:21]>`
--> $DIR/invalid-iterator-chain.rs:12:14
|
LL | vec![0, 1]
| ---------- this expression has type `Vec<{integer}>`
LL | .iter()
| ------ associated type `std::iter::Iterator::Item` is `&{integer}` here
LL | .map(|x| { x; })
| ^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` is `()` here
```
|
Could be a good opportunity to move the entire ObligationCauseCode::FunctionArgumentObligation arm into a new module |
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
0a3933a to
3483869
Compare
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
|
@bors r+ |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#104864 (Account for item-local in inner scope for E0425) - rust-lang#105332 (Point out the type of associated types in every method call of iterator chains) - rust-lang#105620 (Remove unnecessary uses of `clone`) - rust-lang#105625 (minor code cleanups) - rust-lang#105629 (rustdoc: stop treating everything in a trait item as a method) - rust-lang#105636 (Add check for local-storage value when changing "display line numbers" settings) - rust-lang#105639 (rustdoc: remove `type="text/css" from stylesheet links) - rust-lang#105640 (Adjust miri to still be optional) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Point at method chains on `E0271` errors Follow up to rust-lang#105332. Fix rust-lang#33941. CC rust-lang#9082. r? `@oli-obk`
Point at method chains on `E0271` errors Follow up to rust-lang#105332. Fix rust-lang#33941. CC rust-lang#9082. r? ``@oli-obk``
Point at method chains on `E0271` errors Follow up to rust-lang#105332. Fix rust-lang#33941. CC rust-lang#9082. r? ```@oli-obk```
Point at method chains on `E0271` errors Follow up to rust-lang#105332. Fix rust-lang#33941. CC rust-lang#9082. r? `@oli-obk`
…piler-errors,estebank Properly deal with GATs when looking for method chains to point at Fixes rust-lang#121898. ~~While it prevents an ICE and the structured suggestion is correct, the method chain diagnostic notes are weird / useless / incorrect judging by a quick look. I guess I should improve that in this PR.~~ Sufficiently taken care of. r? estebank or compiler-errors (rust-lang#105332, rust-lang#105674).
…ompiler-errors,estebank Properly deal with GATs when looking for method chains to point at Fixes rust-lang#121898. ~~While it prevents an ICE and the structured suggestion is correct, the method chain diagnostic notes are weird / useless / incorrect judging by a quick look. I guess I should improve that in this PR.~~ Sufficiently taken care of. r? estebank or compiler-errors (rust-lang#105332, rust-lang#105674).
Rollup merge of rust-lang#121912 - fmease:diag-method-chains-gat, r=compiler-errors,estebank Properly deal with GATs when looking for method chains to point at Fixes rust-lang#121898. ~~While it prevents an ICE and the structured suggestion is correct, the method chain diagnostic notes are weird / useless / incorrect judging by a quick look. I guess I should improve that in this PR.~~ Sufficiently taken care of. r? estebank or compiler-errors (rust-lang#105332, rust-lang#105674).
Partially address #105184 by pointing out the type of associated types in every method call of iterator chains:
We also reduce the number of impls we mention when any of the candidates is an "exact match". This benefits the output of cases with numerics greatly.
Outstanding work would be to provide a structured suggestion for appropriate changes, like in this case detecting the spurious
;in the closure.