-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Clarify warning for using features
or default-features
in patch
#15953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify warning for using features
or default-features
in patch
#15953
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use |
When attempting to substitute a local version of a dependency, since the `patch` section uses syntax similar to a dependency (and the documentation even says "The syntax is similar to the `[dependencies]` section", it's natural to assume that other things from `[dependencies]` also work, such as `features` or `default-features`. Attempting to use them produces this warning: > patch for `crate-name-here` uses the features mechanism. > default-features and features will not take effect because the patch dependency does not support this mechanism The phrasing "the patch dependency does not support this mechanism" makes it seem at first glance like `patch` just doesn't support this at all. But the actual problem is that the user needs to move the `features`/`default-features` keys to an entry in `dependencies` instead. Modify the message, to make this more obvious. Modify the corresponding warning for `replace` as well. Update tests accordingly.
e3f3bf5
to
5030f23
Compare
p.cargo("check") | ||
.with_stderr_data(str![[r#" | ||
[WARNING] unused field in patch for `bar`: `features` | ||
[NOTE] configure `features` in the `dependencies` entry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this to make two sentences more connected?
[NOTE] configure `features` in the `dependencies` entry | |
[NOTE] configure `features` in the `[dependencies]` entry instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would take the two sentences and make them one which imo doesn't quite fit with this style of messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update cargo submodule 19 commits in 24bb93c388fb8c211a37986539f24a819dc669d3..966f94733bbc94ca51ff9f1e4c49ad250ebbdc50 2025-09-10 23:16:07 +0000 to 2025-09-16 17:24:45 +0000 - fix(frontmatter): Improve error quality (rust-lang/cargo#15972) - fix: wrong variable name in documentation (rust-lang/cargo#15968) - Add "Optimizing Build Performance" section to the Cargo book (rust-lang/cargo#15924) - Remove extra apostrophe in environment-variables.md (rust-lang/cargo#15963) - Clarify warning for using `features` or `default-features` in `patch` (rust-lang/cargo#15953) - fix(frontmatter): Try alternative len code fences (rust-lang/cargo#15952) - feat(cli): Allow completions for third-party subcommand names (rust-lang/cargo#15961) - docs(index): Clarify what we mean by omitting features (rust-lang/cargo#15957) - fix(future): Report all content as a single Report (rust-lang/cargo#15943) - fix(complete): Show local crates/features over other members (rust-lang/cargo#15956) - docs(resolver): Describe the role of the lockfile (rust-lang/cargo#15958) - chore: Skip check-version-bump ci job in forks (rust-lang/cargo#15959) - Eliminate the last three "did you mean" warning phrasings (rust-lang/cargo#15356) - fix(info): Suggest a more universal `cargo tree` command (rust-lang/cargo#15954) - feat(cli): Use ellipses when truncating progress (rust-lang/cargo#15955) - feat(completer): Added completion for `--features` flag (rust-lang/cargo#15309) - fix(publish): Switch the 'ctrl-c on wait' line to a help message (rust-lang/cargo#15942) - docs: move docs building process to contributor guide (rust-lang/cargo#15854) - fix(manifest): Show error source to users (rust-lang/cargo#15939) r? ghost
What does this PR try to resolve?
When attempting to substitute a local version of a dependency, since the
patch
section uses syntax similar to a dependency (and the documentation even says "The syntax is similar to the[dependencies]
section", it's natural to assume that other things from[dependencies]
also work, such asfeatures
ordefault-features
. Attempting to use them produces this warning:The phrasing "the patch dependency does not support this mechanism" makes it seem at first glance like
patch
just doesn't support this at all. But the actual problem is that the user needs to move thefeatures
/default-features
keys to an entry independencies
instead.Closes #13522
How to test and review this PR?
This applies the review feedback from #13522 that the author didn't have a chance to get back to.