Skip to content

Experiment: Move natvis files from src/etc/natvis to debugger_visualizer attributes#154027

Open
clarfonthey wants to merge 1 commit intorust-lang:mainfrom
clarfonthey:natvis
Open

Experiment: Move natvis files from src/etc/natvis to debugger_visualizer attributes#154027
clarfonthey wants to merge 1 commit intorust-lang:mainfrom
clarfonthey:natvis

Conversation

@clarfonthey
Copy link
Contributor

@clarfonthey clarfonthey commented Mar 18, 2026

This is the "easy part" of a massive rabbit hole that I fell into trying to figure out how the current debug visualizers for hashmaps could potentially be moved into the hashbrown crate, while still being able to leverage them for libstd.

For natvis, it's pretty easy to separate out what belongs where, and we basically already do this. This just takes it a slight step further and attempts to move them into their relevant crates, and we'll see if it breaks everything in CI. For lack of a better place, this moves the "intrinsic" (should probably be renamed to "primitive") natvis file into the libcore crate, since no_core is unstable anyway.

The Python scripts are an absolute mess, and that's going to take some asking around. So, instead of stalling this part on that being done, I decided to just offer this PR and we'll see if it can work and hopefully make it easier for people to modify the debug visualizers in the standard library, at least for Windows.


Worth also mentioning right now that I don't have a copy of Windows proper to test this on, so, I'm mostly relying on CI/others to verify that this actually doesn't break anything.

@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) T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 18, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 18, 2026

r? @clubby789

rustbot has assigned @clubby789.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: bootstrap
  • bootstrap expanded to 6 candidates
  • Random selection from Mark-Simulacrum, clubby789, jieyouxu

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Mar 18, 2026

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc labels Mar 18, 2026
"library/core/core.natvis",
"library/core/intrinsic.natvis",
"library/alloc/alloc.natvis",
"library/std/std.natvis",
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary? Shouldn't changing them trigger a rebuild of the standard library already and in turn cause all test results to be invalidated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm actually not sure, but I wasn't even sure this would work at first, so, I was being cautious

@bjorn3
Copy link
Member

bjorn3 commented Mar 18, 2026

// This will cause the Microsoft linker to embed .natvis info into the PDB file
let natvis_dir_path = self.sess.opts.sysroot.path().join("lib\\rustlib\\etc");
if let Ok(natvis_dir) = fs::read_dir(&natvis_dir_path) {
for entry in natvis_dir {
match entry {
Ok(entry) => {
let path = entry.path();
if path.extension() == Some("natvis".as_ref()) {
let mut arg = OsString::from("/NATVIS:");
arg.push(path);
self.link_arg(arg);
}
}
Err(error) => {
self.sess.dcx().emit_warn(errors::NoNatvisDirectory { error });
}
}
}
}
can be removed after these changes, right?

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

Labels

A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc 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) T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants