-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
unused_imports
lint help on module named tests_*
too assertive and potentially confusing
#121502
Comments
unused_imports
lint help on module name tests_*
too assertive and potentially confusingunused_imports
lint help on module named tests_*
too assertive and potentially confusing
How can i proceed to solve this any suggestions on how can it be done changes to which file will make it happen since i am new to this repo |
Hi @Redidacove, thank you for your interest. For now, I think making the help message less assertive would be sufficient. Here are some tips to get you started:
You can identify where this help message is coming from by grepping the repo, i.e. $ rg --no-ignore --fixed-strings "consider adding a `#[cfg(test)]` to the containing module" compiler
compiler/rustc_lint/src/context/diagnostics.rs
111: "consider adding a `#[cfg(test)]` to the containing module",
https://rustc-dev-guide.rust-lang.org/ is the more in-depth reference. If you are stuck, feel free to ask here, or make a new thread in |
@rustbot claim |
(Unless @Redidacove already submitted a change and I didn't find it, I should be able to create a PR soon) |
…aelwoerister make unused_imports less assertive in test modules closes rust-lang#121502 This is a fairly small change and I used the fix suggested in the example expected error message. Not sure if I should've rather used the alternatives but this one seems the most descriptive. Some alternatives: - if this is meant to be a test module, add `#[cfg(test)]` to the containing module - try adding #[cfg(test)] to this test module - consider adding #[allow(unused_imports)] if you want to silent the lint on the unused import - consider removing the unused import
Rollup merge of rust-lang#121580 - Suyashtnt:issue-121502-fix, r=michaelwoerister make unused_imports less assertive in test modules closes rust-lang#121502 This is a fairly small change and I used the fix suggested in the example expected error message. Not sure if I should've rather used the alternatives but this one seems the most descriptive. Some alternatives: - if this is meant to be a test module, add `#[cfg(test)]` to the containing module - try adding #[cfg(test)] to this test module - consider adding #[allow(unused_imports)] if you want to silent the lint on the unused import - consider removing the unused import
Code
Current output
Desired output
Rationale and extra context
This help message seems weird. I'd expect the help to be more like:
#[allow(unused_imports)]
if you want to silent the lint on the unused importSuggesting to add
#[cfg(test)]
to the module is the least expected option, and it seems too assertive in its current wording.Other cases
No response
Rust Version
Anything else?
Perhaps the detection for triggering
#[cfg(test)]
on the module could be smarter and only consider a module as a potential test module if it contains at least one#[test]
annotated function?The text was updated successfully, but these errors were encountered: