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

Need a way to verify that register_lints registers all workspace members #1533

Open
smoelius opened this issue Feb 19, 2025 · 4 comments
Open

Comments

@smoelius
Copy link
Collaborator

E.g., that this register_lints function registers all the supplementary workspace members:

pub fn register_lints(sess: &rustc_session::Session, lint_store: &mut rustc_lint::LintStore) {
// smoelius: Please keep the following `register_lints` calls sorted by crate name.
commented_code::register_lints(sess, lint_store);
escaping_doc_link::register_lints(sess, lint_store);
inconsistent_struct_pattern::register_lints(sess, lint_store);
redundant_reference::register_lints(sess, lint_store);
unnamed_constant::register_lints(sess, lint_store);
unnecessary_borrow_mut::register_lints(sess, lint_store);
unnecessary_conversion_for_trait::register_lints(sess, lint_store);
}

At the moment, I'm not sure how best to do this.

@augustin-v
Copy link
Contributor

I'd love to work on this! I'm guessing this is a function that would go to cargo-dylint/tests/ci.rs ?

@smoelius
Copy link
Collaborator Author

Yeah.

Do you have thoughts on how you would implement this?

The best idea I have come up with is:

  • Find each example library workspace (examples::iter might help with that).
  • Then, for each:
    • Extract the register_lints calls from the root package's src/lib.rs file using regular expressions.
    • Get the workspace's packages using cargo metadata.
    • Compare the extracted register_lints calls to the list of found packages.

I'm open to other ideas though.

Please be aware that something in Dylint broke with the upgrade to Rust 1.85. I need to investigate.

@augustin-v
Copy link
Contributor

That sounds very good and this made me realize that I forgot to add the nonexistent_path_in_comment to the lib.rs file.

  • Find each example library workspace (examples::iter might help with that).

This seems perfect for the task indeed, I was thinking about how we could fetch the examples with multiple workspaces before looking at it, and that does just that.

Definitely doable! Could I work on it?

@smoelius
Copy link
Collaborator Author

Definitely doable! Could I work on it?

Yes! Please!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants