Open illicitonion opened 5 years ago
Rustc has some code around this for making the suggestion to add a use
import if the type hasn't been imported yet. Unfortunately it is heavily entangled with the resolve code in the compiler. I'm not sure what kind of refactorings would be necessary in order to just query a few specific paths
I'm writing a new lint (and have written one before, too), where the suggested replacement code needs to reference a type where it's non-obvious how the type has been imported into scope.
Is there a handy helper somewhere for "Given this type, give me the best way this code could reference it"? i.e. if the type is imported into scope, use its bare name, or if the module which defines it is in scope, reference it as
module::Type
, or if not, use::fully::qualified::Type
?If not, are there any pointers for how I might go about implementing such a thing?
Thanks!