resolve: use #[doc(alias)] to improve function resolution diagnostics#154833
resolve: use #[doc(alias)] to improve function resolution diagnostics#154833Unique-Usman wants to merge 1 commit intorust-lang:mainfrom
#[doc(alias)] to improve function resolution diagnostics#154833Conversation
Parse `#[doc(alias)]` attributes for local functions and store them in the resolver. Use these aliases during name resolution diagnostics to suggest the original function when an alias is used in its place. This enables cases like calling `bar()` to suggest `foo()` when `foo` is annotated with `#[doc(alias = "bar")]`. Includes UI tests for function and method cases(which has already being supported). Helped-by: Esteban Küber <esteban@kuber.com.ar> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
|
r? @davidtwco rustbot has assigned @davidtwco. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? estebank |
|
I don't think we should do this. So it's a low value diagnostic change, but it requires keeping a new global mutable resolver state and doing extra work on a good path -> doesn't pull its weight. |
Valid point. Not entirely true though, because, doc alias is actually used initially before this pr in the same crate for method and associated functions for diagnostics. Also, the comment was actually also a little bit misleading, after investigating it, the lookup_doc_alias_name was using
This is true, but, looking at my reason above, do you think this stills stands ? |
|
This also works for methods and associated function in a trait for the same crates for diagnosis. So, I believe not working for function is more of the hacking that needs to be done to supportting it. |
Yeah, because there (in
That's an (ideological) issue with the new attribute parsing infra design, parsed attributes are not HIR, and are often used before HIR is built (like in rustc_resolve), but the new infra uses HIR for naming and puts itself into HIR modules. |
Parse
#[doc(alias)]attributes for local functions and store them in the resolver. Use these aliases during name resolution diagnostics to suggest the original function when an alias is used in its place.This enables cases like calling
bar()to suggestfoo()whenfoois annotated with#[doc(alias = "bar")].Includes UI tests for function and method cases(which has already being supported).