From 3868c39563df9e3c82a6fe1f8f6a95d53f0a582e Mon Sep 17 00:00:00 2001
From: Tejesh Vaish <188414140+tridev-tej@users.noreply.github.com>
Date: Sun, 25 Oct 2026 22:26:39 +0000
Subject: [PATCH] Document cfg(trybuild) for test cases
---
README.md | 7 +++++++
src/lib.rs | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/README.md b/README.md
index d0ecf7a..87b51e3 100644
--- a/README.md
+++ b/README.md
@@ -120,6 +120,13 @@ Pass tests are considered to succeed if they compile successfully and have a
That's the entire API.
+### Conditional compilation
+
+Trybuild sets `cfg(trybuild)` when compiling test cases. In a test case,
+use `#[cfg(trybuild)]` to include code in these compilations, or
+`#[cfg(not(trybuild))]` to exclude it. Trybuild does not set this cfg for
+the outer test harness that calls `TestCases`.
+
## Workflow
diff --git a/src/lib.rs b/src/lib.rs
index c6d06d0..05ed62d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -105,6 +105,13 @@
//!
//! That's the entire API.
//!
+//! ## Conditional compilation
+//!
+//! Trybuild sets `cfg(trybuild)` when compiling test cases. In a test case,
+//! use `#[cfg(trybuild)]` to include code in these compilations, or
+//! `#[cfg(not(trybuild))]` to exclude it. Trybuild does not set this cfg for
+//! the outer test harness that calls `TestCases`.
+//!
//!
//!
//! # Workflow