@@ -10,6 +10,8 @@ const RUSTFMT_COMPONENTS: &[&str] = &["rustfmt-preview"];
10
10
11
11
struct Tool {
12
12
config : Config ,
13
+ comments : Vec < String > ,
14
+
13
15
channel : Channel ,
14
16
version : [ u16 ; 3 ] ,
15
17
checksums : IndexMap < String , String > ,
@@ -35,7 +37,13 @@ impl Tool {
35
37
36
38
let existing: Stage0 = serde_json:: from_slice ( & std:: fs:: read ( PATH ) ?) ?;
37
39
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
+ } )
39
47
}
40
48
41
49
fn update_json ( mut self ) -> Result < ( ) , Error > {
@@ -44,9 +52,6 @@ impl Tool {
44
52
format ! (
45
53
"{}\n " ,
46
54
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( ) ,
50
55
compiler: self . detect_compiler( ) ?,
51
56
rustfmt: self . detect_rustfmt( ) ?,
52
57
checksums_sha256: {
@@ -56,6 +61,7 @@ impl Tool {
56
61
self . checksums
57
62
} ,
58
63
config: self . config,
64
+ comments: self . comments,
59
65
} ) ?
60
66
) ,
61
67
) ?;
@@ -172,9 +178,18 @@ enum Channel {
172
178
173
179
#[ derive( Debug , serde:: Serialize , serde:: Deserialize ) ]
174
180
struct Stage0 {
175
- #[ serde( rename = "__comment" ) ]
176
- comment : String ,
177
181
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 > ,
178
193
compiler : Stage0Toolchain ,
179
194
rustfmt : Option < Stage0Toolchain > ,
180
195
checksums_sha256 : IndexMap < String , String > ,
0 commit comments