Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions doc/book/src/reference/unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,75 @@ This will cause the crate to default to hint-mostly-unused, unless overridden
via `profile`, which takes precedence, and which can only be specified in the
top-level crate being built.

### Documentation updates

#### hint-mostly-unused

*as a new ["Profile settings" entry](./profiles.html#profile-settings)*

The `hint-mostly-unused` setting controls the [`-Zhint-mostly-unused` flag]
which indicates that most of a crate's API surface will go unused by anything
depending on it. This hint can speed up the build by attempting to minimize
compilation time for items that aren't used at all. Misapplication to crates
that don't fit that criteria can slow down the build rather than speeding it
up.

The valid options are:

* `true`: enabled
* `false`: disabled
Comment on lines +958 to +961

@weihanglo weihanglo Oct 26, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why do we have an unordered list for profile but not for hint? Which writing style do we prefer and follow the eixsting style?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

profiles.md uses this style, so I chose to use it here. manifest.md uses a different style(Or no style😄). I do not think this is a big issue, and I can change either one if you think we should use one style throughout.


The default is the crate's [`mostly-unused` hint](#mostly-unused), or `false`
if the crate does not set the hint.

This is primarily useful to enable for specific dependencies:

```toml
[profile.dev.package.huge-mostly-unused-dependency]
hint-mostly-unused = true
```

The [`blanket_hint_mostly_unused`] lint warns when this setting is applied to
all dependencies.

[`-Zhint-mostly-unused` flag]: ../../unstable-book/compiler-flags/hint-mostly-unused.html
[`blanket_hint_mostly_unused`]: lints.md#blanket_hint_mostly_unused

#### `mostly-unused`

*as a new subsection of ["The `[hints]` section"](./manifest.html#the-hints-section),
which would gain one subsection per hint*

The `mostly-unused` hint indicates that most of this crate's API surface will
go unused by anything depending on it. A crate can provide this hint
automatically for crates that depend on it:

```toml
# In example-dependency's Cargo.toml
[hints]
mostly-unused = true
```

This will cause the crate to default to
[`hint-mostly-unused`](#hint-mostly-unused). A `hint-mostly-unused` setting in
a [profile](profiles.md) takes precedence over the hint. Only the workspace
root `Cargo.toml` and [Cargo configuration](config.md#profile) can set
profiles:

```toml
# This package uses most of `example-dependency`, so the hint does not apply.
[profile.dev.package.example-dependency]
hint-mostly-unused = false
```

The valid values are `true` and `false`. Cargo warns about and ignores any
other value.

A hint only applies to the package that sets it, not to its dependencies.

Only use this hint when you expect most dependents to use a small part of the
crate. Otherwise, the hint may slow down their builds.

## Package `min-opt-level` hint
* Tracking Issue: [#17334](https://github.com/rust-lang/cargo/issues/17334)
* RFC: [#3924](https://github.com/rust-lang/rfcs/pull/3924)
Expand Down
Loading