Skip to content

Commit 9136814

Browse files
committed
Make utils module private.
1 parent e624b77 commit 9136814

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
@@ -434,7 +434,6 @@ pub enum Token<'a> {
434434
OpenParen,
435435
Pound,
436436
Semi,
437-
Slash,
438437
}
439438

440439
pub struct RustSearcher<'txt> {
@@ -512,7 +511,6 @@ impl<'txt> RustSearcher<'txt> {
512511
| (Token::OpenParen, lexer::TokenKind::OpenParen)
513512
| (Token::Pound, lexer::TokenKind::Pound)
514513
| (Token::Semi, lexer::TokenKind::Semi)
515-
| (Token::Slash, lexer::TokenKind::Slash)
516514
| (
517515
Token::LitStr,
518516
lexer::TokenKind::Literal {
@@ -586,7 +584,6 @@ impl<'txt> RustSearcher<'txt> {
586584
}
587585

588586
#[track_caller]
589-
#[expect(clippy::must_use_candidate)]
590587
pub fn try_rename_file(old_name: &Path, new_name: &Path) -> bool {
591588
match OpenOptions::new().create_new(true).write(true).open(new_name) {
592589
Ok(file) => drop(file),
@@ -609,7 +606,6 @@ pub fn try_rename_file(old_name: &Path, new_name: &Path) -> bool {
609606
}
610607

611608
#[track_caller]
612-
#[expect(clippy::must_use_candidate)]
613609
pub fn try_rename_dir(old_name: &Path, new_name: &Path) -> bool {
614610
match fs::create_dir(new_name) {
615611
Ok(()) => {},
@@ -635,11 +631,6 @@ pub fn try_rename_dir(old_name: &Path, new_name: &Path) -> bool {
635631
}
636632
}
637633

638-
#[track_caller]
639-
pub fn write_file(path: &Path, contents: &str) {
640-
expect_action(fs::write(path, contents), ErrAction::Write, path);
641-
}
642-
643634
#[track_caller]
644635
pub fn run_exit_on_err(path: &(impl AsRef<Path> + ?Sized), cmd: &mut Command) {
645636
match expect_action(cmd.status(), ErrAction::Run, path.as_ref()).code() {
@@ -739,7 +730,6 @@ pub fn split_args_for_threads(
739730
}
740731

741732
#[track_caller]
742-
#[expect(clippy::must_use_candidate)]
743733
pub fn delete_file_if_exists(path: &Path) -> bool {
744734
match fs::remove_file(path) {
745735
Ok(()) => true,

0 commit comments

Comments
 (0)