-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into patch-in-config
- Loading branch information
Showing
33 changed files
with
589 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/bin/cargo/commands/describe_future_incompatibilities.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use crate::command_prelude::*; | ||
use anyhow::anyhow; | ||
use cargo::core::compiler::future_incompat::{OnDiskReport, FUTURE_INCOMPAT_FILE}; | ||
use cargo::drop_eprint; | ||
use cargo::util::CargoResultExt; | ||
use std::io::Read; | ||
|
||
pub fn cli() -> App { | ||
subcommand("describe-future-incompatibilities") | ||
.arg( | ||
opt( | ||
"id", | ||
"identifier of the report [generated by a Cargo command invocation", | ||
) | ||
.value_name("id") | ||
.required(true), | ||
) | ||
.about("Reports any crates which will eventually stop compiling") | ||
} | ||
|
||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { | ||
if !config.nightly_features_allowed { | ||
return Err(anyhow!( | ||
"`cargo describe-future-incompatibilities` can only be used on the nightly channel" | ||
) | ||
.into()); | ||
} | ||
|
||
let ws = args.workspace(config)?; | ||
let report_file = ws.target_dir().open_ro( | ||
FUTURE_INCOMPAT_FILE, | ||
ws.config(), | ||
"Future incompatible report", | ||
)?; | ||
|
||
let mut file_contents = String::new(); | ||
report_file | ||
.file() | ||
.read_to_string(&mut file_contents) | ||
.chain_err(|| "failed to read report")?; | ||
let on_disk_report: OnDiskReport = | ||
serde_json::from_str(&file_contents).chain_err(|| "failed to load report")?; | ||
|
||
let id = args.value_of("id").unwrap(); | ||
if id != on_disk_report.id { | ||
return Err(anyhow!( | ||
"Expected an id of `{}`, but `{}` was provided on the command line. \ | ||
Your report may have been overwritten by a different one.", | ||
on_disk_report.id, | ||
id | ||
) | ||
.into()); | ||
} | ||
|
||
drop_eprint!(config, "{}", on_disk_report.report); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// The future incompatibility report, emitted by the compiler as a JSON message. | ||
#[derive(serde::Deserialize)] | ||
pub struct FutureIncompatReport { | ||
pub future_incompat_report: Vec<FutureBreakageItem>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct FutureBreakageItem { | ||
/// The date at which this lint will become an error. | ||
/// Currently unused | ||
pub future_breakage_date: Option<String>, | ||
/// The original diagnostic emitted by the compiler | ||
pub diagnostic: Diagnostic, | ||
} | ||
|
||
/// A diagnostic emitted by the compiler as a JSON message. | ||
/// We only care about the 'rendered' field | ||
#[derive(Serialize, Deserialize)] | ||
pub struct Diagnostic { | ||
pub rendered: String, | ||
} | ||
|
||
/// The filename in the top-level `target` directory where we store | ||
/// the report | ||
pub const FUTURE_INCOMPAT_FILE: &str = ".future-incompat-report.json"; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct OnDiskReport { | ||
// A Cargo-generated id used to detect when a report has been overwritten | ||
pub id: String, | ||
// Cannot be a &str, since Serde needs | ||
// to be able to un-escape the JSON | ||
pub report: String, | ||
} |
Oops, something went wrong.