aboutsummaryrefslogtreecommitdiff
path: root/xtask
diff options
context:
space:
mode:
Diffstat (limited to 'xtask')
-rw-r--r--xtask/src/codegen.rs43
-rw-r--r--xtask/src/flags.rs10
-rw-r--r--xtask/src/main.rs1
-rw-r--r--xtask/src/release.rs5
-rw-r--r--xtask/src/tidy.rs21
5 files changed, 35 insertions, 45 deletions
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs
index e3f9ccada..7cdd8f251 100644
--- a/xtask/src/codegen.rs
+++ b/xtask/src/codegen.rs
@@ -7,9 +7,9 @@
7 7
8mod gen_syntax; 8mod gen_syntax;
9mod gen_parser_tests; 9mod gen_parser_tests;
10mod gen_lint_completions;
10mod gen_assists_docs; 11mod gen_assists_docs;
11mod gen_feature_docs; 12mod gen_feature_docs;
12mod gen_lint_completions;
13mod gen_diagnostic_docs; 13mod gen_diagnostic_docs;
14 14
15use std::{ 15use std::{
@@ -18,38 +18,35 @@ use std::{
18}; 18};
19use xshell::{cmd, pushenv, read_file, write_file}; 19use xshell::{cmd, pushenv, read_file, write_file};
20 20
21use crate::{ensure_rustfmt, flags, project_root, Result}; 21use crate::{ensure_rustfmt, project_root, Result};
22 22
23pub(crate) use self::{ 23pub(crate) use self::{
24 gen_assists_docs::{generate_assists_docs, generate_assists_tests}, 24 gen_assists_docs::generate_assists_tests, gen_lint_completions::generate_lint_completions,
25 gen_diagnostic_docs::generate_diagnostic_docs, 25 gen_parser_tests::generate_parser_tests, gen_syntax::generate_syntax,
26 gen_feature_docs::generate_feature_docs,
27 gen_lint_completions::generate_lint_completions,
28 gen_parser_tests::generate_parser_tests,
29 gen_syntax::generate_syntax,
30}; 26};
31 27
28pub(crate) fn docs() -> Result<()> {
29 // We don't commit docs to the repo, so we can just overwrite them.
30 gen_assists_docs::generate_assists_docs(Mode::Overwrite)?;
31 gen_feature_docs::generate_feature_docs(Mode::Overwrite)?;
32 gen_diagnostic_docs::generate_diagnostic_docs(Mode::Overwrite)?;
33 Ok(())
34}
35
36#[allow(unused)]
37fn used() {
38 generate_parser_tests(Mode::Overwrite);
39 generate_assists_tests(Mode::Overwrite);
40 generate_syntax(Mode::Overwrite);
41 generate_lint_completions(Mode::Overwrite);
42}
43
32#[derive(Debug, PartialEq, Eq, Clone, Copy)] 44#[derive(Debug, PartialEq, Eq, Clone, Copy)]
33pub(crate) enum Mode { 45pub(crate) enum Mode {
34 Overwrite, 46 Overwrite,
35 Ensure, 47 Ensure,
36} 48}
37 49
38impl flags::Codegen {
39 pub(crate) fn run(self) -> Result<()> {
40 if self.features {
41 generate_lint_completions(Mode::Overwrite)?;
42 }
43 generate_syntax(Mode::Overwrite)?;
44 generate_parser_tests(Mode::Overwrite)?;
45 generate_assists_tests(Mode::Overwrite)?;
46 generate_assists_docs(Mode::Overwrite)?;
47 generate_feature_docs(Mode::Overwrite)?;
48 generate_diagnostic_docs(Mode::Overwrite)?;
49 Ok(())
50 }
51}
52
53/// A helper to update file on disk if it has changed. 50/// A helper to update file on disk if it has changed.
54/// With verify = false, 51/// With verify = false,
55fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> { 52fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
diff --git a/xtask/src/flags.rs b/xtask/src/flags.rs
index b39d937ca..48d1ad45e 100644
--- a/xtask/src/flags.rs
+++ b/xtask/src/flags.rs
@@ -27,10 +27,6 @@ xflags::xflags! {
27 optional --jemalloc 27 optional --jemalloc
28 } 28 }
29 29
30 cmd codegen {
31 optional --features
32 }
33
34 cmd lint {} 30 cmd lint {}
35 cmd fuzz-tests {} 31 cmd fuzz-tests {}
36 cmd pre-cache {} 32 cmd pre-cache {}
@@ -67,7 +63,6 @@ pub struct Xtask {
67pub enum XtaskCmd { 63pub enum XtaskCmd {
68 Help(Help), 64 Help(Help),
69 Install(Install), 65 Install(Install),
70 Codegen(Codegen),
71 Lint(Lint), 66 Lint(Lint),
72 FuzzTests(FuzzTests), 67 FuzzTests(FuzzTests),
73 PreCache(PreCache), 68 PreCache(PreCache),
@@ -93,11 +88,6 @@ pub struct Install {
93} 88}
94 89
95#[derive(Debug)] 90#[derive(Debug)]
96pub struct Codegen {
97 pub features: bool,
98}
99
100#[derive(Debug)]
101pub struct Lint; 91pub struct Lint;
102 92
103#[derive(Debug)] 93#[derive(Debug)]
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index 25fd32f92..c2dda928e 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -40,7 +40,6 @@ fn main() -> Result<()> {
40 return Ok(()); 40 return Ok(());
41 } 41 }
42 flags::XtaskCmd::Install(cmd) => cmd.run(), 42 flags::XtaskCmd::Install(cmd) => cmd.run(),
43 flags::XtaskCmd::Codegen(cmd) => cmd.run(),
44 flags::XtaskCmd::Lint(_) => run_clippy(), 43 flags::XtaskCmd::Lint(_) => run_clippy(),
45 flags::XtaskCmd::FuzzTests(_) => run_fuzzer(), 44 flags::XtaskCmd::FuzzTests(_) => run_fuzzer(),
46 flags::XtaskCmd::PreCache(cmd) => cmd.run(), 45 flags::XtaskCmd::PreCache(cmd) => cmd.run(),
diff --git a/xtask/src/release.rs b/xtask/src/release.rs
index d8d86fd63..dde5d14ee 100644
--- a/xtask/src/release.rs
+++ b/xtask/src/release.rs
@@ -2,7 +2,7 @@ use std::fmt::Write;
2 2
3use xshell::{cmd, cp, pushd, read_dir, write_file}; 3use xshell::{cmd, cp, pushd, read_dir, write_file};
4 4
5use crate::{codegen, date_iso, flags, is_release_tag, project_root, Mode, Result}; 5use crate::{codegen, date_iso, flags, is_release_tag, project_root, Result};
6 6
7impl flags::Release { 7impl flags::Release {
8 pub(crate) fn run(self) -> Result<()> { 8 pub(crate) fn run(self) -> Result<()> {
@@ -12,8 +12,7 @@ impl flags::Release {
12 cmd!("git reset --hard tags/nightly").run()?; 12 cmd!("git reset --hard tags/nightly").run()?;
13 cmd!("git push").run()?; 13 cmd!("git push").run()?;
14 } 14 }
15 codegen::generate_assists_docs(Mode::Overwrite)?; 15 codegen::docs()?;
16 codegen::generate_feature_docs(Mode::Overwrite)?;
17 16
18 let website_root = project_root().join("../rust-analyzer.github.io"); 17 let website_root = project_root().join("../rust-analyzer.github.io");
19 let changelog_dir = website_root.join("./thisweek/_posts"); 18 let changelog_dir = website_root.join("./thisweek/_posts");
diff --git a/xtask/src/tidy.rs b/xtask/src/tidy.rs
index 3818b9e0f..03b4c0092 100644
--- a/xtask/src/tidy.rs
+++ b/xtask/src/tidy.rs
@@ -12,31 +12,36 @@ use crate::{
12}; 12};
13 13
14#[test] 14#[test]
15fn generated_grammar_is_fresh() { 15fn generate_grammar() {
16 codegen::generate_syntax(Mode::Ensure).unwrap() 16 codegen::generate_syntax(Mode::Ensure).unwrap()
17} 17}
18 18
19#[test] 19#[test]
20fn generated_tests_are_fresh() { 20fn generate_parser_tests() {
21 codegen::generate_parser_tests(Mode::Ensure).unwrap() 21 codegen::generate_parser_tests(Mode::Ensure).unwrap()
22} 22}
23 23
24#[test] 24#[test]
25fn generated_assists_are_fresh() { 25fn generate_assists_tests() {
26 codegen::generate_assists_tests(Mode::Ensure).unwrap(); 26 codegen::generate_assists_tests(Mode::Ensure).unwrap();
27} 27}
28 28
29/// This clones rustc repo, and so is not worth to keep up-to-date. We update
30/// manually by un-ignoring the test from time to time.
31#[test]
32#[ignore]
33fn generate_lint_completions() {
34 codegen::generate_lint_completions(Mode::Overwrite).unwrap()
35}
36
29#[test] 37#[test]
30fn check_code_formatting() { 38fn check_code_formatting() {
31 run_rustfmt(Mode::Ensure).unwrap() 39 run_rustfmt(Mode::Ensure).unwrap()
32} 40}
33 41
34#[test] 42#[test]
35fn smoke_test_docs_generation() { 43fn smoke_test_generate_documentation() {
36 // We don't commit docs to the repo, so we can just overwrite in tests. 44 codegen::docs().unwrap()
37 codegen::generate_assists_docs(Mode::Overwrite).unwrap();
38 codegen::generate_feature_docs(Mode::Overwrite).unwrap();
39 codegen::generate_diagnostic_docs(Mode::Overwrite).unwrap();
40} 45}
41 46
42#[test] 47#[test]