Skip to content

Commit 7f8dfc4

Browse files
committed
Make utils module private.
1 parent c262bdb commit 7f8dfc4

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

clippy_dev/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
)]
1717
#![allow(clippy::missing_panics_doc)]
1818

19-
// The `rustc_driver` crate seems to be required in order to use the `rust_lexer` crate.
20-
#[allow(unused_extern_crates)]
19+
#[expect(unused_extern_crates, reason = "required to link to rustc crates")]
2120
extern crate rustc_driver;
2221
extern crate rustc_lexer;
2322
extern crate rustc_literal_escaper;
@@ -33,4 +32,6 @@ pub mod serve;
3332
pub mod setup;
3433
pub mod sync;
3534
pub mod update_lints;
36-
pub mod utils;
35+
36+
mod utils;
37+
pub use utils::{ClippyInfo, UpdateMode};

clippy_dev/src/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
use clap::{Args, Parser, Subcommand};
66
use clippy_dev::{
7-
deprecate_lint, dogfood, fmt, lint, new_lint, release, rename_lint, serve, setup, sync, update_lints, utils,
7+
ClippyInfo, UpdateMode, deprecate_lint, dogfood, fmt, lint, new_lint, release, rename_lint, serve, setup, sync,
8+
update_lints,
89
};
910
use std::convert::Infallible;
1011
use std::env;
1112

1213
fn main() {
1314
let dev = Dev::parse();
14-
let clippy = utils::ClippyInfo::search_for_manifest();
15+
let clippy = ClippyInfo::search_for_manifest();
1516
if let Err(e) = env::set_current_dir(&clippy.path) {
1617
panic!("error setting current directory to `{}`: {e}", clippy.path.display());
1718
}
@@ -26,16 +27,16 @@ fn main() {
2627
allow_staged,
2728
allow_no_vcs,
2829
} => dogfood::dogfood(fix, allow_dirty, allow_staged, allow_no_vcs),
29-
DevCommand::Fmt { check } => fmt::run(utils::UpdateMode::from_check(check)),
30-
DevCommand::UpdateLints { check } => update_lints::update(utils::UpdateMode::from_check(check)),
30+
DevCommand::Fmt { check } => fmt::run(UpdateMode::from_check(check)),
31+
DevCommand::UpdateLints { check } => update_lints::update(UpdateMode::from_check(check)),
3132
DevCommand::NewLint {
3233
pass,
3334
name,
3435
category,
3536
r#type,
3637
msrv,
3738
} => match new_lint::create(clippy.version, pass, &name, &category, r#type.as_deref(), msrv) {
38-
Ok(()) => update_lints::update(utils::UpdateMode::Change),
39+
Ok(()) => update_lints::update(UpdateMode::Change),
3940
Err(e) => eprintln!("Unable to create lint: {e}"),
4041
},
4142
DevCommand::Setup(SetupCommand { subcommand }) => match subcommand {

clippy_dev/src/utils.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ pub enum Token<'a> {
450450
OpenParen,
451451
Pound,
452452
Semi,
453-
Slash,
454453
}
455454

456455
pub struct RustSearcher<'txt> {
@@ -528,7 +527,6 @@ impl<'txt> RustSearcher<'txt> {
528527
| (Token::OpenParen, lexer::TokenKind::OpenParen)
529528
| (Token::Pound, lexer::TokenKind::Pound)
530529
| (Token::Semi, lexer::TokenKind::Semi)
531-
| (Token::Slash, lexer::TokenKind::Slash)
532530
| (
533531
Token::LitStr,
534532
lexer::TokenKind::Literal {
@@ -602,7 +600,6 @@ impl<'txt> RustSearcher<'txt> {
602600
}
603601

604602
#[track_caller]
605-
#[expect(clippy::must_use_candidate)]
606603
pub fn try_rename_file(old_name: &Path, new_name: &Path) -> bool {
607604
match OpenOptions::new().create_new(true).write(true).open(new_name) {
608605
Ok(file) => drop(file),
@@ -625,7 +622,6 @@ pub fn try_rename_file(old_name: &Path, new_name: &Path) -> bool {
625622
}
626623

627624
#[track_caller]
628-
#[expect(clippy::must_use_candidate)]
629625
pub fn try_rename_dir(old_name: &Path, new_name: &Path) -> bool {
630626
match fs::create_dir(new_name) {
631627
Ok(()) => {},
@@ -651,11 +647,6 @@ pub fn try_rename_dir(old_name: &Path, new_name: &Path) -> bool {
651647
}
652648
}
653649

654-
#[track_caller]
655-
pub fn write_file(path: &Path, contents: &str) {
656-
expect_action(fs::write(path, contents), ErrAction::Write, path);
657-
}
658-
659650
#[track_caller]
660651
pub fn run_exit_on_err(path: &(impl AsRef<Path> + ?Sized), cmd: &mut Command) {
661652
match expect_action(cmd.status(), ErrAction::Run, path.as_ref()).code() {
@@ -755,7 +746,6 @@ pub fn split_args_for_threads(
755746
}
756747

757748
#[track_caller]
758-
#[expect(clippy::must_use_candidate)]
759749
pub fn delete_file_if_exists(path: &Path) -> bool {
760750
match fs::remove_file(path) {
761751
Ok(()) => true,

0 commit comments

Comments
 (0)