-
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
On method chain expression failure, look for missing method in earlier segments of the chain #115222
Comments
@rustbot claim |
@estebank Hi, I am new to Rust and need some help landing this fix. Would you be the right person to ask questions? What I have found out so far is that the Diagnostic is generated from here: compiler/rustc_hir_typeck/src/method/suggest.rs:385:22. I think we need to find where in the struct inheritance chain the method appears while walking up the chain from current struct and write out a diagnostic from there. Is that the right way ? If so, is there a compiler pass that will help me walk up the struct chain? |
Hi @iSwapna! There are two things at play here: typeck which you just found and the HIR (high level intermediate representation) which holds the "hydrated AST", a fancy way of saying "every component bit of code with syntax desugaring applied and access to their type information so far". So what you want to do is look at 468
can_eq we'll be looking at theexpr_ty_adjusted_opt for each receiver and then call probe_for_name with the method name that failed on each of those receivers (like we do in note_derefed_ty_has_method ). Do not hesitate to ask more questions!
|
@estebank Here is what I have so far:
|
I am playing with
How do I do that? |
On method chain expression failure, look for missing method in earlier segments of the chain This PR tries to fix the issue: rust-lang#115222 As suggested by `@estebank` , I did the following: 1. Add new test `tests/ui/structs/method-chain-expression-failure.rs` 2. In `compiler/rusct_hir_tycheck/src/method/suggest.rs` walking up the method chain and calling `probe_for_name` with the method name. But the call fails to return `Ok`.
Current output:
So this should be good enough to consider as resolved |
Code
Current output
Desired output
Rationale and extra context
No response
Other cases
No response
Anything else?
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=5d27c80570db4a4005f5ff3d4ea94e0e
The text was updated successfully, but these errors were encountered: