From abac87c2f891c48ac0652e343d58642a88cc165f Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 8 Sep 2025 02:23:33 -0700 Subject: [PATCH] tests: Fix doctests in crates/component (#37716) Previously, `cargo test --package component` failed due to missing imports for a doctest: ``` Doc-tests component running 1 test test crates/component/src/component.rs - Component::description (line 229) ... FAILED failures: ---- crates/component/src/component.rs - Component::description (line 229) stdout ---- error: cannot find derive macro `Documented` in this scope --> crates/component/src/component.rs:231:10 | 4 | #[derive(Documented)] | ^^^^^^^^^^ error[E0599]: no associated item named `DOCS` found for struct `MyComponent` in the current scope --> crates/component/src/component.rs:236:20 | 5 | struct MyComponent; | ------------------ associated item `DOCS` not found for this struct ... 9 | Some(Self::DOCS) | ^^^^ associated item not found in `MyComponent` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0599`. Couldn't compile the test. failures: crates/component/src/component.rs - Component::description (line 229) test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.29s error: doctest failed, to rerun pass `-p component --doc` bobcat ~/src/zed (doctests) 18:33 ``` This might be unnoticed if you mostly run nextest, as it does not run doctests. Release Notes: - N/A --- Cargo.lock | 1 + crates/component/Cargo.toml | 3 +++ crates/component/src/component.rs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index dbcea05ea9bc52288defc8c299d82eb508337544..5ca8375fef2c1e631f820bae88710a328bc02ebe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3515,6 +3515,7 @@ name = "component" version = "0.1.0" dependencies = [ "collections", + "documented", "gpui", "inventory", "parking_lot", diff --git a/crates/component/Cargo.toml b/crates/component/Cargo.toml index 92249de454d7140343cc6f814f6ac1bd99685cda..74481834f1cab5047dec3cd32121eb002fabbbbd 100644 --- a/crates/component/Cargo.toml +++ b/crates/component/Cargo.toml @@ -20,5 +20,8 @@ strum.workspace = true theme.workspace = true workspace-hack.workspace = true +[dev-dependencies] +documented.workspace = true + [features] default = [] diff --git a/crates/component/src/component.rs b/crates/component/src/component.rs index 0c05ba4a97f4598e9f7982cbc294831a955f1fc6..8c7b7ea4d7347ff087c84880c31df5d355870f65 100644 --- a/crates/component/src/component.rs +++ b/crates/component/src/component.rs @@ -227,6 +227,8 @@ pub trait Component { /// Example: /// /// ``` + /// use documented::Documented; + /// /// /// This is a doc comment. /// #[derive(Documented)] /// struct MyComponent;