Skip to content

Commit 6bc97fc

Browse files
author
Jon Gjengset
committed
Merge branch 'master' into patch-in-config
2 parents 6995e1d + e78f1c8 commit 6bc97fc

33 files changed

+589
-44
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ im-rc = "15.0.0"
7373
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
7474
# for more information.
7575
rustc-workspace-hack = "1.0.0"
76+
rand = "0.8.3"
7677

7778
[target.'cfg(target_os = "macos")'.dependencies]
7879
core-foundation = { version = "0.9.0", features = ["mac_os_10_7_support"] }

crates/cargo-test-support/src/install.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ use std::path::{Path, PathBuf};
66
/// has been installed. Example usage:
77
///
88
/// assert_has_installed_exe(cargo_home(), "foo");
9+
#[track_caller]
910
pub fn assert_has_installed_exe<P: AsRef<Path>>(path: P, name: &'static str) {
1011
assert!(check_has_installed_exe(path, name));
1112
}
1213

14+
#[track_caller]
1315
pub fn assert_has_not_installed_exe<P: AsRef<Path>>(path: P, name: &'static str) {
1416
assert!(!check_has_installed_exe(path, name));
1517
}

crates/cargo-test-support/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ impl Execs {
732732
self
733733
}
734734

735+
#[track_caller]
735736
pub fn run(&mut self) {
736737
self.ran = true;
737738
let p = (&self.process_builder).clone().unwrap();
@@ -740,6 +741,7 @@ impl Execs {
740741
}
741742
}
742743

744+
#[track_caller]
743745
pub fn run_output(&mut self, output: &Output) {
744746
self.ran = true;
745747
if let Err(e) = self.match_output(output) {

crates/resolver-tests/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,12 +969,14 @@ fn meta_test_multiple_versions_strategy() {
969969
}
970970

971971
/// Assert `xs` contains `elems`
972+
#[track_caller]
972973
pub fn assert_contains<A: PartialEq>(xs: &[A], elems: &[A]) {
973974
for elem in elems {
974975
assert!(xs.contains(elem));
975976
}
976977
}
977978

979+
#[track_caller]
978980
pub fn assert_same<A: PartialEq>(a: &[A], b: &[A]) {
979981
assert_eq!(a.len(), b.len());
980982
assert_contains(b, a);

src/bin/cargo/commands/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub fn cli() -> App {
4343
.arg_message_format()
4444
.arg_build_plan()
4545
.arg_unit_graph()
46+
.arg_future_incompat_report()
4647
.after_help("Run `cargo help build` for more detailed information.\n")
4748
}
4849

src/bin/cargo/commands/check.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub fn cli() -> App {
3535
.arg_ignore_rust_version()
3636
.arg_message_format()
3737
.arg_unit_graph()
38+
.arg_future_incompat_report()
3839
.after_help("Run `cargo help check` for more detailed information.\n")
3940
}
4041

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
use crate::command_prelude::*;
2+
use anyhow::anyhow;
3+
use cargo::core::compiler::future_incompat::{OnDiskReport, FUTURE_INCOMPAT_FILE};
4+
use cargo::drop_eprint;
5+
use cargo::util::CargoResultExt;
6+
use std::io::Read;
7+
8+
pub fn cli() -> App {
9+
subcommand("describe-future-incompatibilities")
10+
.arg(
11+
opt(
12+
"id",
13+
"identifier of the report [generated by a Cargo command invocation",
14+
)
15+
.value_name("id")
16+
.required(true),
17+
)
18+
.about("Reports any crates which will eventually stop compiling")
19+
}
20+
21+
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
22+
if !config.nightly_features_allowed {
23+
return Err(anyhow!(
24+
"`cargo describe-future-incompatibilities` can only be used on the nightly channel"
25+
)
26+
.into());
27+
}
28+
29+
let ws = args.workspace(config)?;
30+
let report_file = ws.target_dir().open_ro(
31+
FUTURE_INCOMPAT_FILE,
32+
ws.config(),
33+
"Future incompatible report",
34+
)?;
35+
36+
let mut file_contents = String::new();
37+
report_file
38+
.file()
39+
.read_to_string(&mut file_contents)
40+
.chain_err(|| "failed to read report")?;
41+
let on_disk_report: OnDiskReport =
42+
serde_json::from_str(&file_contents).chain_err(|| "failed to load report")?;
43+
44+
let id = args.value_of("id").unwrap();
45+
if id != on_disk_report.id {
46+
return Err(anyhow!(
47+
"Expected an id of `{}`, but `{}` was provided on the command line. \
48+
Your report may have been overwritten by a different one.",
49+
on_disk_report.id,
50+
id
51+
)
52+
.into());
53+
}
54+
55+
drop_eprint!(config, "{}", on_disk_report.report);
56+
Ok(())
57+
}

src/bin/cargo/commands/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub fn builtin() -> Vec<App> {
66
build::cli(),
77
check::cli(),
88
clean::cli(),
9+
describe_future_incompatibilities::cli(),
910
doc::cli(),
1011
fetch::cli(),
1112
fix::cli(),
@@ -44,6 +45,7 @@ pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> Cli
4445
"build" => build::exec,
4546
"check" => check::exec,
4647
"clean" => clean::exec,
48+
"describe-future-incompatibilities" => describe_future_incompatibilities::exec,
4749
"doc" => doc::exec,
4850
"fetch" => fetch::exec,
4951
"fix" => fix::exec,
@@ -82,6 +84,7 @@ pub mod bench;
8284
pub mod build;
8385
pub mod check;
8486
pub mod clean;
87+
pub mod describe_future_incompatibilities;
8588
pub mod doc;
8689
pub mod fetch;
8790
pub mod fix;

src/bin/cargo/commands/rustc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub fn cli() -> App {
4040
.arg_message_format()
4141
.arg_unit_graph()
4242
.arg_ignore_rust_version()
43+
.arg_future_incompat_report()
4344
.after_help("Run `cargo help rustc` for more detailed information.\n")
4445
}
4546

src/cargo/core/compiler/build_config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ pub struct BuildConfig {
3737
// Note that, although the cmd-line flag name is `out-dir`, in code we use
3838
// `export_dir`, to avoid confusion with out dir at `target/debug/deps`.
3939
pub export_dir: Option<PathBuf>,
40+
/// `true` to output a future incompatibility report at the end of the build
41+
pub future_incompat_report: bool,
4042
}
4143

4244
impl BuildConfig {
@@ -80,6 +82,7 @@ impl BuildConfig {
8082
primary_unit_rustc: None,
8183
rustfix_diagnostic_server: RefCell::new(None),
8284
export_dir: None,
85+
future_incompat_report: false,
8386
})
8487
}
8588

0 commit comments

Comments
 (0)