-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
reproducer: fails to query trait imported from a dependecy #333
Open
oknozor
wants to merge
1
commit into
obi1kenobi:rustdoc-v29
Choose a base branch
from
oknozor:rustdoc-v29
base: rustdoc-v29
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "dummy_ext" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub trait DummyExternalTrait { | ||
fn do_something(&self); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note how only rustdoc from
impl_for_ref
is included in the adapter. Nodummy_ext
rustdoc is loaded, so it's as if none of its types exist from the perspective of theRustdocAdapter
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know the internals but that's not entirely true.
I have two reference to the external trait in the rustdoc json generated for
impl_for_ref
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am puzzled. I turned to whole thing into a static mutable, add added this to the test and now it passes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is that the actual definition of item
20:3:2305
AKADummyExternalTrait
is not present in the file: we don't know its attributes, its doc comment, its items, etc. We just know it as a foreign item from an unknown version of a crate calleddummy_ext
.With the approach you propose, queries like the following will produce unexpected results: playground
It will claim that the implemented
DummyExternalTrait
trait is not actually importable from other crates (obviously false — it's implemented by a type in another crate!), because the data to determine its import paths was not present.That sounds like a pretty serious footgun to me — one made even more unpredictable and dangerous if we add
add_manual_trait_item()
to the crate's public API. This is why I'd love to hear more about your use case — there may be a less footgun-y way to accomplish what you're after.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am trying to generate automated documentation for the zed editor actions (those are struct implementing the
Action
trait spread across several crates in a cargo workspace).I could probably parse everything with syn but I was curious about trustfall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that use case, is it guaranteed that you'll have at most one major version of each crate you are querying in the workspace? (This isn't true in general, for example it isn't true when semver-checking
cargo-semver-checks
.)If that's the case, you should be able to accomplish the goal with Trustfall in a better (but slightly more work) way: you could generate the rustdoc for all the crates, and use the external item description
to then look up the item in the other rustdoc using the import path index: crate
dummy_ext
import pathdummy_ext::DummyExternalTrait
.Such a prototype would lay the groundwork for
trustfall-rustdoc-adapter
supporting cross-crate querying once the compiler MCP is approved and the rustdoc linking limitation is lifted. I'd love to see it and if you're interested in building it, I'd love to support you in it.But I totally understand if that sounds like too much work, and you'd prefer to just fork the crate and make the
add_manual_trait_item()
function public in your build.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will give a try, this sound like a lot of fun! I'll let you know if I need your help later.
Thanks a lot for the help so far !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Always happy to help :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I wanted to check in and see how you're doing on this. Are you still working on the prototype, or did something else take priority? Anything I can do to help you along?