@@ -359,9 +359,10 @@ fn get_updates(ws: &Workspace<'_>, package_ids: &BTreeSet<PackageId>) -> Option<
359
359
360
360
if !updated_versions. is_empty ( ) {
361
361
let updated_versions = itertools:: join ( updated_versions, ", " ) ;
362
- writeln ! (
362
+ write ! (
363
363
updates,
364
- "{} has the following newer versions available: {}" ,
364
+ "
365
+ - {} has the following newer versions available: {}" ,
365
366
pkg_id, updated_versions
366
367
)
367
368
. unwrap ( ) ;
@@ -428,23 +429,12 @@ pub fn save_and_display_report(
428
429
. collect ( ) ;
429
430
let package_vers: Vec < _ > = package_ids. iter ( ) . map ( |pid| pid. to_string ( ) ) . collect ( ) ;
430
431
431
- if should_display_message || bcx. build_config . future_incompat_report {
432
- drop ( bcx. gctx . shell ( ) . warn ( & format ! (
433
- "the following packages contain code that will be rejected by a future \
434
- version of Rust: {}",
435
- package_vers. join( ", " )
436
- ) ) ) ;
437
- }
438
-
439
432
let updated_versions = get_updates ( bcx. ws , & package_ids) . unwrap_or ( String :: new ( ) ) ;
440
433
441
434
let update_message = if !updated_versions. is_empty ( ) {
442
435
format ! (
443
- "
444
- - Some affected dependencies have newer versions available.
445
- You may want to consider updating them to a newer version to see if the issue has been fixed.
446
-
447
- {updated_versions}\n " ,
436
+ "\
437
+ update to a newer version to see if the issue has been fixed{updated_versions}",
448
438
updated_versions = updated_versions
449
439
)
450
440
} else {
@@ -456,10 +446,9 @@ You may want to consider updating them to a newer version to see if the issue ha
456
446
. map ( |package_id| {
457
447
let manifest = bcx. packages . get_one ( * package_id) . unwrap ( ) . manifest ( ) ;
458
448
format ! (
459
- "
460
- - {package_spec}
461
- - Repository: {url}
462
- - Detailed warning command: `cargo report future-incompatibilities --id {id} --package {package_spec}`" ,
449
+ " - {package_spec}
450
+ - repository: {url}
451
+ - detailed warning command: `cargo report future-incompatibilities --id {id} --package {package_spec}`" ,
463
452
package_spec = format!( "{}@{}" , package_id. name( ) , package_id. version( ) ) ,
464
453
url = manifest
465
454
. metadata( )
@@ -470,54 +459,75 @@ You may want to consider updating them to a newer version to see if the issue ha
470
459
)
471
460
} )
472
461
. collect :: < Vec < _ > > ( )
473
- . join ( "\n " ) ;
462
+ . join ( "\n \n " ) ;
474
463
475
464
let all_is_local = per_package_future_incompat_reports
476
465
. iter ( )
477
466
. all ( |report| report. is_local ) ;
478
467
479
- let suggestion_message = if all_is_local {
468
+ let suggestion_header = "to solve this problem, you can try the following approaches:" ;
469
+ let mut suggestions = Vec :: new ( ) ;
470
+ if !all_is_local {
471
+ if !update_message. is_empty ( ) {
472
+ suggestions. push ( update_message) ;
473
+ }
474
+ suggestions. push ( format ! (
475
+ "\
476
+ ensure the maintainers know of this problem (e.g. creating a bug report if needed)
477
+ or even helping with a fix (e.g. by creating a pull request)
478
+ {upstream_info}"
479
+ ) ) ;
480
+ suggestions. push (
481
+ "\
482
+ use your own version of the dependency with the `[patch]` section in `Cargo.toml`
483
+ For more information, see:
484
+ https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section"
485
+ . to_owned ( ) ,
486
+ ) ;
487
+ }
488
+
489
+ let suggestion_message = if suggestions. is_empty ( ) {
480
490
String :: new ( )
481
491
} else {
482
- format ! (
483
- "
484
- To solve this problem, you can try the following approaches:
485
-
486
- {update_message}\
487
- - If the issue is not solved by updating the dependencies, a fix has to be
488
- implemented by those dependencies. You can help with that by notifying the
489
- maintainers of this problem (e.g. by creating a bug report) or by proposing a
490
- fix to the maintainers (e.g. by creating a pull request):
491
- {upstream_info}
492
-
493
- - If waiting for an upstream fix is not an option, you can use the `[patch]`
494
- section in `Cargo.toml` to use your own version of the dependency. For more
495
- information, see:
496
- https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
497
- " ,
498
- upstream_info = upstream_info,
499
- update_message = update_message,
500
- )
492
+ let mut suggestion_message = String :: new ( ) ;
493
+ writeln ! ( & mut suggestion_message, "{suggestion_header}" ) . unwrap ( ) ;
494
+ for suggestion in & suggestions {
495
+ writeln ! (
496
+ & mut suggestion_message,
497
+ "
498
+ - {suggestion}"
499
+ )
500
+ . unwrap ( ) ;
501
+ }
502
+ suggestion_message
501
503
} ;
502
-
503
504
let saved_report_id =
504
505
current_reports. save_report ( bcx. ws , suggestion_message. clone ( ) , rendered_report) ;
505
506
506
- if bcx. build_config . future_incompat_report {
507
- if !suggestion_message. is_empty ( ) {
508
- drop ( bcx. gctx . shell ( ) . note ( & suggestion_message) ) ;
509
- }
510
- drop ( bcx. gctx . shell ( ) . note ( & format ! (
511
- "this report can be shown with `cargo report \
507
+ if should_display_message || bcx. build_config . future_incompat_report {
508
+ use annotate_snippets:: * ;
509
+ let mut report = vec ! [ Group :: with_title( Level :: WARNING . secondary_title( format!(
510
+ "the following packages contain code that will be rejected by a future \
511
+ version of Rust: {}",
512
+ package_vers. join( ", " )
513
+ ) ) ) ] ;
514
+ if bcx. build_config . future_incompat_report {
515
+ for suggestion in & suggestions {
516
+ report. push ( Group :: with_title ( Level :: HELP . secondary_title ( suggestion) ) ) ;
517
+ }
518
+ report. push ( Group :: with_title ( Level :: NOTE . secondary_title ( format ! (
519
+ "this report can be shown with `cargo report \
512
520
future-incompatibilities --id {}`",
513
- saved_report_id
514
- ) ) ) ;
515
- } else if should_display_message {
516
- drop ( bcx . gctx . shell ( ) . note ( & format ! (
517
- "to see what the problems were, use the option \
521
+ saved_report_id
522
+ ) ) ) ) ;
523
+ } else if should_display_message {
524
+ report . push ( Group :: with_title ( Level :: NOTE . secondary_title ( format ! (
525
+ "to see what the problems were, use the option \
518
526
`--future-incompat-report`, or run `cargo report \
519
527
future-incompatibilities --id {}`",
520
- saved_report_id
521
- ) ) ) ;
528
+ saved_report_id
529
+ ) ) ) ) ;
530
+ }
531
+ drop ( bcx. gctx . shell ( ) . print_report ( & report, false ) )
522
532
}
523
533
}
0 commit comments