Skip to content

Commit 7dfc583

Browse files
committed
Update generated lint definitions
1 parent 20dc1b6 commit 7dfc583

File tree

8 files changed

+1041
-813
lines changed

8 files changed

+1041
-813
lines changed

src/tools/rust-analyzer/crates/ide-assists/src/tests/generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Generated by `sourcegen_assists_docs`, do not edit by hand.
1+
//! Generated by `cargo codegen assists-doc-tests`, do not edit by hand.
22
33
use super::check_doc_test;
44

src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs

Lines changed: 1029 additions & 803 deletions
Large diffs are not rendered by default.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ impl flags::Codegen {
1818
flags::CodegenType::All => {
1919
diagnostics_docs::generate(self.check);
2020
assists_doc_tests::generate(self.check);
21+
// diagnostics_docs::generate(self.check) doesn't generate any tests
2122
// lints::generate(self.check) Updating clones the rust repo, so don't run it unless
2223
// explicitly asked for
2324
}
@@ -175,7 +176,8 @@ fn reformat(text: String) -> String {
175176
}
176177

177178
fn add_preamble(generator: &'static str, mut text: String) -> String {
178-
let preamble = format!("//! Generated by `{generator}`, do not edit by hand.\n\n");
179+
let preamble =
180+
format!("//! Generated by `cargo codegen {generator}`, do not edit by hand.\n\n");
179181
text.insert_str(0, &preamble);
180182
text
181183
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ r#####"
4545
buf.push_str(&test)
4646
}
4747
}
48-
let buf = add_preamble("sourcegen_assists_docs", reformat(buf));
48+
let buf = add_preamble("assists-doc-tests", reformat(buf));
4949
ensure_file_contents(
5050
&project_root().join("crates/ide-assists/src/tests/generated.rs"),
5151
&buf,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub(crate) fn generate(check: bool) {
1212
if !check {
1313
let contents =
1414
diagnostics.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
15-
let contents = add_preamble("sourcegen_diagnostic_docs", contents);
15+
let contents = add_preamble("diagnostics-docs", contents);
1616
let dst = project_root().join("docs/user/generated_diagnostic.adoc");
1717
fs::write(dst, contents).unwrap();
1818
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn generate_tokens(grammar: &AstSrc) -> String {
6969
});
7070

7171
add_preamble(
72-
"sourcegen_ast",
72+
"grammar",
7373
reformat(
7474
quote! {
7575
use crate::{SyntaxKind::{self, *}, SyntaxToken, ast::AstToken};
@@ -328,7 +328,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> String {
328328
}
329329
}
330330

331-
let res = add_preamble("sourcegen_ast", reformat(res));
331+
let res = add_preamble("grammar", reformat(res));
332332
res.replace("#[derive", "\n#[derive")
333333
}
334334

@@ -458,7 +458,7 @@ fn generate_syntax_kinds(grammar: KindsSrc<'_>) -> String {
458458
}
459459
};
460460

461-
add_preamble("sourcegen_ast", reformat(ast.to_string()))
461+
add_preamble("grammar", reformat(ast.to_string()))
462462
}
463463

464464
fn to_upper_snake_case(s: &str) -> String {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) fn generate(check: bool) {
2828
cmd!(
2929
sh,
3030
"git -C {rust_repo} submodule update --init --recursive --depth=1 --
31-
compiler library src/tools"
31+
compiler library src/tools src/doc/book"
3232
)
3333
.run()
3434
.unwrap();
@@ -73,7 +73,7 @@ pub struct LintGroup {
7373
.unwrap();
7474
generate_descriptor_clippy(&mut contents, &lints_json);
7575

76-
let contents = add_preamble("sourcegen_lints", reformat(contents));
76+
let contents = add_preamble("lint-definitions", reformat(contents));
7777

7878
let destination = project_root().join(DESTINATION);
7979
ensure_file_contents(destination.as_path(), &contents, check);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl FromStr for CodegenType {
195195
"grammar" => Ok(Self::Grammar),
196196
"assists-doc-tests" => Ok(Self::AssistsDocTests),
197197
"diagnostics-docs" => Ok(Self::DiagnosticsDocs),
198-
"lints-definitions" => Ok(Self::LintDefinitions),
198+
"lint-definitions" => Ok(Self::LintDefinitions),
199199
_ => Err("Invalid option".to_owned()),
200200
}
201201
}

0 commit comments

Comments
 (0)