Skip to content
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

pub trait moved, deleted, or renamed #73

Closed
Tracked by #5
obi1kenobi opened this issue Aug 16, 2022 · 2 comments · Fixed by #230
Closed
Tracked by #5

pub trait moved, deleted, or renamed #73

obi1kenobi opened this issue Aug 16, 2022 · 2 comments · Fixed by #230
Labels
A-lint Area: new or existing lint C-enhancement Category: raise the bar on expectations E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: Mentorship is available for this issue.

Comments

@obi1kenobi
Copy link
Owner

No description provided.

@obi1kenobi obi1kenobi added A-lint Area: new or existing lint E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: Mentorship is available for this issue. C-enhancement Category: raise the bar on expectations labels Aug 16, 2022
@seanchen1991
Copy link

Hi, I'm interested in taking on this issue.

As per this point in CONTRIBUTING.md:

try to identify a related lint that is already implemented and relies on similar information

What's the most closely-related lint that I could reference for this? Also, is there any documentation on the query syntax?

@obi1kenobi
Copy link
Owner Author

obi1kenobi commented Aug 30, 2022

Great choice! There are several very related lints:

There are some resources for using the query language, but I'd recommend using them as a reference rather than as a "getting started" guide: look up what you need when you need it, rather than reading them end-to-end first.

  • The query language is from the Trustfall project. The docs are sadly still lacking, but I'll walk you through the functionality used here.
  • The syntax is also very related (very minor tweaks) to my prior GraphQL compiler project which has a fairly extensive reference. The biggest differences are that the filter and output directives' arguments in Trustfall have shorter, more convenient names (op_name -> op, out_name -> name).

As a first step, I'd recommend trying to write just the new query; we can add the error message text, test case, etc. afterward. I'd recommend copy-pasting the query text out of those files and into files where you can enable GraphQL syntax highlighting:
image

Look for similarities between the queries. You'll notice that they are nearly identical, with minute differences. They all say the following:

  • Given a CrateDiff comparison across crate versions, look in the baseline version for items that are specifically <enum/struct/fn>, which are public ($public is a query argument, defined in the file to have value "public"), and select some of their properties for output (@output) and for later filtering (@tag).
  • Then, look in the current version for a matching item (enum/struct/fn), also public, whose name matches the earlier one (%name refers to name @tag from before), and which is importable via the same path as in the baseline (again, %path refers to path @tag from earlier).
  • The current @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) part means "aggregate all such matching current data into a list, then ensure its element count is zero -- an empty list. When we don't find any matching current items, that item must have been moved, deleted, or renamed, which is what we are looking for.
  • span @optional means "include span information if available, but leave it None otherwise rather than discarding from the search all items lacking span information.

This is very similar to what we'll need for traits as well: traits are items too, just like enums and structs and functions. The queryable schema is here if you'd like to check which properties, edges, or types exist: https://github.com/obi1kenobi/cargo-semver-check/blob/main/src/rustdoc_schema.graphql

Ping me with any questions! Happy to hop on a video call if that would make it easier to get started, and I'm also in the rust-lang zulip if you'd prefer more interactive text chat.

I'm also working with a few friends on a WASM-powered web editor for Trustfall queries with all the modern conveniences (autocomplete, syntax highlighting, etc.), stay tuned! 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: new or existing lint C-enhancement Category: raise the bar on expectations E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: Mentorship is available for this issue.
Projects
None yet
2 participants