Skip to content

Commit 4d961ed

Browse files
committed
Don't show a suggestion to update dependencies
This removes the suggestion to update dependencies when the future incompat error comes from the local crate. It doesn't make sense to suggest that.
1 parent 497cfe5 commit 4d961ed

File tree

3 files changed

+27
-44
lines changed

3 files changed

+27
-44
lines changed

src/cargo/core/compiler/future_incompat.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ pub struct FutureIncompatReport {
7070
/// Structure used for collecting reports in-memory.
7171
pub struct FutureIncompatReportPackage {
7272
pub package_id: PackageId,
73+
/// Whether or not this is a local package, or a remote dependency.
74+
pub is_local: bool,
7375
pub items: Vec<FutureBreakageItem>,
7476
}
7577

@@ -470,8 +472,15 @@ You may want to consider updating them to a newer version to see if the issue ha
470472
.collect::<Vec<_>>()
471473
.join("\n");
472474

473-
let suggestion_message = format!(
474-
"
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+
"
475484
To solve this problem, you can try the following approaches:
476485
477486
{update_message}
@@ -486,15 +495,18 @@ section in `Cargo.toml` to use your own version of the dependency. For more
486495
information, see:
487496
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
488497
",
489-
upstream_info = upstream_info,
490-
update_message = update_message,
491-
);
498+
upstream_info = upstream_info,
499+
update_message = update_message,
500+
)
501+
};
492502

493503
let saved_report_id =
494504
current_reports.save_report(bcx.ws, suggestion_message.clone(), rendered_report);
495505

496506
if bcx.build_config.future_incompat_report {
497-
drop(bcx.gctx.shell().note(&suggestion_message));
507+
if !suggestion_message.is_empty() {
508+
drop(bcx.gctx.shell().note(&suggestion_message));
509+
}
498510
drop(bcx.gctx.shell().note(&format!(
499511
"this report can be shown with `cargo report \
500512
future-incompatibilities --id {}`",

src/cargo/core/compiler/job_queue/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,15 @@ impl<'gctx> DrainState<'gctx> {
700700
}
701701
}
702702
Message::FutureIncompatReport(id, items) => {
703-
let package_id = self.active[&id].pkg.package_id();
703+
let unit = &self.active[&id];
704+
let package_id = unit.pkg.package_id();
705+
let is_local = unit.is_local();
704706
self.per_package_future_incompat_reports
705-
.push(FutureIncompatReportPackage { package_id, items });
707+
.push(FutureIncompatReportPackage {
708+
package_id,
709+
is_local,
710+
items,
711+
});
706712
}
707713
Message::Token(acquired_token) => {
708714
let token = acquired_token.context("failed to acquire jobserver token")?;

tests/testsuite/future_incompat_report.rs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,6 @@ fn incompat_in_local_crate() {
9191
[WARNING] `foo` (lib) generated 1 warning
9292
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
9393
[WARNING] the following packages contain code that will be rejected by a future version of Rust: foo v0.0.0 ([ROOT]/foo)
94-
[NOTE]
95-
To solve this problem, you can try the following approaches:
96-
97-
98-
- If the issue is not solved by updating the dependencies, a fix has to be
99-
implemented by those dependencies. You can help with that by notifying the
100-
maintainers of this problem (e.g. by creating a bug report) or by proposing a
101-
fix to the maintainers (e.g. by creating a pull request):
102-
103-
104-
- Repository: <not found>
105-
- Detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
106-
107-
- If waiting for an upstream fix is not an option, you can use the `[patch]`
108-
section in `Cargo.toml` to use your own version of the dependency. For more
109-
information, see:
110-
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
111-
11294
[NOTE] this report can be shown with `cargo report future-incompatibilities --id 1`
11395
11496
"#]])
@@ -127,23 +109,6 @@ Each warning should contain a link for more information on what the warning
127109
means and how to resolve it.
128110
129111
130-
To solve this problem, you can try the following approaches:
131-
132-
133-
- If the issue is not solved by updating the dependencies, a fix has to be
134-
implemented by those dependencies. You can help with that by notifying the
135-
maintainers of this problem (e.g. by creating a bug report) or by proposing a
136-
fix to the maintainers (e.g. by creating a pull request):
137-
138-
139-
- Repository: <not found>
140-
- Detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
141-
142-
- If waiting for an upstream fix is not an option, you can use the `[patch]`
143-
section in `Cargo.toml` to use your own version of the dependency. For more
144-
information, see:
145-
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
146-
147112
The package `foo v0.0.0 ([ROOT]/foo)` currently triggers the following future incompatibility lints:
148113
> [WARNING] unused variable: `x`
149114
...
@@ -352,7 +317,7 @@ frequency = 'never'
352317
...
353318
[WARNING] the following packages contain code that will be rejected by a future version of Rust: foo v0.0.0 ([ROOT]/foo)
354319
...
355-
320+
[NOTE] this report can be shown with `cargo report future-incompatibilities --id [..]`
356321
...
357322
")
358323
.run();

0 commit comments

Comments
 (0)