Open walksanatora opened 1 week ago
this may also work as a sub-command of cargo report
eg: cargo report trait-implementations
Another way to consider this is that cargo doc
is able to collect this information. On top of that, there is experimental json output for it. Someone could experiment with specific queries or a general purpose set of queries for types and traits based on that. This would likely be the best way forward for experimenting and evaluating the idea before inclusion into Cargo in some form.
odd is that when I ran cargo +nightly rustdoc -Z unstable-options --output-format=json
it only included the trait implementation information for my crate. (as the unstable option of output-format is not on the base doc command yet)
Guess it is because cargo rustdoc
passes those trailing arguments to only one crate selected in CLI, which by default is your primary package.
I'm also interested in this feature.
I've been thinking about a potential cargo trait-query
subcommand.
Maybe use rustdoc experimental JSON output to build a queryable index of trait implementations?
Problem
I am writing a program and would like a way to see every struct that implements a trait (eg:
serde::Serialize
) I know that at somepoint during compilation the full type information is avaliable because rust is able to give output likewhen using types that dont implement a trait.
Proposed Solution
if I had to guess this would probally be best relegated to some kind of nightly -Z flag probally smth like
-Z dump-impls
probally producing either a debug output dump of the crates. or just a simple tabulated tree of crates and traits and implsNotes
No response