Skip to content

Dependency fails with "the feature doc_cfg has already been declared" #1289

Closed
@pka

Description

@pka

Crate name: geozero
Build failure link: https://docs.rs/crate/geozero/0.7.2/builds/355163

Additional details:
geozero has the following Cargo.toml entry:

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"] 

cfg(docsrs) is required for a doc.rs build of the dependency gdal: https://github.com/georust/gdal/blob/master/build.rs#L3

The failing tokio-stream crate does in fact set a feature twice based on docsrs: https://github.com/tokio-rs/tokio/blob/master/tokio-stream/src/lib.rs#L17-L23

But a local doc build is successful!

Activity

jyn514

jyn514 commented on Feb 27, 2021

@jyn514
Member

This should be reported upstream to Tokio, we can't fix it on our end.

But a local doc build is successful!

Local builds don't pass --cfg docsrs by default.

Nemo157

Nemo157 commented on Feb 27, 2021

@Nemo157
Member

There is a bug somewhere here since tokio-stream successfully built its docs, and it appears to activate the cfg for its build. Maybe rustdoc allows duplicate features, while rustc doesn't?

pka

pka commented on Feb 27, 2021

@pka
Author

This should be reported upstream to Tokio, we can't fix it on our end.

PR: tokio-rs/tokio#3561

But a local doc build is successful!

Local builds don't pass --cfg docsrs by default.

I tried to imitate docs.rs build with
cargo +nightly doc --all-features --config 'build.rustflags=["--cfg", "docsrs"]' -Z unstable-options

Am I missing something?

Nemo157

Nemo157 commented on Feb 27, 2021

@Nemo157
Member

I've opened rust-lang/rust#82588 for the rustdoc bug that allowed tokio-stream's docs to succeed.

Using cargo +nightly doc --all-features --config 'build.rustflags=["--cfg", "docsrs"]' -Z unstable-options on a crate that depends on tokio-stream I get the build failure, but at least on my machine I had to override CARGO_HOME for it to avoid loading my ~/.cargo/config, which sets target.x86_64-unknown-linux-gnu.rustflags overriding the build.rustflags config.

pka

pka commented on Feb 27, 2021

@pka
Author

So nothing else to be done here, I think. Thanks @jyn514 and @Nemo157 for looking into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @pka@Nemo157@jyn514

        Issue actions

          Dependency fails with "the feature `doc_cfg` has already been declared" · Issue #1289 · rust-lang/docs.rs