mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
Update generated lint definitions
This commit is contained in:
parent
90682c393d
commit
9b3e912d67
8 changed files with 1040 additions and 812 deletions
|
@ -1,4 +1,4 @@
|
|||
//! Generated by `sourcegen_assists_docs`, do not edit by hand.
|
||||
//! Generated by `cargo codegen assists-doc-tests`, do not edit by hand.
|
||||
|
||||
use super::check_doc_test;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -18,6 +18,7 @@ impl flags::Codegen {
|
|||
flags::CodegenType::All => {
|
||||
diagnostics_docs::generate(self.check);
|
||||
assists_doc_tests::generate(self.check);
|
||||
// diagnostics_docs::generate(self.check) doesn't generate any tests
|
||||
// lints::generate(self.check) Updating clones the rust repo, so don't run it unless
|
||||
// explicitly asked for
|
||||
}
|
||||
|
@ -175,7 +176,8 @@ fn reformat(text: String) -> String {
|
|||
}
|
||||
|
||||
fn add_preamble(generator: &'static str, mut text: String) -> String {
|
||||
let preamble = format!("//! Generated by `{generator}`, do not edit by hand.\n\n");
|
||||
let preamble =
|
||||
format!("//! Generated by `cargo codegen {generator}`, do not edit by hand.\n\n");
|
||||
text.insert_str(0, &preamble);
|
||||
text
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ r#####"
|
|||
buf.push_str(&test)
|
||||
}
|
||||
}
|
||||
let buf = add_preamble("sourcegen_assists_docs", reformat(buf));
|
||||
let buf = add_preamble("assists-doc-tests", reformat(buf));
|
||||
ensure_file_contents(
|
||||
&project_root().join("crates/ide-assists/src/tests/generated.rs"),
|
||||
&buf,
|
||||
|
|
|
@ -12,7 +12,7 @@ pub(crate) fn generate(check: bool) {
|
|||
if !check {
|
||||
let contents =
|
||||
diagnostics.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
|
||||
let contents = add_preamble("sourcegen_diagnostic_docs", contents);
|
||||
let contents = add_preamble("diagnostics-docs", contents);
|
||||
let dst = project_root().join("docs/user/generated_diagnostic.adoc");
|
||||
fs::write(dst, contents).unwrap();
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ fn generate_tokens(grammar: &AstSrc) -> String {
|
|||
});
|
||||
|
||||
add_preamble(
|
||||
"sourcegen_ast",
|
||||
"grammar",
|
||||
reformat(
|
||||
quote! {
|
||||
use crate::{SyntaxKind::{self, *}, SyntaxToken, ast::AstToken};
|
||||
|
@ -328,7 +328,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
let res = add_preamble("sourcegen_ast", reformat(res));
|
||||
let res = add_preamble("grammar", reformat(res));
|
||||
res.replace("#[derive", "\n#[derive")
|
||||
}
|
||||
|
||||
|
@ -458,7 +458,7 @@ fn generate_syntax_kinds(grammar: KindsSrc<'_>) -> String {
|
|||
}
|
||||
};
|
||||
|
||||
add_preamble("sourcegen_ast", reformat(ast.to_string()))
|
||||
add_preamble("grammar", reformat(ast.to_string()))
|
||||
}
|
||||
|
||||
fn to_upper_snake_case(s: &str) -> String {
|
||||
|
|
|
@ -28,7 +28,7 @@ pub(crate) fn generate(check: bool) {
|
|||
cmd!(
|
||||
sh,
|
||||
"git -C {rust_repo} submodule update --init --recursive --depth=1 --
|
||||
compiler library src/tools"
|
||||
compiler library src/tools src/doc/book"
|
||||
)
|
||||
.run()
|
||||
.unwrap();
|
||||
|
@ -73,7 +73,7 @@ pub struct LintGroup {
|
|||
.unwrap();
|
||||
generate_descriptor_clippy(&mut contents, &lints_json);
|
||||
|
||||
let contents = add_preamble("sourcegen_lints", reformat(contents));
|
||||
let contents = add_preamble("lint-definitions", reformat(contents));
|
||||
|
||||
let destination = project_root().join(DESTINATION);
|
||||
ensure_file_contents(destination.as_path(), &contents, check);
|
||||
|
|
|
@ -195,7 +195,7 @@ impl FromStr for CodegenType {
|
|||
"grammar" => Ok(Self::Grammar),
|
||||
"assists-doc-tests" => Ok(Self::AssistsDocTests),
|
||||
"diagnostics-docs" => Ok(Self::DiagnosticsDocs),
|
||||
"lints-definitions" => Ok(Self::LintDefinitions),
|
||||
"lint-definitions" => Ok(Self::LintDefinitions),
|
||||
_ => Err("Invalid option".to_owned()),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue