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
- Future
Breakage Item - A single future-incompatible warning emitted by rustc.
- Future
Incompat Report - The future incompatibility report, emitted by the compiler as a JSON message.
- Future
Incompat Report Package - Structure used for collecting reports in-memory.
- OnDisk
Report π - A single report for a given compilation session.
- OnDisk
Reports - The structure saved to disk containing the reports.
ConstantsΒ§
- FUTURE_
INCOMPAT_ πFILE - The filename in the top-level
build-dirdirectory 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_idshave updates available. This is best-effort - if an error occurs,Nonewill 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.