-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Point out the type of associated types in every method call of iterator chains #105332
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r? @lcnr (rustbot has picked a reviewer for you, use r? to override) |
rustbot
added
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Dec 5, 2022
estebank
force-pushed
the
iterator-chains
branch
from
December 5, 2022 20:59
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
estebank
force-pushed
the
iterator-chains
branch
from
December 5, 2022 23:01
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
estebank
force-pushed
the
iterator-chains
branch
from
December 5, 2022 23:45
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.
compiler-errors
force-pushed
the
iterator-chains
branch
from
December 6, 2022 17:40
8dccc28
to
beeb026
Compare
estebank
force-pushed
the
iterator-chains
branch
from
December 6, 2022 20:08
beeb026
to
fa976a8
Compare
r? @oli-obk |
estebank
force-pushed
the
iterator-chains
branch
from
December 11, 2022 03:09
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 |
oli-obk
reviewed
Dec 11, 2022
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
oli-obk
reviewed
Dec 11, 2022
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
oli-obk
reviewed
Dec 11, 2022
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
oli-obk
reviewed
Dec 11, 2022
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
estebank
force-pushed
the
iterator-chains
branch
from
December 12, 2022 17:23
0a3933a
to
3483869
Compare
oli-obk
reviewed
Dec 12, 2022
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
@bors r+ |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Dec 12, 2022
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Dec 13, 2022
…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
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Dec 14, 2022
Point at method chains on `E0271` errors Follow up to rust-lang#105332. Fix rust-lang#33941. CC rust-lang#9082. r? `@oli-obk`
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Dec 14, 2022
Point at method chains on `E0271` errors Follow up to rust-lang#105332. Fix rust-lang#33941. CC rust-lang#9082. r? ``@oli-obk``
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Dec 15, 2022
Point at method chains on `E0271` errors Follow up to rust-lang#105332. Fix rust-lang#33941. CC rust-lang#9082. r? ```@oli-obk```
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Dec 15, 2022
Point at method chains on `E0271` errors Follow up to rust-lang#105332. Fix rust-lang#33941. CC rust-lang#9082. r? `@oli-obk`
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 3, 2024
…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).
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Mar 4, 2024
…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).
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 4, 2024
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).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.