@@ -78,9 +78,9 @@ pub struct OnDiskReports {
78
78
struct OnDiskReport {
79
79
/// Unique reference to the report for the `--id` CLI flag.
80
80
id : u32 ,
81
- /// A (possibly empty) message describing which affected
82
- /// packages have newer versions available
83
- update_message : String ,
81
+ /// A message describing suggestions for fixing the
82
+ /// reported issues
83
+ suggestion_message : String ,
84
84
/// Report, suitable for printing to the console.
85
85
/// Maps package names to the corresponding report
86
86
/// We use a `BTreeMap` so that the iteration order
@@ -101,31 +101,22 @@ impl Default for OnDiskReports {
101
101
impl OnDiskReports {
102
102
/// Saves a new report.
103
103
pub fn save_report (
104
+ mut self ,
104
105
ws : & Workspace < ' _ > ,
105
- update_message : String ,
106
+ suggestion_message : String ,
106
107
per_package_reports : & [ FutureIncompatReportPackage ] ,
107
- ) -> OnDiskReports {
108
- let mut current_reports = match Self :: load ( ws) {
109
- Ok ( r) => r,
110
- Err ( e) => {
111
- log:: debug!(
112
- "saving future-incompatible reports failed to load current reports: {:?}" ,
113
- e
114
- ) ;
115
- OnDiskReports :: default ( )
116
- }
117
- } ;
108
+ ) {
118
109
let report = OnDiskReport {
119
- id : current_reports . next_id ,
120
- update_message ,
110
+ id : self . next_id ,
111
+ suggestion_message ,
121
112
per_package : render_report ( per_package_reports) ,
122
113
} ;
123
- current_reports . next_id += 1 ;
124
- current_reports . reports . push ( report) ;
125
- if current_reports . reports . len ( ) > MAX_REPORTS {
126
- current_reports . reports . remove ( 0 ) ;
114
+ self . next_id += 1 ;
115
+ self . reports . push ( report) ;
116
+ if self . reports . len ( ) > MAX_REPORTS {
117
+ self . reports . remove ( 0 ) ;
127
118
}
128
- let on_disk = serde_json:: to_vec ( & current_reports ) . unwrap ( ) ;
119
+ let on_disk = serde_json:: to_vec ( & self ) . unwrap ( ) ;
129
120
if let Err ( e) = ws
130
121
. target_dir ( )
131
122
. open_rw (
@@ -146,7 +137,6 @@ impl OnDiskReports {
146
137
& mut ws. config ( ) . shell ( ) ,
147
138
) ;
148
139
}
149
- current_reports
150
140
}
151
141
152
142
/// Loads the on-disk reports.
@@ -201,7 +191,8 @@ impl OnDiskReports {
201
191
)
202
192
} ) ?;
203
193
204
- let mut to_display = report. update_message . clone ( ) ;
194
+ let mut to_display = report. suggestion_message . clone ( ) ;
195
+ to_display += "\n " ;
205
196
206
197
let package_report = if let Some ( package) = package {
207
198
report
@@ -248,8 +239,7 @@ fn render_report(per_package_reports: &[FutureIncompatReportPackage]) -> BTreeMa
248
239
) ;
249
240
let rendered = report. entry ( package_spec) . or_default ( ) ;
250
241
rendered. push_str ( & format ! (
251
- "The package `{}` currently triggers the following future \
252
- incompatibility lints:\n ",
242
+ "The package `{}` currently triggers the following future incompatibility lints:\n " ,
253
243
per_package. package_id
254
244
) ) ;
255
245
for item in & per_package. items {
@@ -354,6 +344,19 @@ pub fn render_message(
354
344
return ;
355
345
}
356
346
347
+ let current_reports = match OnDiskReports :: load ( bcx. ws ) {
348
+ Ok ( r) => r,
349
+ Err ( e) => {
350
+ log:: debug!(
351
+ "saving future-incompatible reports failed to load current reports: {:?}" ,
352
+ e
353
+ ) ;
354
+ OnDiskReports :: default ( )
355
+ }
356
+ } ;
357
+ let report_id = current_reports. next_id ;
358
+
359
+
357
360
// Get a list of unique and sorted package name/versions.
358
361
let package_ids: BTreeSet < _ > = per_package_future_incompat_reports
359
362
. iter ( )
@@ -384,35 +387,28 @@ You may want to consider updating them to a newer version to see if the issue ha
384
387
String :: new ( )
385
388
} ;
386
389
387
- let on_disk_reports = OnDiskReports :: save_report (
388
- bcx. ws ,
389
- update_message. clone ( ) ,
390
- per_package_future_incompat_reports,
391
- ) ;
392
- let report_id = on_disk_reports. last_id ( ) ;
393
-
394
- if bcx. build_config . future_incompat_report {
395
- let upstream_info = package_ids
396
- . iter ( )
397
- . map ( |package_id| {
398
- let manifest = bcx. packages . get_one ( * package_id) . unwrap ( ) . manifest ( ) ;
399
- format ! (
400
- "
390
+ let upstream_info = package_ids
391
+ . iter ( )
392
+ . map ( |package_id| {
393
+ let manifest = bcx. packages . get_one ( * package_id) . unwrap ( ) . manifest ( ) ;
394
+ format ! (
395
+ "
401
396
- {name}
402
397
- Repository: {url}
403
398
- Detailed warning command: `cargo report future-incompatibilities --id {id} --package {name}`" ,
404
- name = format!( "{}:{}" , package_id. name( ) , package_id. version( ) ) ,
405
- url = manifest
406
- . metadata( )
407
- . repository
408
- . as_deref( )
409
- . unwrap_or( "<not found>" ) ,
410
- id = report_id,
411
- )
412
- } )
413
- . collect :: < Vec < _ > > ( )
399
+ name = format!( "{}:{}" , package_id. name( ) , package_id. version( ) ) ,
400
+ url = manifest
401
+ . metadata( )
402
+ . repository
403
+ . as_deref( )
404
+ . unwrap_or( "<not found>" ) ,
405
+ id = report_id,
406
+ )
407
+ } )
408
+ . collect :: < Vec < _ > > ( )
414
409
. join ( "\n " ) ;
415
- drop ( bcx. config . shell ( ) . note ( & format ! (
410
+
411
+ let suggestion_message = format ! (
416
412
"
417
413
To solve this problem, you can try the following approaches:
418
414
@@ -430,8 +426,17 @@ https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch
430
426
" ,
431
427
upstream_info = upstream_info,
432
428
update_message = update_message,
433
- ) ) ) ;
429
+ ) ;
430
+
434
431
432
+ current_reports. save_report (
433
+ bcx. ws ,
434
+ suggestion_message. clone ( ) ,
435
+ per_package_future_incompat_reports,
436
+ ) ;
437
+
438
+ if bcx. build_config . future_incompat_report {
439
+ drop ( bcx. config . shell ( ) . note ( & suggestion_message) ) ;
435
440
drop ( bcx. config . shell ( ) . note ( & format ! (
436
441
"this report can be shown with `cargo report \
437
442
future-incompatibilities -Z future-incompat-report --id {}`",
0 commit comments