Skip to content

Conversation

lolbinarycat
Copy link
Contributor

@lolbinarycat lolbinarycat commented Sep 15, 2025

based on discussion on #146591

now, if the user puts build.download-rustc in bootstrap.toml, they'll get a diagnostic:
hint: try moving `download-rustc` to the `rust` section

and if they nest things too much (rust.rust.download-rustc):
hint: section name `rust` used as a key within a section

if they specify a top-level key within a section (rust.profile):
hint: try using `profile` as a top level key

r? @Kobzol

@rustbot
Copy link
Collaborator

rustbot commented Sep 15, 2025

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Sep 15, 2025
@lolbinarycat lolbinarycat force-pushed the bootstrap-toml-wrong-section-diagnostic branch from e85f09f to 2593762 Compare September 15, 2025 21:56
Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

The implementation is so hacky I don't even want to look at it 😆 But since this is just a best effort hint, and doesn't affect the rest of the codebase, I'm fine with it. Left one nit. Thank you!

View changes since this review

}

fn find_correct_section_for_field(field_name: &str) -> Vec<&'static str> {
let sections = ["<top level>", "build", "install", "llvm", "gcc", "rust", "dist"];
Copy link
Member

Choose a reason for hiding this comment

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

We actually have a field named build, so for that this heuristic wouldn't work, but that's not so important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code could easily be generalized to detect when a section name is also valid as a key in a given section, but the problem is I have no idea what a good diagnostic to print in that case would be.

exit!(2);
}

fn find_correct_section_for_field(field_name: &str) -> Vec<&'static str> {
Copy link
Member

Choose a reason for hiding this comment

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

Could you please use an enum rather than a string reference here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants