@@ -78,9 +78,9 @@ pub struct OnDiskReports {
7878struct OnDiskReport {
7979 /// Unique reference to the report for the `--id` CLI flag.
8080 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 ,
8484 /// Report, suitable for printing to the console.
8585 /// Maps package names to the corresponding report
8686 /// We use a `BTreeMap` so that the iteration order
@@ -101,31 +101,22 @@ impl Default for OnDiskReports {
101101impl OnDiskReports {
102102 /// Saves a new report.
103103 pub fn save_report (
104+ mut self ,
104105 ws : & Workspace < ' _ > ,
105- update_message : String ,
106+ suggestion_message : String ,
106107 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+ ) {
118109 let report = OnDiskReport {
119- id : current_reports . next_id ,
120- update_message ,
110+ id : self . next_id ,
111+ suggestion_message ,
121112 per_package : render_report ( per_package_reports) ,
122113 } ;
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 ) ;
127118 }
128- let on_disk = serde_json:: to_vec ( & current_reports ) . unwrap ( ) ;
119+ let on_disk = serde_json:: to_vec ( & self ) . unwrap ( ) ;
129120 if let Err ( e) = ws
130121 . target_dir ( )
131122 . open_rw (
@@ -146,7 +137,6 @@ impl OnDiskReports {
146137 & mut ws. config ( ) . shell ( ) ,
147138 ) ;
148139 }
149- current_reports
150140 }
151141
152142 /// Loads the on-disk reports.
@@ -201,7 +191,8 @@ impl OnDiskReports {
201191 )
202192 } ) ?;
203193
204- let mut to_display = report. update_message . clone ( ) ;
194+ let mut to_display = report. suggestion_message . clone ( ) ;
195+ to_display += "\n " ;
205196
206197 let package_report = if let Some ( package) = package {
207198 report
@@ -248,8 +239,7 @@ fn render_report(per_package_reports: &[FutureIncompatReportPackage]) -> BTreeMa
248239 ) ;
249240 let rendered = report. entry ( package_spec) . or_default ( ) ;
250241 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 " ,
253243 per_package. package_id
254244 ) ) ;
255245 for item in & per_package. items {
@@ -354,6 +344,19 @@ pub fn render_message(
354344 return ;
355345 }
356346
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+
357360 // Get a list of unique and sorted package name/versions.
358361 let package_ids: BTreeSet < _ > = per_package_future_incompat_reports
359362 . iter ( )
@@ -384,35 +387,28 @@ You may want to consider updating them to a newer version to see if the issue ha
384387 String :: new ( )
385388 } ;
386389
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+ "
401396 - {name}
402397 - Repository: {url}
403398 - 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 < _ > > ( )
414409 . join ( "\n " ) ;
415- drop ( bcx. config . shell ( ) . note ( & format ! (
410+
411+ let suggestion_message = format ! (
416412 "
417413To solve this problem, you can try the following approaches:
418414
@@ -430,8 +426,17 @@ https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch
430426 " ,
431427 upstream_info = upstream_info,
432428 update_message = update_message,
433- ) ) ) ;
429+ ) ;
430+
434431
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) ) ;
435440 drop ( bcx. config . shell ( ) . note ( & format ! (
436441 "this report can be shown with `cargo report \
437442 future-incompatibilities -Z future-incompat-report --id {}`",
0 commit comments