Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid saving the same future_incompat warning multiple times #11648

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/cargo/core/compiler/future_incompat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,30 @@ impl Default for OnDiskReports {
}

impl OnDiskReports {
/// Saves a new report.
/// Saves a new report returning its id
pub fn save_report(
mut self,
ws: &Workspace<'_>,
suggestion_message: String,
per_package_reports: &[FutureIncompatReportPackage],
) {
) -> u32 {
let per_package = render_report(per_package_reports);

if let Some(existing_report) = self
.reports
.iter()
.find(|existing| existing.per_package == per_package)
{
return existing_report.id;
}

let report = OnDiskReport {
id: self.next_id,
suggestion_message,
per_package: render_report(per_package_reports),
per_package,
};

let saved_id = report.id;
self.next_id += 1;
self.reports.push(report);
if self.reports.len() > MAX_REPORTS {
Expand All @@ -138,6 +150,8 @@ impl OnDiskReports {
&mut ws.config().shell(),
);
}

saved_id
}

/// Loads the on-disk reports.
Expand Down Expand Up @@ -450,7 +464,7 @@ https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch
update_message = update_message,
);

current_reports.save_report(
let saved_report_id = current_reports.save_report(
bcx.ws,
suggestion_message.clone(),
per_package_future_incompat_reports,
Expand All @@ -461,14 +475,14 @@ https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch
drop(bcx.config.shell().note(&format!(
"this report can be shown with `cargo report \
future-incompatibilities --id {}`",
report_id
saved_report_id
)));
} else if should_display_message {
drop(bcx.config.shell().note(&format!(
"to see what the problems were, use the option \
`--future-incompat-report`, or run `cargo report \
future-incompatibilities --id {}`",
report_id
saved_report_id
)));
}
}