RustCrypto / RustCrypto/AEADs

Doctests no longer build with default features

Open
#755 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
961
Forks
200
Avg merge
1h 30m
Merged PRs (30d)
6

Description

This was somehow introduced in #752 which bumped aead to v0.6.0-rc.4, but I am baffled as to how or what's even happening.

Example reproduction

$ cd aes-gcm
$ cargo test --doc
[...]
---- aes-gcm/src/lib.rs - (line 150) stdout ----
error[E0432]: unresolved import `aes_gcm::aead::Generate`
  --> aes-gcm/src/lib.rs:156:28
   |
8  |     aead::{Aead, AeadCore, Generate, Key, KeyInit},
   |                            ^^^^^^^^ no `Generate` in the root
   |
note: found an item that was configured out

Notes

This occurs in several crates, any of which use this style of gating:

#![cfg_attr(feature = "getrandom", doc = "```")]
#![cfg_attr(not(feature = "getrandom"), doc = "```ignore")]

Curiously, if the first line is changed to:

#![cfg_attr(feature = "getrandom", doc = "```ignore")]

Then the test is successfully ignored, suggesting this gating somehow isn't working correctly:

running 2 tests
test aes-gcm/src/lib.rs - (line 150) ... ignored
test aes-gcm/src/lib.rs - (line 189) ... ignored

Note the other example, which depends on both the arrayvec and getrandom features, is successfully being ignored with logic like:

#![cfg_attr(all(feature = "getrandom", feature = "arrayvec"), doc = "```")]
#![cfg_attr(
    not(all(feature = "getrandom", feature = "arrayvec")),
    doc = "```ignore"
)]

Perhaps the weirdest part is nothing in #752 actually changed how this gating worked, it just started behaving differently when the aead crate was upgraded from v0.6.0-rc.3 to v0.6.0-rc.4.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce from aes-gcm with cargo test --doc, then inspect the feature-gated doctest attributes in aes-gcm/src/lib.rs. Compare the behavior with aead v0.6.0-rc.3 and v0.6.0-rc.4, including the examples using getrandom and arrayvec. Done means default-feature doctests no longer produce the unresolved Generate import and appropriately gated examples are ignored.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.