-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
New lint: trait removed supertrait #232
Comments
@obi1kenobi I can take this one if you don't mind me sitting on it for a couple of days, I'm still trying to understand exactly how the lint rules work (more specifically the trustfall queries). edit: I think "sitting on it" is not the right expression, "if you don't mind me taking a couple of days trying out how to make this work" |
No worries at all, take all the time you need and feel free to ask questions / open draft PRs and ask for feedback / etc. I'm happy to support you in whatever way you need. You can play with the query language over rustdoc here: https://play.predr.ag/rustdoc It can't compare crates -- it only queries one crate at a time -- and uses a slightly older plugin version so not all the bits of the schema cargo-semver-checks has are there (this is what the playground has instead). But it's a quick and easy way to write some queries, see what they do, and get used to the whole thing. There are example queries in the drop-down but you can also write your own as well. |
I do have a question, I'm using the playground to understand better the information available on query {
Crate {
item {
... on Trait {
name @output
docs @output
crate_id @output
span {
filename @output
first_line: begin_line @output
}
}
}
}
} My output is []. But from what I can see, all the attributes I'm looking for are present at the Schema. Also, if I change Do you know what I'm doing wrong? |
Best guess: you aren't doing anything wrong. Most likely it's just a case
of the adapter code being incomplete, since the web UI is using an older
version of the adapter than cargo-semver-checks does. I need to update it
and also update the rustdoc format used for the demo.
Currently away from my computer for a few hours, I'll check for sure when I
get back.
…On Sun, Jun 4, 2023, 5:36 AM エリアス ***@***.***> wrote:
I do have a question, I'm using the playground to understand better the
information available on Trait. But I cannot get any data from it, for
example if I try:
query {
Crate {
item {
... on Trait {
name @output
docs @output
crate_id @output
span {
filename @output
first_line: begin_line @output
}
}
}
}
}
My output is []. But from what I can see, all the attributes I'm looking
for are present at the Schema. Also, if I change Trait to Struct I do get
some data. I tried the query against this crate:
https://docs.rs/http/0.2.8/http/all.html, which has two traits.
Do you know what I'm doing wrong?
—
Reply to this email directly, view it on GitHub
<#232 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAR5MSVO4HFXAOSQJKIDCZTXJRJKJANCNFSM6AAAAAATCZOCJ4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Confirmed. Just a severely outdated and incomplete implementation. I'll see if I can upgrade it to something more feature-complete and modern in the next few days :) |
Thank you for checking I was not crazy about the queries. I tried a bit locally and I think I understand how things are working on that side. I started looking at the code for the Adapter. For exposing the information about the supertrait. If I understood it correctly this information is on "0:4:1601": {
"id": "0:4:1601",
"crate_id": 0,
"bounds": [
{
"trait_bound": {
"trait": {
"name": "supertrait",
"id": "0:3:1600",
"args": {
"angle_bracketed": {
"args": [],
"bindings": []
}
}
},
"generic_params": [],
"modifier": "none"
}
}
],
"implementations": []
}
}, for something like: pub trait supertrait {}
pub trait base_trait : supertrait {} So I think the schema outcome would be:
(Please tell me any modification you want on the structure) Based on that, I believe I need to modify a couple of things in the adapter:
My main question is how to "iterate" on the |
Sorry for the delay. I suggested trying this issue precisely because I was hoping it would create exactly this kind of learning opportunity. Trustfall is unusual in the amount of flexibility it provides us to build a more pleasant representation than what the underlying format provides. Check this out! Rustdoc JSON uses a Let's ignore rustdoc JSON's structure for a second, and just think about Rust. The following is valid Rust: pub trait Supertrait<T> { ... }
pub trait MyTrait : Supertrait<i64> { ... } How might we represent this in a Trustfall schema? As you've already observed, our The And What if Even if we try something really complex, like: pub trait Bar<'a> {}
pub trait Foo<'a> : for<'b> Bar<'b> + 'a {} this design still holds up: So with this design, all we're adding is a new Does this make sense? Last night I also updated the playground to use the same adapter code as I didn't quite understand the question about iterating on |
Re-reading this, I feel like I did an B- job of explaining. It's hard! 😅 Let me try to find you some code from a prior schema addition, perhaps that will be more helpful. Try this one, it adds a I've since refactored the adapter code a bit, so the code from that PR ended up here now: https://github.com/obi1kenobi/trustfall-rustdoc-adapter/blob/rustdoc-v26/src/adapter/edges.rs#L199-L230 |
The explanation was perfect! I was actually expecting the changes to be more complex, so I thought I was missing something, but using Thank you! |
Example of why this is breaking: say we removed the
DerefMut: Deref
supertrait relationship. Then, this code would break:h/t https://twitter.com/i2talics/status/1559607755975057408
The text was updated successfully, but these errors were encountered: