Skip to content

Commit 2c5b4df

Browse files
committed
fix(future): Report all content as a single Report
1 parent 8e1cdcf commit 2c5b4df

File tree

2 files changed

+55
-70
lines changed

2 files changed

+55
-70
lines changed

src/cargo/core/compiler/future_incompat.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -505,27 +505,29 @@ https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch
505505
current_reports.save_report(bcx.ws, suggestion_message.clone(), rendered_report);
506506

507507
if should_display_message || bcx.build_config.future_incompat_report {
508-
drop(bcx.gctx.shell().warn(&format!(
508+
use annotate_snippets::*;
509+
let mut report = vec![Group::with_title(Level::WARNING.secondary_title(format!(
509510
"the following packages contain code that will be rejected by a future \
510511
version of Rust: {}",
511512
package_vers.join(", ")
512-
)));
513+
)))];
513514
if bcx.build_config.future_incompat_report {
514-
if !suggestion_message.is_empty() {
515-
drop(bcx.gctx.shell().note(&suggestion_message));
515+
for suggestion in &suggestions {
516+
report.push(Group::with_title(Level::HELP.secondary_title(suggestion)));
516517
}
517-
drop(bcx.gctx.shell().note(&format!(
518+
report.push(Group::with_title(Level::NOTE.secondary_title(format!(
518519
"this report can be shown with `cargo report \
519520
future-incompatibilities --id {}`",
520521
saved_report_id
521-
)));
522+
))));
522523
} else if should_display_message {
523-
drop(bcx.gctx.shell().note(&format!(
524+
report.push(Group::with_title(Level::NOTE.secondary_title(format!(
524525
"to see what the problems were, use the option \
525526
`--future-incompat-report`, or run `cargo report \
526527
future-incompatibilities --id {}`",
527528
saved_report_id
528-
)));
529+
))));
529530
}
531+
drop(bcx.gctx.shell().print_report(&report, false))
530532
}
531533
}

tests/testsuite/future_incompat_report.rs

Lines changed: 45 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,14 @@ fn incompat_in_dependency() {
146146
.with_stderr_data(str![[r#"
147147
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
148148
[WARNING] the following packages contain code that will be rejected by a future version of Rust: bar v1.0.0
149-
[NOTE] to solve this problem, you can try the following approaches:
150-
151-
- ensure the maintainers know of this problem (e.g. creating a bug report if needed)
152-
or even helping with a fix (e.g. by creating a pull request)
153-
- bar@1.0.0
154-
- repository: https://example.com/
155-
- detailed warning command: `cargo report future-incompatibilities --id 1 --package bar@1.0.0`
156-
157-
- use your own version of the dependency with the `[patch]` section in `Cargo.toml`
158-
For more information, see:
159-
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
160-
149+
[HELP] ensure the maintainers know of this problem (e.g. creating a bug report if needed)
150+
or even helping with a fix (e.g. by creating a pull request)
151+
- bar@1.0.0
152+
- repository: https://example.com/
153+
- detailed warning command: `cargo report future-incompatibilities --id 1 --package bar@1.0.0`
154+
[HELP] use your own version of the dependency with the `[patch]` section in `Cargo.toml`
155+
For more information, see:
156+
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
161157
[NOTE] this report can be shown with `cargo report future-incompatibilities --id 1`
162158
163159
"#]])
@@ -362,9 +358,9 @@ fn test_multi_crate() {
362358
...
363359
[WARNING] the following packages contain code that will be rejected by a future version of Rust: first-dep v0.0.1, second-dep v0.0.2
364360
...
365-
- first-dep@0.0.1
361+
- first-dep@0.0.1
366362
...
367-
- second-dep@0.0.2
363+
- second-dep@0.0.2
368364
...
369365
")
370366
.run();
@@ -593,30 +589,25 @@ fn suggestions_for_updates() {
593589
[CHECKING] foo v0.1.0 ([ROOT]/foo)
594590
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
595591
[WARNING] the following packages contain code that will be rejected by a future version of Rust: big_update v1.0.0, with_updates v1.0.0, without_updates v1.0.0
596-
[NOTE] to solve this problem, you can try the following approaches:
597-
598-
- update to a newer version to see if the issue has been fixed
599-
- big_update v1.0.0 has the following newer versions available: 2.0.0
600-
- with_updates v1.0.0 has the following newer versions available: 1.0.1, 1.0.2, 3.0.1
601-
602-
- ensure the maintainers know of this problem (e.g. creating a bug report if needed)
603-
or even helping with a fix (e.g. by creating a pull request)
604-
- big_update@1.0.0
605-
- repository: <not found>
606-
- detailed warning command: `cargo report future-incompatibilities --id 1 --package big_update@1.0.0`
607-
608-
- with_updates@1.0.0
609-
- repository: <not found>
610-
- detailed warning command: `cargo report future-incompatibilities --id 1 --package with_updates@1.0.0`
611-
612-
- without_updates@1.0.0
613-
- repository: <not found>
614-
- detailed warning command: `cargo report future-incompatibilities --id 1 --package without_updates@1.0.0`
615-
616-
- use your own version of the dependency with the `[patch]` section in `Cargo.toml`
617-
For more information, see:
618-
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
619-
592+
[HELP] update to a newer version to see if the issue has been fixed
593+
- big_update v1.0.0 has the following newer versions available: 2.0.0
594+
- with_updates v1.0.0 has the following newer versions available: 1.0.1, 1.0.2, 3.0.1
595+
[HELP] ensure the maintainers know of this problem (e.g. creating a bug report if needed)
596+
or even helping with a fix (e.g. by creating a pull request)
597+
- big_update@1.0.0
598+
- repository: <not found>
599+
- detailed warning command: `cargo report future-incompatibilities --id 1 --package big_update@1.0.0`
600+
601+
- with_updates@1.0.0
602+
- repository: <not found>
603+
- detailed warning command: `cargo report future-incompatibilities --id 1 --package with_updates@1.0.0`
604+
605+
- without_updates@1.0.0
606+
- repository: <not found>
607+
- detailed warning command: `cargo report future-incompatibilities --id 1 --package without_updates@1.0.0`
608+
[HELP] use your own version of the dependency with the `[patch]` section in `Cargo.toml`
609+
For more information, see:
610+
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
620611
[NOTE] this report can be shown with `cargo report future-incompatibilities --id 1`
621612
622613
"#]])
@@ -694,18 +685,14 @@ fn correct_report_id_when_cached() {
694685
[CHECKING] foo v1.0.0 ([ROOT]/foo)
695686
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
696687
[WARNING] the following packages contain code that will be rejected by a future version of Rust: bar v1.0.0
697-
[NOTE] to solve this problem, you can try the following approaches:
698-
699-
- ensure the maintainers know of this problem (e.g. creating a bug report if needed)
700-
or even helping with a fix (e.g. by creating a pull request)
701-
- bar@1.0.0
702-
- repository: https://example.com/
703-
- detailed warning command: `cargo report future-incompatibilities --id 1 --package bar@1.0.0`
704-
705-
- use your own version of the dependency with the `[patch]` section in `Cargo.toml`
706-
For more information, see:
707-
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
708-
688+
[HELP] ensure the maintainers know of this problem (e.g. creating a bug report if needed)
689+
or even helping with a fix (e.g. by creating a pull request)
690+
- bar@1.0.0
691+
- repository: https://example.com/
692+
- detailed warning command: `cargo report future-incompatibilities --id 1 --package bar@1.0.0`
693+
[HELP] use your own version of the dependency with the `[patch]` section in `Cargo.toml`
694+
For more information, see:
695+
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
709696
[NOTE] this report can be shown with `cargo report future-incompatibilities --id 1`
710697
711698
"#]])
@@ -716,18 +703,14 @@ https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch
716703
.with_stderr_data(str![[r#"
717704
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
718705
[WARNING] the following packages contain code that will be rejected by a future version of Rust: bar v1.0.0
719-
[NOTE] to solve this problem, you can try the following approaches:
720-
721-
- ensure the maintainers know of this problem (e.g. creating a bug report if needed)
722-
or even helping with a fix (e.g. by creating a pull request)
723-
- bar@1.0.0
724-
- repository: https://example.com/
725-
- detailed warning command: `cargo report future-incompatibilities --id 1 --package bar@1.0.0`
726-
727-
- use your own version of the dependency with the `[patch]` section in `Cargo.toml`
728-
For more information, see:
729-
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
730-
706+
[HELP] ensure the maintainers know of this problem (e.g. creating a bug report if needed)
707+
or even helping with a fix (e.g. by creating a pull request)
708+
- bar@1.0.0
709+
- repository: https://example.com/
710+
- detailed warning command: `cargo report future-incompatibilities --id 1 --package bar@1.0.0`
711+
[HELP] use your own version of the dependency with the `[patch]` section in `Cargo.toml`
712+
For more information, see:
713+
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
731714
[NOTE] this report can be shown with `cargo report future-incompatibilities --id 1`
732715
733716
"#]])

0 commit comments

Comments
 (0)