What version are you using?
Current main (crate version 0.1.1, commit 5b99774). Reproduced with both the crate's MSRV (1.74.0) and the latest stable Rust toolchain.
What did you do?
Ran clippy against the crate:
cargo clippy --all-targets
What did you expect to see?
A clean clippy run with no warnings, and — when building docs with the doc make target — rustdoc annotations indicating which items require the alloc feature.
What did you see instead?
Three warnings, and doc(cfg(...)) hints that never activate:
-
feature = "doc" is not a defined feature — src/escape.rs:15 and src/unescape.rs:22 use #[cfg_attr(feature = "doc", doc(cfg(feature = "alloc")))]. No feature named doc is defined in Cargo.toml (only alloc, default, and docs), which triggers unexpected_cfgs:
warning: unexpected `cfg` condition value: `doc`
--> src/escape.rs:15:12
|
15 | #[cfg_attr(feature = "doc", doc(cfg(feature = "alloc")))]
| ^^^^^^^^^^-----
| |
| help: there is a expected value with a similar name: `"docs"`
The Makefile's doc target sets RUSTDOCFLAGS="--cfg doc", which suggests the attribute was meant to key off the bare cfg(doc) predicate rather than a feature = "doc". Because the attribute never matches, rustdoc output never gains the doc(cfg(feature = "alloc")) annotation on gated items.
-
let...else can be replaced with ? — src/escape.rs:135 inside Escape::next triggers clippy::question_mark:
warning: this `let...else` may be rewritten with the `?` operator
--> src/escape.rs:135:17
|
135 | / let Some(b) = self.input.next() else {
136 | | return None;
137 | | };
Suggested fix
- Change
#[cfg_attr(feature = "doc", ...)] to #[cfg_attr(doc, ...)] in src/escape.rs and src/unescape.rs so the annotation activates when the Makefile's --cfg doc flag is set.
- Enable the nightly
doc_cfg feature conditionally in src/lib.rs via #![cfg_attr(doc, feature(doc_cfg))], so doc(cfg(...)) compiles on the nightly toolchain the doc target uses, without affecting stable builds.
- Replace the
let...else in src/escape.rs with let b = self.input.next()?;.
Affected files
src/lib.rs
src/escape.rs
src/unescape.rs
What version are you using?
Current
main(crate version0.1.1, commit5b99774). Reproduced with both the crate's MSRV (1.74.0) and the latest stable Rust toolchain.What did you do?
Ran clippy against the crate:
What did you expect to see?
A clean clippy run with no warnings, and — when building docs with the
docmake target — rustdoc annotations indicating which items require theallocfeature.What did you see instead?
Three warnings, and
doc(cfg(...))hints that never activate:feature = "doc"is not a defined feature —src/escape.rs:15andsrc/unescape.rs:22use#[cfg_attr(feature = "doc", doc(cfg(feature = "alloc")))]. No feature nameddocis defined inCargo.toml(onlyalloc,default, anddocs), which triggersunexpected_cfgs:The
Makefile'sdoctarget setsRUSTDOCFLAGS="--cfg doc", which suggests the attribute was meant to key off the barecfg(doc)predicate rather than afeature = "doc". Because the attribute never matches, rustdoc output never gains thedoc(cfg(feature = "alloc"))annotation on gated items.let...elsecan be replaced with?—src/escape.rs:135insideEscape::nexttriggersclippy::question_mark:Suggested fix
#[cfg_attr(feature = "doc", ...)]to#[cfg_attr(doc, ...)]insrc/escape.rsandsrc/unescape.rsso the annotation activates when theMakefile's--cfg docflag is set.doc_cfgfeature conditionally insrc/lib.rsvia#![cfg_attr(doc, feature(doc_cfg))], sodoc(cfg(...))compiles on the nightly toolchain thedoctarget uses, without affecting stable builds.let...elseinsrc/escape.rswithlet b = self.input.next()?;.Affected files
src/lib.rssrc/escape.rssrc/unescape.rs