Skip to content

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Jun 19, 2025

I think rustdoc-json-types was more recently split out, so this download-rustc logic became outdated as it wasn't tracked. This PR adds src/rustdoc-json-types to be tracked for difference versus upstream, so that we properly rebuild rustdoc if it has changes versus upstream.

Fixes #142738.

Local testing

This is not so easy to test locally because it requires download-rustc. To test this, you need to:

  1. Disable download-rustc inhibition from bootstrap changes versus upstream, by including :!src/bootstrap in
    pub const RUSTC_IF_UNCHANGED_ALLOWED_PATHS: &[&str] = &[
    ":!library",
    ":!src/tools",
    ":!src/librustdoc",
    ":!src/rustdoc-json-types",
    ":!tests",
    ":!triagebot.toml",
    ];
    .
  2. Then, use a config like profile = "tools" which by default uses download-rustc = "if-unchanged".
  3. Run ./x test tests/rustdoc-json one time, to "prime" initial build caches.
  4. Change the FORMAT_VERSION in src/rustdoc-json-types, i.e.
    diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs
    index 1f93895ae07..72a3720c7b4 100644
    --- a/src/rustdoc-json-types/lib.rs
    +++ b/src/rustdoc-json-types/lib.rs
    @@ -38,7 +38,7 @@
     // are deliberately not in a doc comment, because they need not be in public docs.)
     //
     // Latest feature: Pretty printing of inline attributes changed
    -pub const FORMAT_VERSION: u32 = 48;
    +pub const FORMAT_VERSION: u32 = 666;
  5. Observe that without this patch, rustdoc-json tests fail because FORMAT_VERSION mismatch. Observe that with this patch, rustdoc gets properly rebuilt and rustdoc-json tests pass.

cc @aDotInTheVoid

r? Kobzol

@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 Jun 19, 2025
@aDotInTheVoid
Copy link
Member

Thanks ❤️!

I think rustdoc-json-types was more recently split out

It's been around for ages (#81287), I think this was hidden for so longer because modifying rustdoc-json-types without also modifying librustdoc doesn't make much sense.

@Kobzol
Copy link
Member

Kobzol commented Jun 20, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jun 20, 2025

📌 Commit fca6e81 has been approved by Kobzol

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 20, 2025
Kobzol added a commit to Kobzol/rust that referenced this pull request Jun 20, 2025
Make sure to rebuild rustdoc if `src/rustdoc-json-types` is changed

I think `rustdoc-json-types` was more recently split out, so this download-rustc logic became outdated as it wasn't tracked. This PR adds `src/rustdoc-json-types` to be tracked for difference versus upstream, so that we properly rebuild rustdoc if it has changes versus upstream.

Fixes rust-lang#142738.

### Local testing

This is not so easy to test locally because it requires download-rustc. To test this, you need to:

1. Disable `download-rustc` inhibition from bootstrap changes versus upstream, by including `:!src/bootstrap` in https://github.com/rust-lang/rust/blob/255aa220821c05c3eac7605fce4ea1c9ab2cbdb4/src/bootstrap/src/core/config/config.rs#L67-L74.
2. Then, use a config like `profile = "tools"` which by default uses `download-rustc = "if-unchanged"`.
3. Run `./x test tests/rustdoc-json` one time, to "prime" initial build caches.
4. Change the `FORMAT_VERSION` in `src/rustdoc-json-types`, i.e.
	```diff
	diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs
	index 1f93895..72a3720c7b4 100644
	--- a/src/rustdoc-json-types/lib.rs
	+++ b/src/rustdoc-json-types/lib.rs
	`@@` -38,7 +38,7 `@@`
	 // are deliberately not in a doc comment, because they need not be in public docs.)
	 //
	 // Latest feature: Pretty printing of inline attributes changed
	-pub const FORMAT_VERSION: u32 = 48;
	+pub const FORMAT_VERSION: u32 = 666;
	```
5. Observe that without this patch, `rustdoc-json` tests fail because `FORMAT_VERSION` mismatch. Observe that with this patch, rustdoc gets properly rebuilt and `rustdoc-json` tests pass.

cc `@aDotInTheVoid`

r? Kobzol
bors added a commit that referenced this pull request Jun 20, 2025
Rollup of 11 pull requests

Successful merges:

 - #142478 (install docs for each target in different directory)
 - #142629 (Add config builder for bootstrap tests)
 - #142715 (correct template for `#[align]` attribute)
 - #142720 (De-dup common code from `ExternalCrate` methods)
 - #142736 (add issue template for rustdoc)
 - #142743 (rustc-dev-guide subtree update)
 - #142744 (Add a mailmap entry for y21)
 - #142758 (Make sure to rebuild rustdoc if `src/rustdoc-json-types` is changed)
 - #142764 (Convert `ilog(10)` to `ilog10()`)
 - #142767 (Some symbol and PathRoot cleanups)
 - #142769 (remove equivalent new method on context)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jun 20, 2025
Rollup of 10 pull requests

Successful merges:

 - #142629 (Add config builder for bootstrap tests)
 - #142715 (correct template for `#[align]` attribute)
 - #142720 (De-dup common code from `ExternalCrate` methods)
 - #142736 (add issue template for rustdoc)
 - #142743 (rustc-dev-guide subtree update)
 - #142744 (Add a mailmap entry for y21)
 - #142758 (Make sure to rebuild rustdoc if `src/rustdoc-json-types` is changed)
 - #142764 (Convert `ilog(10)` to `ilog10()`)
 - #142767 (Some symbol and PathRoot cleanups)
 - #142769 (remove equivalent new method on context)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 64a7fcf into rust-lang:master Jun 20, 2025
10 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 20, 2025
rust-timer added a commit that referenced this pull request Jun 20, 2025
Rollup merge of #142758 - jieyouxu:rustdoc-json-types, r=Kobzol

Make sure to rebuild rustdoc if `src/rustdoc-json-types` is changed

I think `rustdoc-json-types` was more recently split out, so this download-rustc logic became outdated as it wasn't tracked. This PR adds `src/rustdoc-json-types` to be tracked for difference versus upstream, so that we properly rebuild rustdoc if it has changes versus upstream.

Fixes #142738.

### Local testing

This is not so easy to test locally because it requires download-rustc. To test this, you need to:

1. Disable `download-rustc` inhibition from bootstrap changes versus upstream, by including `:!src/bootstrap` in https://github.com/rust-lang/rust/blob/255aa220821c05c3eac7605fce4ea1c9ab2cbdb4/src/bootstrap/src/core/config/config.rs#L67-L74.
2. Then, use a config like `profile = "tools"` which by default uses `download-rustc = "if-unchanged"`.
3. Run `./x test tests/rustdoc-json` one time, to "prime" initial build caches.
4. Change the `FORMAT_VERSION` in `src/rustdoc-json-types`, i.e.
	```diff
	diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs
	index 1f93895..72a3720c7b4 100644
	--- a/src/rustdoc-json-types/lib.rs
	+++ b/src/rustdoc-json-types/lib.rs
	``@@`` -38,7 +38,7 ``@@``
	 // are deliberately not in a doc comment, because they need not be in public docs.)
	 //
	 // Latest feature: Pretty printing of inline attributes changed
	-pub const FORMAT_VERSION: u32 = 48;
	+pub const FORMAT_VERSION: u32 = 666;
	```
5. Observe that without this patch, `rustdoc-json` tests fail because `FORMAT_VERSION` mismatch. Observe that with this patch, rustdoc gets properly rebuilt and `rustdoc-json` tests pass.

cc ``@aDotInTheVoid``

r? Kobzol
@jieyouxu jieyouxu deleted the rustdoc-json-types branch June 20, 2025 23:03
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jun 23, 2025
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#142629 (Add config builder for bootstrap tests)
 - rust-lang/rust#142715 (correct template for `#[align]` attribute)
 - rust-lang/rust#142720 (De-dup common code from `ExternalCrate` methods)
 - rust-lang/rust#142736 (add issue template for rustdoc)
 - rust-lang/rust#142743 (rustc-dev-guide subtree update)
 - rust-lang/rust#142744 (Add a mailmap entry for y21)
 - rust-lang/rust#142758 (Make sure to rebuild rustdoc if `src/rustdoc-json-types` is changed)
 - rust-lang/rust#142764 (Convert `ilog(10)` to `ilog10()`)
 - rust-lang/rust#142767 (Some symbol and PathRoot cleanups)
 - rust-lang/rust#142769 (remove equivalent new method on context)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

bootstrap: Chaning src/rustdoc-json-types doesn't rebuild rustdoc
5 participants