Skip to content

Commit 1cb9e5d

Browse files
committed
docs: swap doc_auto_cfg with doc_cfg
In rust-lang/rust#138907, the `doc_auto_cfg` feature was subsumed by `doc_cfg`. This does overall look like we're on a path toward stabilization, which is great. One problem here though is that a bunch of crates use the `cfg` `docsrs` to enable `doc_auto_cfg`. So if we enable it, then it causes those crates to stop compiling. This is overall very annoying, and I don't know how to unfuck things. So I changed the `cfg` knob to `docsrs_regex` which, doesn't quite provide a guarantee, but gets us closer to being masters of our own destiny.
1 parent 0089034 commit 1cb9e5d

File tree

9 files changed

+103
-26
lines changed

9 files changed

+103
-26
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
rust: stable-x86_64-gnu
5656
steps:
5757
- name: Checkout repository
58-
uses: actions/checkout@v4
58+
uses: actions/checkout@v5
5959
- name: Install Rust
6060
uses: dtolnay/rust-toolchain@master
6161
with:
@@ -107,7 +107,7 @@ jobs:
107107
- s390x-unknown-linux-gnu
108108
steps:
109109
- name: Checkout repository
110-
uses: actions/checkout@v4
110+
uses: actions/checkout@v5
111111
- name: Install and configure Cross
112112
run: |
113113
# In the past, new releases of 'cross' have broken CI. So for now, we
@@ -142,7 +142,7 @@ jobs:
142142
runs-on: ubuntu-latest
143143
steps:
144144
- name: Checkout repository
145-
uses: actions/checkout@v4
145+
uses: actions/checkout@v5
146146
- name: Install Rust
147147
uses: dtolnay/rust-toolchain@master
148148
with:
@@ -152,6 +152,26 @@ jobs:
152152
- name: Build docs
153153
run: cargo doc --verbose
154154

155+
# This job checks the docsrs configuration.
156+
#
157+
# This is important because we enable `doc_cfg`, which is an unstable
158+
# feature that can (and has) broken.
159+
docsrs:
160+
runs-on: ubuntu-latest
161+
env:
162+
RUSTDOCFLAGS: "-D rustdoc::broken_intra_doc_links --cfg docsrs_regex"
163+
steps:
164+
- name: Checkout repository
165+
uses: actions/checkout@v5
166+
- name: Install Rust
167+
uses: dtolnay/rust-toolchain@master
168+
with:
169+
toolchain: nightly
170+
- name: Basic build
171+
run: cargo build --verbose
172+
- name: Build docs
173+
run: cargo doc --verbose
174+
155175
# This job runs many more tests for the regex crate proper. Basically,
156176
# it repeats the same test suite for a bunch of different crate feature
157177
# combinations. There are so many features that exhaustive testing isn't
@@ -163,7 +183,7 @@ jobs:
163183
runs-on: ubuntu-latest
164184
steps:
165185
- name: Checkout repository
166-
uses: actions/checkout@v4
186+
uses: actions/checkout@v5
167187
- name: Install Rust
168188
uses: dtolnay/rust-toolchain@master
169189
with:
@@ -176,7 +196,7 @@ jobs:
176196
runs-on: ubuntu-latest
177197
steps:
178198
- name: Checkout repository
179-
uses: actions/checkout@v4
199+
uses: actions/checkout@v5
180200
- name: Install Rust
181201
uses: dtolnay/rust-toolchain@master
182202
with:
@@ -189,7 +209,7 @@ jobs:
189209
runs-on: ubuntu-latest
190210
steps:
191211
- name: Checkout repository
192-
uses: actions/checkout@v4
212+
uses: actions/checkout@v5
193213
- name: Install Rust
194214
uses: dtolnay/rust-toolchain@master
195215
with:
@@ -202,7 +222,7 @@ jobs:
202222
runs-on: ubuntu-latest
203223
steps:
204224
- name: Checkout repository
205-
uses: actions/checkout@v4
225+
uses: actions/checkout@v5
206226
- name: Install Rust
207227
uses: dtolnay/rust-toolchain@master
208228
with:
@@ -217,7 +237,7 @@ jobs:
217237
runs-on: ubuntu-latest
218238
steps:
219239
- name: Checkout repository
220-
uses: actions/checkout@v4
240+
uses: actions/checkout@v5
221241
- name: Install Rust
222242
uses: dtolnay/rust-toolchain@master
223243
with:
@@ -234,7 +254,7 @@ jobs:
234254
runs-on: ubuntu-latest
235255
steps:
236256
- name: Checkout repository
237-
uses: actions/checkout@v4
257+
uses: actions/checkout@v5
238258
- name: Install Rust
239259
uses: dtolnay/rust-toolchain@master
240260
with:

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
1.12.2 (2025-10-13)
2+
===================
3+
This release fixes a `cargo doc` breakage on nightly when `--cfg docsrs` is
4+
enabled. This caused documentation to fail to build on docs.rs.
5+
6+
Bug fixes:
7+
8+
* [BUG #1305](https://github.com/rust-lang/regex/issues/1305):
9+
Switches the `doc_auto_cfg` feature to `doc_cfg` on nightly for docs.rs builds.
10+
11+
112
1.12.1 (2025-10-10)
213
===================
314
This release makes a bug fix in the new `regex::Captures::get_match` API

Cargo.toml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,23 @@ name = "integration"
229229
all-features = true
230230
# Since this crate's feature setup is pretty complicated, it is worth opting
231231
# into a nightly unstable option to show the features that need to be enabled
232-
# for public API items. To do that, we set 'docsrs', and when that's enabled,
233-
# we enable the 'doc_auto_cfg' feature.
232+
# for public API items. To do that, we set 'docsrs_regex', and when that's
233+
# enabled, we enable the 'doc_cfg' feature.
234234
#
235235
# To test this locally, run:
236236
#
237-
# RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features
238-
rustdoc-args = ["--cfg", "docsrs"]
237+
# RUSTDOCFLAGS="--cfg docsrs_regex" cargo +nightly doc --all-features
238+
#
239+
# Note that we use `docsrs_regex` instead of the more standard `docsrs` because
240+
# other crates use that same `cfg` knob. And since we are enabling a nightly
241+
# feature, they sometimes break. By using our "own" `cfg` knob, we are closer
242+
# to being masters of our own destiny.
243+
rustdoc-args = ["--cfg", "docsrs_regex"]
244+
245+
# This squashes the (AFAIK) erroneous warning that `docsrs_regex` is not a
246+
# valid `cfg` knob.
247+
[lints.rust]
248+
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(docsrs_regex)'] }
239249

240250
[profile.release]
241251
debug = true

regex-automata/Cargo.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,26 @@ features = ["atty", "humantime", "termcolor"]
109109
[[test]]
110110
path = "tests/lib.rs"
111111
name = "integration"
112+
113+
[package.metadata.docs.rs]
114+
# We want to document all features.
115+
all-features = true
116+
# Since this crate's feature setup is pretty complicated, it is worth opting
117+
# into a nightly unstable option to show the features that need to be enabled
118+
# for public API items. To do that, we set 'docsrs_regex', and when that's
119+
# enabled, we enable the 'doc_cfg' feature.
120+
#
121+
# To test this locally, run:
122+
#
123+
# RUSTDOCFLAGS="--cfg docsrs_regex" cargo +nightly doc --all-features
124+
#
125+
# Note that we use `docsrs_regex` instead of the more standard `docsrs` because
126+
# other crates use that same `cfg` knob. And since we are enabling a nightly
127+
# feature, they sometimes break. By using our "own" `cfg` knob, we are closer
128+
# to being masters of our own destiny.
129+
rustdoc-args = ["--cfg", "docsrs_regex"]
130+
131+
# This squashes the (AFAIK) erroneous warning that `docsrs_regex` is not a
132+
# valid `cfg` knob.
133+
[lints.rust]
134+
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(docsrs_regex)'] }

regex-automata/src/dfa/regex.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ define_regex_type!(
7070
/// a match.
7171
///
7272
/// The type of the DFA used by a `Regex` corresponds to the `A` type
73-
/// parameter, which must satisfy the [`Automaton`] trait. Typically,
74-
/// `A` is either a [`dense::DFA`](crate::dfa::dense::DFA) or a
75-
/// [`sparse::DFA`](crate::dfa::sparse::DFA), where dense DFAs use more
76-
/// memory but search faster, while sparse DFAs use less memory but search
77-
/// more slowly.
73+
/// parameter, which must satisfy the [`Automaton`] trait. Typically, `A`
74+
/// is either a [`dense::DFA`] or a [`sparse::DFA`], where dense DFAs use
75+
/// more memory but search faster, while sparse DFAs use less memory but
76+
/// search more slowly.
7877
///
7978
/// # Crate features
8079
///

regex-automata/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,10 +603,9 @@ enables `alloc` and `nfa-thompson`.
603603
)]
604604
// We generally want all types to impl Debug.
605605
#![warn(missing_debug_implementations)]
606-
// No clue why this thing is still unstable because it's pretty amazing. This
607-
// adds Cargo feature annotations to items in the rustdoc output. Which is
606+
// This adds Cargo feature annotations to items in the rustdoc output. Which is
608607
// sadly hugely beneficial for this crate due to the number of features.
609-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
608+
#![cfg_attr(docsrs_regex, feature(doc_cfg))]
610609

611610
// I have literally never tested this crate on 16-bit, so it is quite
612611
// suspicious to advertise support for it. But... the regex crate, at time

regex-syntax/Cargo.toml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,20 @@ arbitrary = { version = "1.3.0", features = ["derive"], optional = true }
4343
all-features = true
4444
# Since this crate's feature setup is pretty complicated, it is worth opting
4545
# into a nightly unstable option to show the features that need to be enabled
46-
# for public API items. To do that, we set 'docsrs', and when that's enabled,
47-
# we enable the 'doc_auto_cfg' feature.
46+
# for public API items. To do that, we set 'docsrs_regex', and when that's
47+
# enabled, we enable the 'doc_cfg' feature.
4848
#
4949
# To test this locally, run:
5050
#
51-
# RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features
52-
rustdoc-args = ["--cfg", "docsrs"]
51+
# RUSTDOCFLAGS="--cfg docsrs_regex" cargo +nightly doc --all-features
52+
#
53+
# Note that we use `docsrs_regex` instead of the more standard `docsrs` because
54+
# other crates use that same `cfg` knob. And since we are enabling a nightly
55+
# feature, they sometimes break. By using our "own" `cfg` knob, we are closer
56+
# to being masters of our own destiny.
57+
rustdoc-args = ["--cfg", "docsrs_regex"]
58+
59+
# This squashes the (AFAIK) erroneous warning that `docsrs_regex` is not a
60+
# valid `cfg` knob.
61+
[lints.rust]
62+
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(docsrs_regex)'] }

regex-syntax/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ The following features are available:
168168
#![forbid(unsafe_code)]
169169
#![deny(missing_docs, rustdoc::broken_intra_doc_links)]
170170
#![warn(missing_debug_implementations)]
171-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
171+
// This adds Cargo feature annotations to items in the rustdoc output. Which is
172+
// sadly hugely beneficial for this crate due to the number of features.
173+
#![cfg_attr(docsrs_regex, feature(doc_cfg))]
172174

173175
#[cfg(any(test, feature = "std"))]
174176
extern crate std;

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,9 @@ this for literal optimizations.
13191319
#![no_std]
13201320
#![deny(missing_docs)]
13211321
#![cfg_attr(feature = "pattern", feature(pattern))]
1322+
// This adds Cargo feature annotations to items in the rustdoc output. Which is
1323+
// sadly hugely beneficial for this crate due to the number of features.
1324+
#![cfg_attr(docsrs_regex, feature(doc_cfg))]
13221325
#![warn(missing_debug_implementations)]
13231326

13241327
#[cfg(doctest)]

0 commit comments

Comments
 (0)