Skip to content

Commit b190379

Browse files
committed
fix(future): Report all content as a single Report
1 parent 7719031 commit b190379

File tree

2 files changed

+62
-70
lines changed

2 files changed

+62
-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: 52 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ fn incompat_in_local_crate() {
7777
[WARNING] `foo` (lib) generated 1 warning
7878
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
7979
[WARNING] the following packages contain code that will be rejected by a future version of Rust: foo v0.0.0 ([ROOT]/foo)
80+
|
8081
[NOTE] to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
8182
8283
"#]])
@@ -91,6 +92,7 @@ fn incompat_in_local_crate() {
9192
[WARNING] `foo` (lib) generated 1 warning
9293
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
9394
[WARNING] the following packages contain code that will be rejected by a future version of Rust: foo v0.0.0 ([ROOT]/foo)
95+
|
9496
[NOTE] this report can be shown with `cargo report future-incompatibilities --id 1`
9597
9698
"#]])
@@ -136,6 +138,7 @@ fn incompat_in_dependency() {
136138
[CHECKING] foo v1.0.0 ([ROOT]/foo)
137139
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
138140
[WARNING] the following packages contain code that will be rejected by a future version of Rust: bar v1.0.0
141+
|
139142
[NOTE] to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
140143
141144
"#]])
@@ -146,18 +149,15 @@ fn incompat_in_dependency() {
146149
.with_stderr_data(str![[r#"
147150
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
148151
[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-
154-
- repository: https://example.com/
155-
- detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
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-
152+
|
153+
[HELP] ensure the maintainers know of this problem (e.g. creating a bug report if needed)
154+
or even helping with a fix (e.g. by creating a pull request)
155+
156+
- repository: https://example.com/
157+
- detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
158+
[HELP] use your own version of the dependency with the `[patch]` section in `Cargo.toml`
159+
For more information, see:
160+
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
161161
[NOTE] this report can be shown with `cargo report future-incompatibilities --id 1`
162162
163163
"#]])
@@ -362,9 +362,9 @@ fn test_multi_crate() {
362362
...
363363
[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
364364
...
365-
365+
366366
...
367-
367+
368368
...
369369
")
370370
.run();
@@ -593,30 +593,26 @@ fn suggestions_for_updates() {
593593
[CHECKING] foo v0.1.0 ([ROOT]/foo)
594594
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
595595
[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-
605-
- repository: <not found>
606-
- detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
607-
608-
609-
- repository: <not found>
610-
- detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
611-
612-
613-
- repository: <not found>
614-
- detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
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-
596+
|
597+
[HELP] update to a newer version to see if the issue has been fixed
598+
- big_update v1.0.0 has the following newer versions available: 2.0.0
599+
- with_updates v1.0.0 has the following newer versions available: 1.0.1, 1.0.2, 3.0.1
600+
[HELP] ensure the maintainers know of this problem (e.g. creating a bug report if needed)
601+
or even helping with a fix (e.g. by creating a pull request)
602+
603+
- repository: <not found>
604+
- detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
605+
606+
607+
- repository: <not found>
608+
- detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
609+
610+
611+
- repository: <not found>
612+
- detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
613+
[HELP] use your own version of the dependency with the `[patch]` section in `Cargo.toml`
614+
For more information, see:
615+
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
620616
[NOTE] this report can be shown with `cargo report future-incompatibilities --id 1`
621617
622618
"#]])
@@ -694,18 +690,15 @@ fn correct_report_id_when_cached() {
694690
[CHECKING] foo v1.0.0 ([ROOT]/foo)
695691
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
696692
[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-
702-
- repository: https://example.com/
703-
- detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
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-
693+
|
694+
[HELP] ensure the maintainers know of this problem (e.g. creating a bug report if needed)
695+
or even helping with a fix (e.g. by creating a pull request)
696+
697+
- repository: https://example.com/
698+
- detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
699+
[HELP] use your own version of the dependency with the `[patch]` section in `Cargo.toml`
700+
For more information, see:
701+
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
709702
[NOTE] this report can be shown with `cargo report future-incompatibilities --id 1`
710703
711704
"#]])
@@ -716,18 +709,15 @@ https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch
716709
.with_stderr_data(str![[r#"
717710
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
718711
[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-
724-
- repository: https://example.com/
725-
- detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
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-
712+
|
713+
[HELP] ensure the maintainers know of this problem (e.g. creating a bug report if needed)
714+
or even helping with a fix (e.g. by creating a pull request)
715+
716+
- repository: https://example.com/
717+
- detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
718+
[HELP] use your own version of the dependency with the `[patch]` section in `Cargo.toml`
719+
For more information, see:
720+
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
731721
[NOTE] this report can be shown with `cargo report future-incompatibilities --id 1`
732722
733723
"#]])

0 commit comments

Comments
 (0)