@@ -70,6 +70,8 @@ pub struct FutureIncompatReport {
70
70
/// Structure used for collecting reports in-memory.
71
71
pub struct FutureIncompatReportPackage {
72
72
pub package_id : PackageId ,
73
+ /// Whether or not this is a local package, or a remote dependency.
74
+ pub is_local : bool ,
73
75
pub items : Vec < FutureBreakageItem > ,
74
76
}
75
77
@@ -140,16 +142,10 @@ impl OnDiskReports {
140
142
mut self ,
141
143
ws : & Workspace < ' _ > ,
142
144
suggestion_message : String ,
143
- per_package_reports : & [ FutureIncompatReportPackage ] ,
145
+ per_package : BTreeMap < String , String > ,
144
146
) -> u32 {
145
- let per_package = render_report ( per_package_reports) ;
146
-
147
- if let Some ( existing_report) = self
148
- . reports
149
- . iter ( )
150
- . find ( |existing| existing. per_package == per_package)
151
- {
152
- return existing_report. id ;
147
+ if let Some ( existing_id) = self . has_report ( & per_package) {
148
+ return existing_id;
153
149
}
154
150
155
151
let report = OnDiskReport {
@@ -189,6 +185,14 @@ impl OnDiskReports {
189
185
saved_id
190
186
}
191
187
188
+ /// Returns the ID of a report if it is already on disk.
189
+ fn has_report ( & self , rendered_per_package : & BTreeMap < String , String > ) -> Option < u32 > {
190
+ self . reports
191
+ . iter ( )
192
+ . find ( |existing| & existing. per_package == rendered_per_package)
193
+ . map ( |report| report. id )
194
+ }
195
+
192
196
/// Loads the on-disk reports.
193
197
pub fn load ( ws : & Workspace < ' _ > ) -> CargoResult < OnDiskReports > {
194
198
let report_file = match ws. build_dir ( ) . open_ro_shared (
@@ -408,7 +412,14 @@ pub fn save_and_display_report(
408
412
OnDiskReports :: default ( )
409
413
}
410
414
} ;
411
- let report_id = current_reports. next_id ;
415
+
416
+ let rendered_report = render_report ( per_package_future_incompat_reports) ;
417
+
418
+ // If the report is already on disk, then it will reuse the same ID,
419
+ // otherwise prepare for the next ID.
420
+ let report_id = current_reports
421
+ . has_report ( & rendered_report)
422
+ . unwrap_or ( current_reports. next_id ) ;
412
423
413
424
// Get a list of unique and sorted package name/versions.
414
425
let package_ids: BTreeSet < _ > = per_package_future_incompat_reports
@@ -461,11 +472,18 @@ You may want to consider updating them to a newer version to see if the issue ha
461
472
. collect :: < Vec < _ > > ( )
462
473
. join ( "\n " ) ;
463
474
464
- let suggestion_message = format ! (
465
- "
475
+ let all_is_local = per_package_future_incompat_reports
476
+ . iter ( )
477
+ . all ( |report| report. is_local ) ;
478
+
479
+ let suggestion_message = if all_is_local {
480
+ String :: new ( )
481
+ } else {
482
+ format ! (
483
+ "
466
484
To solve this problem, you can try the following approaches:
467
485
468
- {update_message}
486
+ {update_message}\
469
487
- If the issue is not solved by updating the dependencies, a fix has to be
470
488
implemented by those dependencies. You can help with that by notifying the
471
489
maintainers of this problem (e.g. by creating a bug report) or by proposing a
@@ -476,19 +494,19 @@ fix to the maintainers (e.g. by creating a pull request):
476
494
section in `Cargo.toml` to use your own version of the dependency. For more
477
495
information, see:
478
496
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
479
- " ,
480
- upstream_info = upstream_info,
481
- update_message = update_message,
482
- ) ;
497
+ " ,
498
+ upstream_info = upstream_info,
499
+ update_message = update_message,
500
+ )
501
+ } ;
483
502
484
- let saved_report_id = current_reports. save_report (
485
- bcx. ws ,
486
- suggestion_message. clone ( ) ,
487
- per_package_future_incompat_reports,
488
- ) ;
503
+ let saved_report_id =
504
+ current_reports. save_report ( bcx. ws , suggestion_message. clone ( ) , rendered_report) ;
489
505
490
506
if bcx. build_config . future_incompat_report {
491
- drop ( bcx. gctx . shell ( ) . note ( & suggestion_message) ) ;
507
+ if !suggestion_message. is_empty ( ) {
508
+ drop ( bcx. gctx . shell ( ) . note ( & suggestion_message) ) ;
509
+ }
492
510
drop ( bcx. gctx . shell ( ) . note ( & format ! (
493
511
"this report can be shown with `cargo report \
494
512
future-incompatibilities --id {}`",
0 commit comments