Skip to content

cargo doc fails with E0080 #1909

Description

@Warfront1

cargo doc fails on p256 0.14.0, p384 0.14.0, p521 0.14.0, k256 0.14.0, and sm2 0.14.0-rc.15 with Rust 1.85-1.89.
Projects using Rust 1.85-1.89 that have dependencies on these are failing when executing cargo doc --document-private-items.

The following is the error message you receive from cargo doc --document-private-items:

Documenting p256 v0.14.0 (/repo/p256)
error[E0080]: it is undefined behavior to use this value
  --> p256/src/arithmetic/tables.rs:17:5
   |
17 |     const BASEPOINT_TABLE: &'static BasepointTable = &BASEPOINT_TABLE;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
   |
   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
   = note: the raw bytes of the constant (size: 8, align: 8) {
               ╾─────alloc456894─────╼                         │ ╾──────╼
           }

For more information about this error, try `rustc --explain E0080`.
error: could not document `p256`

cargo build and cargo test succeed — only cargo doc fails (rustdoc evaluates the associated const to render its value).

Reproduction (Rust 1.85-1.89):

docker run --rm rust:1.85.0 bash -c '
  apt-get update -qq && apt-get install -y -qq git >/dev/null
  git clone --depth 1 https://github.com/RustCrypto/elliptic-curves.git /repo
  cd /repo/p256
  cargo doc --document-private-items
'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions