-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
fix misleading type annotation diagonstics #69456
Conversation
This comment has been minimized.
This comment has been minimized.
You may want to add a regression test for this. See the rustc book. |
This comment has been minimized.
This comment has been minimized.
744fb23
to
6153629
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6153629
to
6d7e5e2
Compare
Ping from triage: |
@JohnCSimon As I explained in #69455 (comment), the problem is that my PR will eliminate some relevant error message in some cases. The current error messages obviously more informative. I can push a new commit to resolve the conflict and use |
6d7e5e2
to
25ec438
Compare
This comment has been minimized.
This comment has been minimized.
Yes, if you could |
This comment has been minimized.
This comment has been minimized.
ccbb4e1
to
88c45cf
Compare
This solves the method call part of issue rust-lang#69455 I added a `target_span` field so as to pin down the exact location of the error. We need a dedicated field `found_exact_method_call` to prioritize situations like the test case `issue-69455.rs`. If we reuse `found_method_call`, `found_local_pattern` will show up first. We can not move `found_method_call` up, it is undesirable in various situations.
88c45cf
to
3ae974f
Compare
@cramertj It is now ready for review. I added two field in the original struct. They are needed because I can not find any way to it without affecting existing error messages. I added a |
r? @estebank |
| ------^^^^----------------- | ||
| | | | ||
| | cannot infer type for type `u64` | ||
| this method call resolves to `<Self as Test<Rhs>>::Output` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be amazing if we actually suggested <u64 as Test<u64>>::test(23u64, xs.iter().sum())
, but that is beyond the scope of this PR.
The code looks ok to me. @contrun could you add tests for the cases you mention in your original comment would regress? I'm not sure I can see what they would be. |
@estebank
Unfortunately, my current PR does not solve that yet. This is because |
@contrun it is ok if this PR doesn't fix it, but having the test in the codebase helps us catch when an unrelated change either improves or degrades it. It also makes it easier for the reviewer to see the explicitly ignored cases. That being said, now I see what the problem is and it shouldn't block this PR. @bors r+ |
📌 Commit 3ae974f has been approved by |
Rollup of 8 pull requests Successful merges: - rust-lang#69456 (fix misleading type annotation diagonstics) - rust-lang#71330 (Only run dataflow for const qualification if type-based check would fail) - rust-lang#71480 (Improve PanicInfo examples readability) - rust-lang#71485 (Add BinaryHeap::retain as suggested in rust-lang#42849) - rust-lang#71512 (Remove useless "" args) - rust-lang#71527 (Miscellaneous cleanup in `check_consts`) - rust-lang#71534 (Avoid unused Option::map results) - rust-lang#71535 (Fix typos in docs for keyword "in") Failed merges: r? @ghost
This solves the method call part of issue #69455