Skip to content

Commit 6f346c9

Browse files
committed
Re-implement tidy as an xtask action
1 parent d00f474 commit 6f346c9

File tree

12 files changed

+69
-60
lines changed

12 files changed

+69
-60
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/consteval/tests/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ fn floating_point() {
426426
true,
427427
)),
428428
);
429-
#[allow(unknown_lints, unnecessary_min_or_max)]
429+
#[allow(unknown_lints, clippy::unnecessary_min_or_max)]
430430
check_number(
431431
r#"
432432
extern "rust-intrinsic" {

src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@
1111
#![allow(clippy::disallowed_types)]
1212

1313
mod ratoml;
14-
#[cfg(not(feature = "in-rust-tree"))]
15-
mod sourcegen;
1614
mod support;
1715
mod testdir;
18-
mod tidy;
1916

2017
use std::{collections::HashMap, path::PathBuf, time::Instant};
2118

src/tools/rust-analyzer/xtask/src/codegen.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,36 +39,6 @@ impl flags::Codegen {
3939
}
4040
}
4141

42-
fn list_rust_files(dir: &Path) -> Vec<PathBuf> {
43-
let mut res = list_files(dir);
44-
res.retain(|it| {
45-
it.file_name().unwrap_or_default().to_str().unwrap_or_default().ends_with(".rs")
46-
});
47-
res
48-
}
49-
50-
fn list_files(dir: &Path) -> Vec<PathBuf> {
51-
let mut res = Vec::new();
52-
let mut work = vec![dir.to_path_buf()];
53-
while let Some(dir) = work.pop() {
54-
for entry in dir.read_dir().unwrap() {
55-
let entry = entry.unwrap();
56-
let file_type = entry.file_type().unwrap();
57-
let path = entry.path();
58-
let is_hidden =
59-
path.file_name().unwrap_or_default().to_str().unwrap_or_default().starts_with('.');
60-
if !is_hidden {
61-
if file_type.is_dir() {
62-
work.push(path);
63-
} else if file_type.is_file() {
64-
res.push(path);
65-
}
66-
}
67-
}
68-
}
69-
res
70-
}
71-
7242
#[derive(Clone)]
7343
pub(crate) struct CommentBlock {
7444
pub(crate) id: String,

src/tools/rust-analyzer/xtask/src/codegen/assists_doc_tests.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ use std::{fmt, fs, path::Path};
55
use stdx::format_to_acc;
66

77
use crate::{
8-
codegen::{
9-
add_preamble, ensure_file_contents, list_rust_files, reformat, CommentBlock, Location,
10-
},
8+
codegen::{add_preamble, ensure_file_contents, reformat, CommentBlock, Location},
119
project_root,
10+
util::list_rust_files,
1211
};
1312

1413
pub(crate) fn generate(check: bool) {

src/tools/rust-analyzer/xtask/src/codegen/diagnostics_docs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
use std::{fmt, fs, io, path::PathBuf};
44

55
use crate::{
6-
codegen::{add_preamble, list_rust_files, CommentBlock, Location},
6+
codegen::{add_preamble, CommentBlock, Location},
77
project_root,
8+
util::list_rust_files,
89
};
910

1011
pub(crate) fn generate(check: bool) {

src/tools/rust-analyzer/xtask/src/codegen/feature_docs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
use std::{fmt, fs, io, path::PathBuf};
44

55
use crate::{
6-
codegen::{list_rust_files, CommentBlock, Location},
6+
codegen::{CommentBlock, Location},
77
project_root,
8+
util::list_rust_files,
89
};
910

1011
pub(crate) fn generate(_check: bool) {

src/tools/rust-analyzer/xtask/src/codegen/lints.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ use stdx::format_to;
66
use xshell::{cmd, Shell};
77

88
use crate::{
9-
codegen::{add_preamble, ensure_file_contents, list_files, reformat},
9+
codegen::{add_preamble, ensure_file_contents, reformat},
1010
project_root,
11+
util::list_files,
1112
};
1213

1314
const DESTINATION: &str = "crates/ide-db/src/generated/lints.rs";

src/tools/rust-analyzer/xtask/src/codegen/parser_inline_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ use std::{
99
};
1010

1111
use crate::{
12-
codegen::{ensure_file_contents, list_rust_files, CommentBlock},
12+
codegen::{ensure_file_contents, CommentBlock},
1313
project_root,
14+
util::list_rust_files,
1415
};
1516

1617
pub(crate) fn generate(check: bool) {

src/tools/rust-analyzer/xtask/src/flags.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ xflags::xflags! {
7373
optional codegen_type: CodegenType
7474
optional --check
7575
}
76+
77+
cmd tidy {}
7678
}
7779
}
7880

@@ -96,8 +98,12 @@ pub enum XtaskCmd {
9698
Metrics(Metrics),
9799
Bb(Bb),
98100
Codegen(Codegen),
101+
Tidy(Tidy),
99102
}
100103

104+
#[derive(Debug)]
105+
pub struct Tidy {}
106+
101107
#[derive(Debug)]
102108
pub struct Install {
103109
pub client: bool,

src/tools/rust-analyzer/xtask/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ mod install;
1919
mod metrics;
2020
mod publish;
2121
mod release;
22+
mod tidy;
23+
mod util;
2224

2325
use anyhow::bail;
2426
use std::{env, path::PathBuf};
@@ -51,6 +53,7 @@ fn main() -> anyhow::Result<()> {
5153
)?;
5254
Ok(())
5355
}
56+
flags::XtaskCmd::Tidy(cmd) => cmd.run(sh),
5457
}
5558
}
5659

0 commit comments

Comments
 (0)