Skip to content

Commit

Permalink
also move module_style to span_lint_x functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacherr committed Nov 15, 2023
1 parent a86a570 commit 11881be
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions clippy_lints/src/module_style.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use clippy_utils::diagnostics::span_lint_and_help;
use rustc_ast::ast;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_lint::{EarlyContext, EarlyLintPass, Level, LintContext};
Expand Down Expand Up @@ -124,11 +125,13 @@ impl EarlyLintPass for ModStyle {
correct.pop();
correct.push(folder);
correct.push("mod.rs");
cx.struct_span_lint(
span_lint_and_help(
cx,
SELF_NAMED_MODULE_FILES,
Span::new(file.start_pos, file.start_pos, SyntaxContext::root(), None),
format!("`mod.rs` files are required, found `{}`", path.display()),
|lint| lint.help(format!("move `{}` to `{}`", path.display(), correct.display(),)),
&format!("`mod.rs` files are required, found `{}`", path.display()),
None,
&format!("move `{}` to `{}`", path.display(), correct.display(),),
);
}
}
Expand Down Expand Up @@ -162,11 +165,13 @@ fn check_self_named_mod_exists(cx: &EarlyContext<'_>, path: &Path, file: &Source
mod_file.pop();
mod_file.set_extension("rs");

cx.struct_span_lint(
span_lint_and_help(
cx,
MOD_MODULE_FILES,
Span::new(file.start_pos, file.start_pos, SyntaxContext::root(), None),
format!("`mod.rs` files are not allowed, found `{}`", path.display()),
|lint| lint.help(format!("move `{}` to `{}`", path.display(), mod_file.display())),
&format!("`mod.rs` files are not allowed, found `{}`", path.display()),
None,
&format!("move `{}` to `{}`", path.display(), mod_file.display()),
);
}
}

0 comments on commit 11881be

Please sign in to comment.