Rollup merge of #91770 - TaKO8Ki:suggest-adding-cfg-test, r=joshtriplett
Suggest adding a `#[cfg(test)]` to to a test module closes #88138
This commit is contained in:
commit
790950a530
6 changed files with 264 additions and 4 deletions
|
@ -661,7 +661,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,
|
||||
|
@ -669,6 +669,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