-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Improve type hints for long/deeply nested types (parser combinators etc.) #11240
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
Comments
I don't think we should allow crate developers to turn off inlay hints - I fear this might lead to even more confusion for the end user. But perhaps we should endeavor to render something more sensible for inlay hints in places like this, similar to what is done for iterable chains already. |
11247: Print a single ellipsis for any number of omitted types r=jonas-schievink a=jonas-schievink Helps a little bit with #11240 bors r+ Co-authored-by: Jonas Schievink <[email protected]>
Couldn't type aliases solve this? |
No, because 1. rust-analyzer doesn't use type aliases when displaying types, and doing so is kind of complicated, and 2. type aliases can't really simplify such a nested type much anyway. |
Playing with @zesterer's idea a bit, I'm wondering how we might get lib authors involved in this process by allowing them to annotate for example, "I want this to be displayed as some For the reference:
|
Ideally via #11556 would be my first thought |
Hello!
I'm the author of
chumsky
, a parser combinator crate. As I'm sure you know, parser combinators involve combining simple parsers together with the type system to produce parsers for more complex syntaxes.Unfortunately, this can result in very large types that, although very useful to the compiler, are almost entirely useless for the programmer trying to work with them (each parser has a virtually identical API to any other, and so the type conveys no real meaning: only the traits that it implements matter).
I'm not personally a user of
rust-analyzer
, but I have a few users that are, and I've noticed that they're getting rather intrusive type annotations within combinator code, like so:It would be great is there were a way to opt out of inline type hints (perhaps with an override) that could be controlled by crate developers. Perhaps it would be possible to have some sort of
#[rust_analyzer(no_hint)]
attribute that I can add to my combinator types that would be understood byrust-analyzer
?My apologies if this has already been requested: I checked existing issues already and was unable to find something similar.
The text was updated successfully, but these errors were encountered: