@@ -10,6 +10,8 @@ const RUSTFMT_COMPONENTS: &[&str] = &["rustfmt-preview"];
1010
1111struct Tool {
1212 config : Config ,
13+ comments : Vec < String > ,
14+
1315 channel : Channel ,
1416 version : [ u16 ; 3 ] ,
1517 checksums : IndexMap < String , String > ,
@@ -35,7 +37,13 @@ impl Tool {
3537
3638 let existing: Stage0 = serde_json:: from_slice ( & std:: fs:: read ( PATH ) ?) ?;
3739
38- Ok ( Self { channel, version, config : existing. config , checksums : IndexMap :: new ( ) } )
40+ Ok ( Self {
41+ channel,
42+ version,
43+ config : existing. config ,
44+ comments : existing. comments ,
45+ checksums : IndexMap :: new ( ) ,
46+ } )
3947 }
4048
4149 fn update_json ( mut self ) -> Result < ( ) , Error > {
@@ -44,9 +52,6 @@ impl Tool {
4452 format ! (
4553 "{}\n " ,
4654 serde_json:: to_string_pretty( & Stage0 {
47- comment: "Generated by `./x.py run src/tools/bump-stage0`. \
48- Run that command again to update the bootstrap compiler."
49- . into( ) ,
5055 compiler: self . detect_compiler( ) ?,
5156 rustfmt: self . detect_rustfmt( ) ?,
5257 checksums_sha256: {
@@ -56,6 +61,7 @@ impl Tool {
5661 self . checksums
5762 } ,
5863 config: self . config,
64+ comments: self . comments,
5965 } ) ?
6066 ) ,
6167 ) ?;
@@ -172,9 +178,18 @@ enum Channel {
172178
173179#[ derive( Debug , serde:: Serialize , serde:: Deserialize ) ]
174180struct Stage0 {
175- #[ serde( rename = "__comment" ) ]
176- comment : String ,
177181 config : Config ,
182+ // Comments are explicitly below the config, do not move them above.
183+ //
184+ // Downstream forks of the compiler codebase can change the configuration values defined above,
185+ // but doing so would risk merge conflicts whenever they import new changes that include a
186+ // bootstrap compiler bump.
187+ //
188+ // To lessen the pain, a big block of comments is placed between the configuration and the
189+ // auto-generated parts of the file, preventing git diffs of the config to include parts of the
190+ // auto-egenrated content and vice versa. This should prevent merge conflicts.
191+ #[ serde( rename = "__comments" ) ]
192+ comments : Vec < String > ,
178193 compiler : Stage0Toolchain ,
179194 rustfmt : Option < Stage0Toolchain > ,
180195 checksums_sha256 : IndexMap < String , String > ,
0 commit comments