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 <[email protected]> Signed-off-by: Usman Akinyemi <[email protected]>
|
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. |
Do note that in some cases, the crate's author is a collection of people of different levels of expertise with the codebase. Think large commercial projects with high turn-over. Those would likely want to be able to leverage existing mechanisms for onboarding new engineers. Realistically, it's true that a lot of these projects would already be relying on workspaces and splitting their projects in multiple crates, but that is not necessarily a given.
I highly suspect that the order in which the thought process went was "we don't get this for free" -> "we don't need it anyways", which is perfectly defensible! But the comment should likely have included both points :)
Agreed on the additional cost to
The lack of consistency is a minor papercut that might confuse people by not matching their expectations. I agree it is not too important to address, but I'd like to minimize divergences as much as possible. Otherwise, we'd want a lint on |
|
@petrochenkov - you might want to take a look at the last comment. |
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).