Skip to main content

Module future_incompat

Module future_incompat 

Source
Expand description

Support for future-incompatible warning reporting.

Here is an overview of how Cargo handles future-incompatible reports.

Β§Receive reports from the compiler

When receiving a compiler message during a build, if it is effectively a FutureIncompatReport, Cargo gathers and forwards it as a Message::FutureIncompatReport to the main thread.

To have the correct layout of structures for deserializing a report emitted by the compiler, most of structure definitions, for example FutureIncompatReport, are copied either partially or entirely from compiler/rustc_errors/src/json.rs in rust-lang/rust repository.

Β§Persist reports on disk

When a build comes to an end, by calling save_and_display_report Cargo saves the report on disk, and displays it directly if requested via command line or configuration. The information of the on-disk file can be found in FUTURE_INCOMPAT_FILE.

During the persistent process, Cargo will attempt to query the source of each package emitting the report, for the sake of providing an upgrade information as a solution to fix the incompatibility.

Β§Display reports to users

Users can run cargo report future-incompat to retrieve a report. This is done by OnDiskReports::load. Cargo simply prints reports to the standard output.

Re-exportsΒ§

use crate::compiler::BuildContext; πŸ”’
use crate::sources::IndexSummary; πŸ”’
use crate::sources::SourceConfigMap; πŸ”’
use crate::sources::source::QueryKind; πŸ”’
use crate::util::CargoResult; πŸ”’
use crate::util::cache_lock::CacheLockMode; πŸ”’
use crate::workspace::Dependency; πŸ”’
use crate::workspace::PackageId; πŸ”’
use crate::workspace::Workspace; πŸ”’
use anyhow::Context; πŸ”’
use anyhow::bail; πŸ”’
use anyhow::format_err; πŸ”’
use cargo_util::collections::HashMap; πŸ”’
use cargo_util::collections::HashSet; πŸ”’
use futures::stream::FuturesUnordered; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Serialize; πŸ”’
use serde::Serialize; πŸ”’
use std::collections::BTreeMap; πŸ”’
use std::collections::BTreeSet; πŸ”’
use std::fmt::Write as _; πŸ”’
use std::io::Read; πŸ”’
use std::io::Write; πŸ”’

StructsΒ§

Diagnostic
A diagnostic emitted by the compiler as a JSON message. We only care about the β€˜rendered’ field
FutureBreakageItem
A single future-incompatible warning emitted by rustc.
FutureIncompatReport
The future incompatibility report, emitted by the compiler as a JSON message.
FutureIncompatReportPackage
Structure used for collecting reports in-memory.
OnDiskReport πŸ”’
A single report for a given compilation session.
OnDiskReports
The structure saved to disk containing the reports.

ConstantsΒ§

FUTURE_INCOMPAT_FILE πŸ”’
The filename in the top-level build-dir directory where we store the report
MAX_REPORTS πŸ”’
Max number of reports to save on disk.
ON_DISK_VERSION πŸ”’
Current version of the on-disk format.
REPORT_PREAMBLE

FunctionsΒ§

get_updates πŸ”’
Returns a user-readable message explaining which of the packages in package_ids have updates available. This is best-effort - if an error occurs, None will be returned.
render_report πŸ”’
save_and_display_report
Writes a future-incompat report to disk, using the per-package reports gathered during the build. If requested by the user, a message is also displayed in the build output.