Skip to content

cargo publish stripping hints section from Cargo.toml #15836

@landonxjames

Description

@landonxjames

Problem

We recently added hints.mostly-unused = true to several of the aws-sdk-rust crates to improve compilation time (ex: aws-sdk-ec2). A user reported that compiling with the new -Zprofile-hint-mostly-unused option did not improve their compilation times and that they did not see a hints section when looking at the crate in the Cargo cache.

When looking at the published source on docs.rs (which I assume is the same as that on crates.io?) I also do not see a hints section. Running cargo publish --dry-run and looking at the generated package in target/package I can confirm that the hints section is removed from the package by the publish command.

Running cargo +nightly publish --dry-run does include the hints section in Cargo.toml

Steps

git clone --depth 1 https://github.com/awslabs/aws-sdk-rust.git;
cd aws-sdk-rust/sdk/ec2;

# Finds hints
cat Cargo.toml | grep hints;

# If you add +nightly here all works as expected
cargo publish --dry-run;

# Does not find hints (unless you add +nightly in the line above)
cat ../../target/package/aws-sdk-ec2-1.158.0/Cargo.toml | grep hints;

Possible Solution(s)

I suspect that cargo publish is stripping out unrecognized sections in Cargo.toml, and we are not publishing with nightly and the -Zprofile-hint-mostly-unused option. This should likely be more permissive in allowing sections through.

Notes

No response

Version

# Local testing
$ cargo --version
cargo 1.89.0 (c24e10642 2025-06-23)

$ cargo +nightly --version
cargo 1.91.0-nightly (840b83a10 2025-07-30)


# Actual publishing
$ cargo --version
cargo 1.86.0 (adf9b6ad1 2025-02-28)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-documenting-cargo-itselfArea: Cargo's documentationA-manifestArea: Cargo.toml issuesC-bugCategory: bugCommand-packageS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions