Skip to content

Conversation

@kornelski
Copy link
Contributor

What does this PR try to resolve?

Makes an error message more helpful to novice users who may encounter it when writing Cargo.toml for the first time. The previous wording expected users to know what a "virtual manifest" and did not provide any further hints.

How to test and review this PR?

Updated unit tests demonstrate it.

@rustbot rustbot added A-manifest Area: Cargo.toml issues S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 12, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 12, 2026

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@epage
Copy link
Contributor

epage commented Jan 12, 2026

Thanks!

};
let toml_table = format_args!("{table_open}{field}{table_close}");
anyhow!(
"this virtual manifest does not have a `[package]` section, which is required when specifying the `{toml_table}` section"
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, didn't notice the wording change before because of everything else that changed (which is one reason why splitting up changes into individual commits can be helpful).

You are right that the old message is bad, focusing on terminology that is unlikely to be meaningful to the user. Something both messages have in common though is they are indirect about the problem at hand

e.g. the old message should have said something like:

`{field}` section is invalid in virtual manifests

Looking at the new wording, one possible suggestion is:

`{toml_table}` requires a `[package]` section

or

`[package]` section is missing
note: required by `{toml_table}`

When we switch this to annotate snippets, we could move the note to an annotation on the {toml_table} in the source.

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

Labels

A-manifest Area: Cargo.toml issues S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants