Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--Cargo.lock1
-rw-r--r--crates/ide-assists/Cargo.toml3
-rw-r--r--crates/ide-diagnostics/Cargo.toml4
-rw-r--r--crates/ide/Cargo.toml3
-rw-r--r--crates/rust-analyzer/Cargo.toml1
-rw-r--r--xtask/src/codegen.rs1
-rw-r--r--xtask/src/codegen/diagnostics_docs.rs (renamed from crates/ide-diagnostics/src/tests/sourcegen.rs)28
7 files changed, 17 insertions, 24 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 9b431d85a6..45f4aa8911 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -747,7 +747,6 @@ dependencies = [
"itertools",
"once_cell",
"serde_json",
- "sourcegen",
"stdx",
"syntax",
"test-fixture",
diff --git a/crates/ide-assists/Cargo.toml b/crates/ide-assists/Cargo.toml
index a78129fc47..b1e7609afe 100644
--- a/crates/ide-assists/Cargo.toml
+++ b/crates/ide-assists/Cargo.toml
@@ -33,8 +33,5 @@ expect-test = "1.4.0"
test-utils.workspace = true
test-fixture.workspace = true
-[features]
-in-rust-tree = []
-
[lints]
workspace = true
diff --git a/crates/ide-diagnostics/Cargo.toml b/crates/ide-diagnostics/Cargo.toml
index 509c5a152f..8ccea99e9e 100644
--- a/crates/ide-diagnostics/Cargo.toml
+++ b/crates/ide-diagnostics/Cargo.toml
@@ -33,10 +33,6 @@ expect-test = "1.4.0"
# local deps
test-utils.workspace = true
test-fixture.workspace = true
-sourcegen.workspace = true
-
-[features]
-in-rust-tree = []
[lints]
workspace = true
diff --git a/crates/ide/Cargo.toml b/crates/ide/Cargo.toml
index bb06d61445..eab3925aab 100644
--- a/crates/ide/Cargo.toml
+++ b/crates/ide/Cargo.toml
@@ -51,8 +51,5 @@ expect-test = "1.4.0"
test-utils.workspace = true
test-fixture.workspace = true
-[features]
-in-rust-tree = ["ide-assists/in-rust-tree", "ide-diagnostics/in-rust-tree"]
-
[lints]
workspace = true
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml
index a212041e66..766606be7b 100644
--- a/crates/rust-analyzer/Cargo.toml
+++ b/crates/rust-analyzer/Cargo.toml
@@ -85,7 +85,6 @@ force-always-assert = ["always-assert/force"]
sysroot-abi = []
in-rust-tree = [
"sysroot-abi",
- "ide/in-rust-tree",
"syntax/in-rust-tree",
"parser/in-rust-tree",
"hir/in-rust-tree",
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs
index e579660ac9..d51daa3395 100644
--- a/xtask/src/codegen.rs
+++ b/xtask/src/codegen.rs
@@ -8,6 +8,7 @@ use xshell::{cmd, Shell};
use crate::{flags, project_root};
pub(crate) mod assists_doc_tests;
+pub(crate) mod diagnostics_docs;
impl flags::Codegen {
pub(crate) fn run(self, _sh: &Shell) -> anyhow::Result<()> {
diff --git a/crates/ide-diagnostics/src/tests/sourcegen.rs b/xtask/src/codegen/diagnostics_docs.rs
index 9e7fcfc590..a45b412fda 100644
--- a/crates/ide-diagnostics/src/tests/sourcegen.rs
+++ b/xtask/src/codegen/diagnostics_docs.rs
@@ -2,22 +2,26 @@
use std::{fmt, fs, io, path::PathBuf};
-use sourcegen::project_root;
+use crate::{
+ codegen::{add_preamble, list_rust_files, CommentBlock, Location},
+ project_root,
+};
-#[test]
-fn sourcegen_diagnostic_docs() {
+fn generate(check: bool) {
let diagnostics = Diagnostic::collect().unwrap();
- let contents =
- diagnostics.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
- let contents = sourcegen::add_preamble("sourcegen_diagnostic_docs", contents);
- let dst = project_root().join("docs/user/generated_diagnostic.adoc");
- fs::write(dst, contents).unwrap();
+ 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 dst = project_root().join("docs/user/generated_diagnostic.adoc");
+ fs::write(dst, contents).unwrap();
+ }
}
#[derive(Debug)]
struct Diagnostic {
id: String,
- location: sourcegen::Location,
+ location: Location,
doc: String,
}
@@ -26,7 +30,7 @@ impl Diagnostic {
let handlers_dir = project_root().join("crates/ide-diagnostics/src/handlers");
let mut res = Vec::new();
- for path in sourcegen::list_rust_files(&handlers_dir) {
+ for path in list_rust_files(&handlers_dir) {
collect_file(&mut res, path)?;
}
res.sort_by(|lhs, rhs| lhs.id.cmp(&rhs.id));
@@ -34,7 +38,7 @@ impl Diagnostic {
fn collect_file(acc: &mut Vec<Diagnostic>, path: PathBuf) -> io::Result<()> {
let text = fs::read_to_string(&path)?;
- let comment_blocks = sourcegen::CommentBlock::extract("Diagnostic", &text);
+ let comment_blocks = CommentBlock::extract("Diagnostic", &text);
for block in comment_blocks {
let id = block.id;
@@ -42,7 +46,7 @@ impl Diagnostic {
panic!("invalid diagnostic name: {id:?}:\n {msg}")
}
let doc = block.contents.join("\n");
- let location = sourcegen::Location { file: path.clone(), line: block.line };
+ let location = Location { file: path.clone(), line: block.line };
acc.push(Diagnostic { id, location, doc })
}