suggest adding a #[cfg(test)]
to test modules
remove a empty line import `module_to_string` use `contains("test")` show a suggestion in case module starts_with/ends_with "test" replace `parent` with `containing`
This commit is contained in:
parent
3ee016ae4d
commit
6f8ad6d83a
6 changed files with 264 additions and 4 deletions
|
@ -671,7 +671,7 @@ pub trait LintContext: Sized {
|
|||
BuiltinLintDiagnostics::UnknownCrateTypes(span, note, sugg) => {
|
||||
db.span_suggestion(span, ¬e, sugg, Applicability::MaybeIncorrect);
|
||||
}
|
||||
BuiltinLintDiagnostics::UnusedImports(message, replaces) => {
|
||||
BuiltinLintDiagnostics::UnusedImports(message, replaces, in_test_module) => {
|
||||
if !replaces.is_empty() {
|
||||
db.tool_only_multipart_suggestion(
|
||||
&message,
|
||||
|
@ -679,6 +679,14 @@ pub trait LintContext: Sized {
|
|||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(span) = in_test_module {
|
||||
let def_span = self.sess().source_map().guess_head_span(span);
|
||||
db.span_help(
|
||||
span.shrink_to_lo().to(def_span),
|
||||
"consider adding a `#[cfg(test)]` to the containing module",
|
||||
);
|
||||
}
|
||||
}
|
||||
BuiltinLintDiagnostics::RedundantImport(spans, ident) => {
|
||||
for (span, is_imported) in spans {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue