aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/codegen')
-rw-r--r--xtask/src/codegen/gen_lint_completions.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/xtask/src/codegen/gen_lint_completions.rs b/xtask/src/codegen/gen_lint_completions.rs
index 24dbc6a39..f5736d1b5 100644
--- a/xtask/src/codegen/gen_lint_completions.rs
+++ b/xtask/src/codegen/gen_lint_completions.rs
@@ -28,9 +28,9 @@ pub(crate) fn generate_lint_completions() -> Result<()> {
28} 28}
29 29
30fn generate_descriptor(buf: &mut String, src_dir: PathBuf) -> Result<()> { 30fn generate_descriptor(buf: &mut String, src_dir: PathBuf) -> Result<()> {
31 buf.push_str(r#"pub(super) const FEATURES: &[LintCompletion] = &["#); 31 buf.push_str(r#"pub const FEATURES: &[LintCompletion] = &["#);
32 buf.push('\n'); 32 buf.push('\n');
33 ["language-features", "library-features"] 33 let mut vec = ["language-features", "library-features"]
34 .iter() 34 .iter()
35 .flat_map(|it| WalkDir::new(src_dir.join(it))) 35 .flat_map(|it| WalkDir::new(src_dir.join(it)))
36 .filter_map(|e| e.ok()) 36 .filter_map(|e| e.ok())
@@ -38,13 +38,17 @@ fn generate_descriptor(buf: &mut String, src_dir: PathBuf) -> Result<()> {
38 // Get all `.md ` files 38 // Get all `.md ` files
39 entry.file_type().is_file() && entry.path().extension().unwrap_or_default() == "md" 39 entry.file_type().is_file() && entry.path().extension().unwrap_or_default() == "md"
40 }) 40 })
41 .for_each(|entry| { 41 .map(|entry| {
42 let path = entry.path(); 42 let path = entry.path();
43 let feature_ident = path.file_stem().unwrap().to_str().unwrap().replace("-", "_"); 43 let feature_ident = path.file_stem().unwrap().to_str().unwrap().replace("-", "_");
44 let doc = read_file(path).unwrap(); 44 let doc = read_file(path).unwrap();
45 45 (feature_ident, doc)
46 push_lint_completion(buf, &feature_ident, &doc); 46 })
47 }); 47 .collect::<Vec<_>>();
48 vec.sort_by(|(feature_ident, _), (feature_ident2, _)| feature_ident.cmp(feature_ident2));
49 vec.into_iter().for_each(|(feature_ident, doc)| {
50 push_lint_completion(buf, &feature_ident, &doc);
51 });
48 buf.push_str("];\n"); 52 buf.push_str("];\n");
49 Ok(()) 53 Ok(())
50} 54}
@@ -85,8 +89,8 @@ fn generate_descriptor_clippy(buf: &mut String, path: &Path) -> Result<()> {
85 .into(); 89 .into();
86 } 90 }
87 } 91 }
88 92 clippy_lints.sort_by(|lint, lint2| lint.id.cmp(&lint2.id));
89 buf.push_str(r#"pub(super) const CLIPPY_LINTS: &[LintCompletion] = &["#); 93 buf.push_str(r#"pub const CLIPPY_LINTS: &[LintCompletion] = &["#);
90 buf.push('\n'); 94 buf.push('\n');
91 clippy_lints.into_iter().for_each(|clippy_lint| { 95 clippy_lints.into_iter().for_each(|clippy_lint| {
92 let lint_ident = format!("clippy::{}", clippy_lint.id); 96 let lint_ident = format!("clippy::{}", clippy_lint.id);